NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Microcontroller Programming » Simple Communication with your computer

April 10, 2009
by FWSquatch
FWSquatch's Avatar

I've ordered some LED's to try out the LED Marquee but while I'm waiting, I was getting kind of antsy and I wanted to just throw together a little mini-marquee with the included LCD. All I'm really looking for is some simple C code that will check my computer for messages every few seconds. I think I can figure out how to display it no problem, but I have been poring over the Marquee code and I must say I'm a bit confused as to where the code is that is pulling the info from my computer. I've seen the code that writes to the serial but I haven't seen any that reads from it. I was wondering if someone could give me a push in the right direction?

April 10, 2009
by kwiegand
kwiegand's Avatar

Try looking at the sample code from the usb servo-guided water squirter tutorial. The code from that project will show you how to get the micro controller to read characters sent to the serial port from your computer.

April 10, 2009
by kwiegand
kwiegand's Avatar

-Kerry

April 10, 2009
by Soybean
Soybean's Avatar

There's some in the LED Marquee tutorial, too. In the ledarray.c file, the serial port is set up for read/write access in main(), and then actual reading occurs (one character at a time) in do_scrolling_display() and do_simple_display().

April 10, 2009
by FWSquatch
FWSquatch's Avatar

Thanks guys! I don't have a servo so I didn't even look at that Tutorial. I'm gonna do that now.

April 11, 2009
by mcai8sh4
mcai8sh4's Avatar

Don't know if this helps, but I've played around with the marquee (it's fun), and the c code on the chip waits for the info from the computer as mentioned above. From your computer you run the python-listener.py program then you can netcat messages across.

With the excellent help from the Nerkits staff, and the other users of this forum, I've now got some other python scripts that makes it easier (for me anyway) to pass text to the chip (then onto the display), using these programs I can write a quick bash script to display stuff that needs displaying (I'm using Linux btw). Have a quick look at the other thread in this subforum, it may be of some help.

April 25, 2009
by digiassn
digiassn's Avatar

Probably the easiest way is to use the librarys included with the Nerdkit and use their UART reading to read in from a serial port. You can use the programmer for this, but for a dedicated circuit, you can use a MAX232 (http://www.mouser.com/Search/ProductDetail.aspx?qs=5BZzbFV4k2vm92DEZa5XUA%3d%3d) so you don't have to worry about inverting the logic. Just decide on a message terminator of some sort, or a simple data structure, and send that from a sender on the PC, and have the micro either poll the input, or use a Clear to Send pin or something. I believe their are examples in about all the example code (I used the Temp sensor) on how to work with the UART.

May 05, 2009
by n3ueaEMTP
n3ueaEMTP's Avatar

Here is my most recent problem. I have the tempsensor project loaded now. When I use PuTTY, the giberish below is what the MCU is sending to the serial port. I thought maybe it was something that I did when writing the program from the tutorial so I loaded the pre-written code to be sure. The MCU is working fine confirmed by the temperature in my office being accurately displayed on the LCD. Any ideas?

Here is what I'm getting as output (it's not one continuous line, there are many line breaks & tabs): þ!ùÔþ!û±þ!ù!ö±þHüHþ!ù¦üHúHþ!ù!öþJú!ö!û¡þJþJüHþ!ù±þ!ù¡þLúHüHþ!öJþ!ûÔþ!ù±þ!ö!öHü!ö!ùÔþ!ö!ù!ö±þ!û±þHúHü!ö!öJú!ù³þJþ!öLúJþ!ûþ!ùþ!ý±þJþ!ö!û±þJúJü!ö!ù³þ!û±þ!ù þJú!ùÔþJú!ö!ý±þ!ö!û¡þ!ùÔþHþJüLú!ù þJþ!ù þHú!ö!ö!ù±þ!û!ý±þ!û!ö³þJþ!öJþ!ö!ù±þJþ!û¤ü!ù±þ!ö!ö!ù!öÔþ!ù±þ!ùÔþ!ù þLü!ù þ!û!ö ÿ¥üHþ!ù ÿ±þ!û þJþ!ù þ!öHú!ûÔ

Some specs:

Computer: Windows vista

4GB RAM

Intel Core Duo 2.00Ghz

MCU: operating on homebrew power supply

all other items as per Nerd Kit instructions

Thanks

Chris B.

May 05, 2009
by Kevin
Kevin's Avatar

Hi n3ueaEMTP,

I had the same problem. I am using Hyper Terminal. Is Hyper Terminal still included with Vista?

I changed my HT settings to 115200 8-N-1 and now I am capturing temps.

Good luck!

May 05, 2009
by n3ueaEMTP
n3ueaEMTP's Avatar

Kevin, Hyper Terminal is not included in vista. I will make the changes & see what happens. Thanks for the help!!

Chris B.

May 06, 2009
by wayward
wayward's Avatar

þLúHüHþ!öJþ!ûÔþ!ù±þ!ö!öHü!ö!ùÔþ!

Reminds me of the good old days with serial modems. :) Yeah, that does look like the sort of thing one would get when UARTs are misconfigured. 115200 bps, 8-N-1 framing is used in the NerdKits UART library (uart.c: uart_init() ), just as Kevin said.

Good luck!

May 06, 2009
by n3ueaEMTP
n3ueaEMTP's Avatar

After I changed the settings, everything started to work well. My only problem now is to integrate parts of the servo control project into my current project without loosing its functionality (last night I could control parts of my MCU but it would not operate from the external trigger). My goal is to manually trigger my MCU via computer AND via automatic trigger. We'll see how it goes!

Thanks guys & gals

Chris B.

Post a Reply

Please log in to post a reply.

Did you know that you can aim and fire a servo-controlled water gun from your computer? Learn more...