Monday, December 10, 2012

Netduino Serial Demo Sample

Last month we ran out of time in our meeting before I could finish up my serial data demo.  At that time I promised to get some sample code out there…all I can say is I’ve been very busy and better late than never.

The demo program I created which was called SerialIODemo is a very simple mechanism to send commands and arguments from the desktop down to the Netduino via a via a FTDI USB Serial port.

Connecting the two is very simple, just run wires as follows

BLACK  FTDI->GND to Netduino GND
GREEN FTDI->TXD to Netduino 0 (On the Digital I/O bank)
YELLOW  FTDI->RXD to Neduino 1 (On the Digital I/O bank)

Then of course you’ll need to connect both of these to your computer via USB.  The following picture should give you a good idea of how this should look.  Note the green wire is in the pin closes to end of the connector.

image

Fully Connected

image

Connection to FTDI

image

image

Connections on Netduino

After you have made your connections and plugged in the USB connections to your computer, you’ll need to check the Serial Port the FTDI is connected to. this can be done via the Device Manager under ports.  In my case, I’m on COM1

image

You’ll need to modify the code to connect to this port (TODO: Could have this configurable through the UI).  This needs to be done in MainWindows.xaml.cs in the DesktopApp project

image

Once you’ve done this you should be ready to go!

To use the app, simply make sure both programs start.  This can easily be done by right mouse clicking on the solution node SerialIODemo and setting both projects to startup.

image

Now start your program, give the Netduino a few seconds to warm up and press Connect.  When you do so, the Netduino should respond back as in the screen below.  If you don’t see this give the Netduino a little longer to start.

image

Extending the App

The idea behind this application is to invoke different commands by sending a string from the computer to the device.  The string will be in the format “command=arg”.  A switch statement in the device code will handle different commands and the args can be used to make those commands work with different “stuff” on the device.

image

image

image

Hope this gets you started on controlling your Netduino with your computer!

-twb

No comments:

Post a Comment