Netduino home hardware projects downloads community

Jump to content


Photo

Running a VB program -- it remembers the old serial port


  • Please log in to reply
3 replies to this topic

#1 Dr Who

Dr Who

    Advanced Member

  • Members
  • PipPipPip
  • 261 posts
  • LocationNYC

Posted 04 August 2015 - 03:39 AM

Hello!

I decided to try and revive an program which successfully ran on the Mini, which will cycle an SN74278 device.

 

It turns out that this program:

Imports Microsoft.SPOT
Imports Microsoft.SPOT.Hardware
Imports SecretLabs.NETMF.Hardware
Imports SecretLabs.NETMF.Hardware.NetduinoMini

Module Module1

    Sub Main()
        ' write your code here
        Dim led As New OutputPort(Pins.GPIO_PIN_20, False)
        Dim led0 As New OutputPort(Pins.GPIO_PIN_19, False)
        Dim led1 As New OutputPort(Pins.GPIO_PIN_18, False)
        Dim led2 As New OutputPort(Pins.GPIO_PIN_17, False)
        Dim led3 As New OutputPort(Pins.GPIO_PIN_16, False)
        Dim led4 As New OutputPort(Pins.GPIO_PIN_15, False)
        Dim led5 As New OutputPort(Pins.GPIO_PIN_14, False)
        Dim led6 As New OutputPort(Pins.GPIO_PIN_13, False)
        Do
            led3.Write(True)
            led4.Write(True)
            led5.Write(True)
            led6.Write(True)
            Thread.Sleep(500)
            led3.Write(False)
            led4.Write(False)
            led5.Write(False)
            led6.Write(False)
            led.Write(True)
            led3.Write(True)
            Thread.Sleep(250)
            led.Write(False)
            led3.Write(False)
            Thread.Sleep(250)
            led0.Write(True)
            led4.Write(True)
            Thread.Sleep(250)
            led0.Write(False)
            led4.Write(False)
            Thread.Sleep(250)
            led1.Write(True)
            led5.Write(True)
            Thread.Sleep(250)
            led1.Write(False)
            led5.Write(False)
            Thread.Sleep(250)
            led2.Write(True)
            led6.Write(True)
            Thread.Sleep(250)
            led2.Write(False)
            led6.Write(False)
            Thread.Sleep(175)
            led3.Write(True)
            led4.Write(True)
            led5.Write(True)
            led6.Write(True)
            Thread.Sleep(500)
            led3.Write(False)
            led4.Write(False)
            led5.Write(False)
            led6.Write(False)
            Thread.Sleep(500)
        Loop
    End Sub

End Module

It turns out that it built correctly. (Which wasn't a surprise as it worked properly the first time.)

However it remembered the last used serial port (COM4) from when it was first tested. I needed to cycle through the available ones and then set the serial port back to COM1 to enable it to load properly. And when I loaded the program into the IDE, I checked the properties box and noticed that it didn't select the serial port, instead it showed the emulator. When it started running, I noticed that the sleeper settings need to be updated.... So that's the first draft of the code and the finished version will be up on the GitHub account soon.

-----

Chris what's the blue box that's bigger on the inside then outside, doing outside your offices?

Attached Files



Doctor Who
"This signature does not exist!"

#2 Dr Who

Dr Who

    Advanced Member

  • Members
  • PipPipPip
  • 261 posts
  • LocationNYC

Posted 04 August 2015 - 06:43 AM

Hello!

After completely rewriting the code box which directs the GPIO connections on the Mini to communicate appropriately with the connected parts, I've now gotten it to the point where it works exactly the same as when I checked on how they would work using 8 position DIP switches. And this is the code I am using now:

Imports Microsoft.SPOT
Imports Microsoft.SPOT.Hardware
Imports SecretLabs.NETMF.Hardware
Imports SecretLabs.NETMF.Hardware.NetduinoMini

Module Module1

    Sub Main()
        ' write your code here
        Dim led As New OutputPort(Pins.GPIO_PIN_20, False) 'U1 SN74278 D1
        Dim led0 As New OutputPort(Pins.GPIO_PIN_19, False) 'U1 SN74278 D2
        Dim led1 As New OutputPort(Pins.GPIO_PIN_18, False) 'U1 SN74278 D3
        Dim led2 As New OutputPort(Pins.GPIO_PIN_17, False) 'U1 SN74278 D4
        Dim led3 As New OutputPort(Pins.GPIO_PIN_16, False) 'U2 SN74278 D1
        Dim led4 As New OutputPort(Pins.GPIO_PIN_15, False) 'U2 SN74278 D2
        Dim led5 As New OutputPort(Pins.GPIO_PIN_14, False) 'U2 SN74278 D3
        Dim led6 As New OutputPort(Pins.GPIO_PIN_13, False) 'U2 SN74278 D4
        Do
            Thread.Sleep(750)
            led.Write(True)
            led0.Write(True)
            led1.Write(True)
            led2.Write(True)
            led3.Write(True)
            led4.Write(True)
            led5.Write(True)
            led6.Write(True)
            Thread.Sleep(750)
            led.Write(False)
            led0.Write(True)
            led1.Write(False)
            led2.Write(False)
            led3.Write(False)
            led4.Write(False)
            led5.Write(False)
            led6.Write(False)
            Thread.Sleep(750)
            led.Write(False)
            led0.Write(False)
            led1.Write(True)
            led2.Write(False)
            led3.Write(False)
            led4.Write(False)
            led5.Write(False)
            led6.Write(False)
            Thread.Sleep(750)
            led.Write(False)
            led0.Write(False)
            led1.Write(False)
            led2.Write(False)
            led3.Write(True)
            led4.Write(False)
            led5.Write(False)
            led6.Write(False)
            Thread.Sleep(750)
            led.Write(False)
            led0.Write(False)
            led1.Write(False)
            led2.Write(False)
            led3.Write(False)
            led4.Write(True)
            led5.Write(False)
            led6.Write(False)
            Thread.Sleep(750)
            led.Write(False)
            led0.Write(False)
            led1.Write(False)
            led2.Write(False)
            led3.Write(False)
            led4.Write(False)
            led5.Write(True)
            led6.Write(False)
            Thread.Sleep(750)
            led.Write(False)
            led0.Write(False)
            led1.Write(False)
            led2.Write(False)
            led3.Write(False)
            led4.Write(False)
            led5.Write(False)
            led6.Write(True)

        Loop
    End Sub

End Module

As the reader can see from the attached datasheets the parts labeled U1 and U2 in the code portion who describes the SN74278:

        Dim led As New OutputPort(Pins.GPIO_PIN_20, False) 'U1 SN74278 D1
        Dim led0 As New OutputPort(Pins.GPIO_PIN_19, False) 'U1 SN74278 D2
        Dim led1 As New OutputPort(Pins.GPIO_PIN_18, False) 'U1 SN74278 D3
        Dim led2 As New OutputPort(Pins.GPIO_PIN_17, False) 'U1 SN74278 D4
        Dim led3 As New OutputPort(Pins.GPIO_PIN_16, False) 'U2 SN74278 D1
        Dim led4 As New OutputPort(Pins.GPIO_PIN_15, False) 'U2 SN74278 D2
        Dim led5 As New OutputPort(Pins.GPIO_PIN_14, False) 'U2 SN74278 D3
        Dim led6 As New OutputPort(Pins.GPIO_PIN_13, False) 'U2 SN74278 D4

They match the layout of the parts, The next box would match the truth table for the part. I am going to leave that one as an exercise to the reader.



Doctor Who
"This signature does not exist!"

#3 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 04 August 2015 - 11:55 PM

Hi Dr. Who,

Regarding remembering the last used serial port--you're referring to Visual Studio, correct? The NETMF SDK plug-in for will remember the last-used deployment port unless it is manually changed.

[Unfortunately if you're using USB devices or virtual COM ports, it can also appear to have changed the port because it can't show your previously-selected port. I know...confusing. If it ever gives you trouble, just change the port selection quickly and then change it to the port you want to use.]

On the larger post: what are you building? :) I assume it's not a Dalek.

Chris

#4 Dr Who

Dr Who

    Advanced Member

  • Members
  • PipPipPip
  • 261 posts
  • LocationNYC

Posted 05 August 2015 - 02:18 AM

Hi Dr. Who,

Regarding remembering the last used serial port--you're referring to Visual Studio, correct? The NETMF SDK plug-in for will remember the last-used deployment port unless it is manually changed.

[Unfortunately if you're using USB devices or virtual COM ports, it can also appear to have changed the port because it can't show your previously-selected port. I know...confusing. If it ever gives you trouble, just change the port selection quickly and then change it to the port you want to use.]

On the larger post: what are you building? :) I assume it's not a Dalek.

Chris

And that's what I thought.

Indeed. Right now just exploring an idea I had for the part numbers.

 

Then that does explain why there's a blue box outside your place that's bigger on the inside then on the outside.

 

And were you the one who downloaded those two datasheets?



Doctor Who
"This signature does not exist!"




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.