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 » Help with the LED Marquee

April 26, 2009
by BolanosAV
BolanosAV's Avatar

Hi I am completely new to this so please keep that in mind when you respond to this but I just got my nerdkit not long ago and Ive done the projects that came with it to better understand how it works but while i understand how it works physically i have a hard time understanding how it works on the programing side.

I wrote an email to nerdkit support to see if i could get help and i received an email explaining the make files. I have a much better understanding of the make files now but i am still extremely confused as to what Python is... and how i am supposed to use it to make the LED marquee...

The led marquee does not seem like the other nerdkit projects when it comes to the programing and uploading. mainly because of the .py and .h file

I have the LED Marquee made its just not programed. thats where I am stuck. I downloaded Python 2.6 but i dont know what im supposed to do with it. And before i knew I had to download python i edited the make file cause i thought thats what i was supposed to do. here is what i made.

keep in mind that i am new to microcontrollers outside of the nerdkit

GCCFLAGS=-g -Os -Wall -mmcu=atmega168 LINKFLAGS=-Wl,-u,vfprintf -lprintf_flt -Wl,-u,vfscanf -lscanf_flt -lm AVRDUDEFLAGS=-c avr109 -p m168 -b 115200 -P COM3 LINKOBJECTS=../libnerdkits/delay.o ../libnerdkits/lcd.o ../libnerdkits/uart.o

all: ledarray2-upload

ledarray2.hex: ledarray2.c make -C ../libnerdkits avr-gcc ${GCCFLAGS} ${LINKFLAGS} -o ledarray2.o ledarray2.c ${LINKOBJECTS} avr-objcopy -j .text -O ihex ledarray2.o ledarray2.hex

font.h: font.txt python fontmaker.py > font.h

ledarray2-upload: ledarray2.hex avrdude ${AVRDUDEFLAGS} -U flash:w:ledarray2.hex:a

I am a fast learner but i need info to learn from... even screen shots of ur work would help me so i can actually see what its supposed to look like and from that i can figure out the correct way to do it...

I am lost... I am not dumb though so dont feel like u dont know where to start explaining... just explain and if i have questions about your explanation i will ask.

April 26, 2009
by mcai8sh4
mcai8sh4's Avatar

I'll try to help! For starters I'm using Linux, I assume your in windows, but there shouldn't be any major differences.

To program the chip, I simple ran the make file as you would with any of the other examples. The python file that makes the fonts, has already been done, I think it's there so you can play with it (I notice one of the parenthesis' is wrong, but never mind that). So you can ignore that for the time being.

Once you've used the make file, turn the circuit on - all the leds should light up in order, then go out and the word 'HELLO' should be displayed. If this works then the circuit and the display are ok.

Now I'll have a go at explaining the python programs. I'm not the right person for this as I'm quite (read 'very') new to python. Anything I get wrong, I'm sure someone will correct me... but here goes

Pyhton is just another programming language (or scripting language). The only program you need to worry about (and not really worry) is python-listener.py

This simply listens on a socket and when it receives data then sends it to the nerdkit. To use this, run the program (in the background) then send data to the port it's listening on (6667 i think), your data will then be displayed on the LED display. Remember to only send capital letters else the display will just show '?'.

I have written two (soon to be one - when I get round to it) programs in python that let you send words to the display a little easier (for me at least)... I must also add I didn't really write them on my own, I've never wrote a python script before, but thanks to the help of some members of this forum, I've managed to understand and alter them to do what I wanted.

If you get up and running, and you want to try these programs, let me know, I'll post them.

Hope this helps, if you need more info let me know. I can't promise I'll be able to help, I'm new to all this too, but I'll try.

Best of luck.

April 26, 2009
by BolanosAV
BolanosAV's Avatar

oh thank u for clarifying that i dont even use the py file myself...

so i just run the makefile that came with the ledarray2 folder? i dont edit it?

font.h: font.txt :python fontmaker.py > font.h that is what is inside the original make file.

I greatly appreciate your help. and yes i am running on windows. i am going to try out what u said.

April 26, 2009
by mcai8sh4
mcai8sh4's Avatar

I certainly didn't alter the make file. Since getting everything working I've played with the font python file to correct the parenthesis (although can't remember if I got it working or not).

I'm not sure how python works in windows, prob very similar to linux, but I have no experience in it.

Hope you get it working.

April 26, 2009
by hevans
(NerdKits Staff)

hevans's Avatar

Hi BolanosAV,

You should not need to modify the Makefile, however you will need to run 'make font.h' first if you modify the font.txt file. The font.h target uses python to build the font.h file from font.txt. After that, running 'make' should compile and upload the code. Hope it works!

Humberto

April 27, 2009
by BolanosAV
BolanosAV's Avatar

ok i tried to just run make to compile the code but it says

no targets specified and no makefile found

Originaly i edited the file makefile cause the one that comes in the Zip file says Makefile.FONT and i removed the ".font"

[IMG]http://img.photobucket.com/albums/v336/IntegraAV/ledarray.jpg[/IMG]

After removing the ".FONT" i ran make and now it says

makefile:2:*** missing seperator (did you mean tab instead of 8 spaces?). Stop

I thank you all greatly for your time... I promise I wont have to be taught twice.

April 27, 2009
by hevans
(NerdKits Staff)

hevans's Avatar

Hi BoanosAV,

The Makefile.FONT that is distributed in the zip file on the website is not a full makefile. This is because that code is available to everybody, and there is no guarantee that those people have the same setup as we do in the NerdKit. It looks like the Makefile you posted earlier in your first post was just right. Try that one, and see what you get.

Humberto

April 29, 2009
by BolanosAV
BolanosAV's Avatar

Ok i got it to work... though it drained the 9V battery super fast... is there a part i can buy that allows me to plug the microcontroller into a 110v wall outlet?

I am not sure why the makefile i made wasnt working... i still dont know why... for some reason when i edit it the spacing changes and i guess it meses up the way the computer recognizes it and it wont work.... but no matter what when i edited the file the line spacing would change.. so instead of changing the make file... i changed the name of the ledarray2 files to tempsensor from the nerdkit makefile... and this did work... and confirmed what i thought that the spacing is affecting the make file i edited..

but im happy to say that all of the lights turn on and turn off row by row then it displays H E L L O then turns off completely..

im glad this worked though... i thought i was missing something when in reality it was a simple spacing problem in the makefile text

April 29, 2009
by mcai8sh4
mcai8sh4's Avatar

Glad to hear you've got it up and running! I've found that if you have it connected to the computer then the lights coming on and off then hello is displayed then it repeats. It only stops once I send some text too it.

I had an idea whilst driving home from work today... make a smaller one (to free up some pins) then make OBD car controller, reverse the fonts, then place on the dash board - there you have it - a HUD for your car. Probably not advised for safety reasons, but I can't see why it wont work.

Depending how python works in windows (can you pipe text to it?) then if you want I can give you the other files I use to send date across. If you cant pipe stuff across then I'm sure a friendly python person will help you edit them to work one way or another.

April 29, 2009
by hevans
(NerdKits Staff)

hevans's Avatar

BolanosAV,

What program are you using to edit your Makefile? Windows editors (particularly Notepad) tend to do nasty things to line breaks. If that is the case I suggest you use WordPad or Programmers Notepad to edit your files.

Humberto

April 29, 2009
by BolanosAV
BolanosAV's Avatar

oh interesting i didnt know u could use wordpad... i have used programers notepad before but for some reason i decided against it and wanted to use the most basic program which was notepad...

but now i know not to use notepad. thanks a lot.

mcai8sh4 i agree thats a good idea. My car is actually OBD1 so i would need to convert to OBD2 or figure out a way to track the OBD1 sensors really well.

Is there a connection i can buy for my nerdkit that allows me to power it through a wall outlet?

Thank for your help everyone

April 30, 2009
by BolanosAV
BolanosAV's Avatar

there's so much info in the nerdkit that its easy to forget things u learned at the beginning.. I remembered that the voltage regulator controlled the voltage down to 5v... but i thought it was for 9v to 5v.. but after re reading it says that "ANY" voltage above 5volts and coverts it to a steady 5volts.

Does this mean i could just find an old appliance,cut the power cord off and wire it to the nerd kit and connect that to a wall outlet? would 110Vs be too much would that Voltage regulator overheat and fail or melt?

I am planning on finding an old adapter which reduces the voltage down to 12volts and hooking that up... but i ask the question about 110Volts out of curiosity.

April 30, 2009
by mcai8sh4
mcai8sh4's Avatar

I don't know enough about these things to really help answer your question, but do NOT connect it to the mains electricity. I think I read somewhere that the regulator will accept up to 30 volts (not certain, but something like that rings a bell).

Voltage is one thing to consider, but also current is important.

Until someone who has more knowledge can answer your question correctly, please stick with a battery for the minute. There is information in the downloads section see the info on 7805 (the component). Also read appendix A in your nerdkits guide (page 65 in mine) which talks about using other power sources.

I don't want anyone to get hurt, so I must reiterate - do not plug it in to anything connected to the wall outlet unless you know what your doing. You may fry your circuit, but more importantly, you may fry yourself.

I think the datasheet and the nerdkit guide should answer your questions.

April 30, 2009
by n3ueaEMTP
n3ueaEMTP's Avatar

BolanosAV, connecting your voltage regulator to 110V will not work and is VERY DANGEROUS. The 7805 regulates any DC voltage between 8 & 38v. The supply must be at least 3 volts greater than the output voltage and cannot be greater than 38v. If you find an old adapter, make sure it's at least 8VDC. 90% of the adapters that I've come across are are DC. The adapter should have it's output voltage somewhere on it. To differentiate between AC & DC, there is usually a solid line with a dotted line underneath to signify DC. AC will have a " ~ " type of symbol. As always, you should double check the voltage with a multimeter.

May 01, 2009
by BolanosAV
BolanosAV's Avatar

Oh dont worry guys.. I wouldnt try that without asking first.. Like i said my goal is to find an old adapter and use that.

Good looking out though I do appreciate it.

And thank you for the great responses!

I am currently looking around through all my adapters to see if one will be within range

May 10, 2009
by Ethanal
Ethanal's Avatar

Could the python script used in this project be replaced with c code written for the computer if I tweak the MCU's program a bit?

May 12, 2009
by gerald
gerald's Avatar

ok i'm sorry ive tried everything. i can't get the make file to work on the ledarray. i even copyied the guys above and it still won't go. it says i'm missing a separtor. what does that mean.

May 13, 2009
by Kevin
Kevin's Avatar

when I downloaded the ledarray zip file it did not include a MAKE file so I just copied the make file from the traffic light and just did a search and replace of trafficlight with ledarray.

So now I have the ledarray working. It alternates between the led matrix test pattern and "HELLO". How do I get it to display the time like in the tutorial video?

May 14, 2009
by mcai8sh4
mcai8sh4's Avatar

@Kevin - I'm using linux, if you're on Windows then there may be some slight differences, but the idea is the same.

If you run the python-listener.py script the script will then listen on a port (6667? check the code - it's near the top) for data to be sent to it (it then passes the words to the chip). If you send something across (like the example with netcat) then it will be displayed on the marquee. After it's scrolled your text, the time will then be displayed.

I must admit, I did have a little problems on and off but usually stopping the python-listener.py script and restarting it worked.

Hope this helps.

May 14, 2009
by Kevin
Kevin's Avatar

@mcai8sh4 - so are you saying that it will alternate between the test pattern and "HELLO" until I run the Python script and the python script is what displays the time?

I am having trouble installing python on my WIN XP box.....but that is another issue.

Does netcat come from the Python install? Because I am getting 'netcat' is not recognized as an internal or external command, operable program or batch file.

May 14, 2009
by Kevin
Kevin's Avatar

ok, now I have Python installed (ActiveState ActivePython 2.6) - note to self: dont encrypt the desktop then save an MSI to the desktop and try to install from there.

So I run Python and "browse" to the script file python-listener.py and I get -

Traceback (most recent call last): File "C:Python26Libsite-packagespythonwinpywinframeworkscriptutils.py", line 312, in RunScript exec codeObject in main.dict File "C:AVR_PGMCodeledarray2python-listener.py", line 3, in <module> import serial ImportError: No module named serial

anyone, anyone, Bueller..........

May 15, 2009
by mcai8sh4
mcai8sh4's Avatar

Kevin, the python script simply sends your message to the display, if there isn't a message to display the it sends the time.

Regarding the issue you're having with the traceback... I'm certainly no expert (hell, I'm barley even a beginner in python) but I think that error is due to you not having the correct module installed (I guess they're like a library in c). The one you've not got it "serial".

Try : pySerial

Install that and see if that works. Like I say, as far as python is concerned I don't really have a clue everything I try in python gives me errors like that, but I've not really tried to learn it yet - although I will as it does seem very useful.

You could also write a program in some other language (it doesn't have to be python) and then send data to the serial port.

Best of luck, hope you get it working like you want it to!

May 18, 2009
by Kevin
Kevin's Avatar

I dont get it....

I try to run the script and I get this....

C:AVR_PGMCodeledarray2>python python-listener.py Traceback (most recent call last): File "python-listener.py", line 9, in <module> serial = serial.Serial("/dev/ttyUSB0", 115200) File "C:Python26libsite-packagesserialserialutil.py", line 171, in init self.open() File "C:Python26libsite-packagesserialserialwin32.py", line 53, in open raise SerialException("could not open port %s: %s" % (self.portstr, msg)) serial.serialutil.SerialException: could not open port /dev/ttyUSB0: (3, 'Create File', 'The system cannot find the path specified.')

do I have to edit the "/dev/ttyUSB0" part?

May 19, 2009
by Kevin
Kevin's Avatar

ok, I edited "/dev/ttyUSB0" to agree with my COM port and now I dont get an error message but it just sits there with a blinking cursor doing nothing.

Any clues?

May 31, 2009
by luisgarciaalanis
luisgarciaalanis's Avatar

BolanosAV you can not use python and write the PC side of the program in C++, c# or even visual basic if you dare!

just google how to comunicato through serial ports.

Here is one for C# http://www.codeproject.com/KB/cs/serialcommunication.aspx

August 15, 2010
by ironcladmvtm
ironcladmvtm's Avatar

can someone tell me whats wrong with my make file?! the link is to a image of it. everytime i run it i get "Makefile:12: * missing seperator. stop." i have tried the one above and altered it to my machine still getting that error. i am at a loss please help?!

http://img185.imageshack.us/img185/4060/screenshot20100815at115.png

August 15, 2010
by Rick_S
Rick_S's Avatar

I'd like to help, but I'm not a MAC guy. There are several here though and I'm sure one will pop in to help you out...

Rick

August 16, 2010
by Ralphxyz
Ralphxyz's Avatar

ironcladmvtm, show us your make file.

Just copy and paste here and select it and click the Indent Selection as Code Block button to keep the format.

Ralph

August 16, 2010
by hevans
(NerdKits Staff)

hevans's Avatar

Hi ironcladmvtm,

I'm not positive, but I think there is something weird happening with line breaks here. In your screenshot you seem to have an extra line break somewhere near line 12. The line

avr-gcc ${GCCFLAGS} ${LINKFLAGS} -o ledarray2.o ledarray2.c ${LINKOBJECTS}

should be all on the same line. I'm not sure if your editor is just inserting that line break, or something else is.

Humberto

August 16, 2010
by ironcladmvtm
ironcladmvtm's Avatar

Indeed that was one issue. I just got it all figured out and i also didn't have uart.o declared. Thanks for the help.

Post a Reply

Please log in to post a reply.

Did you know that two resistors can be used to make a voltage divider? Learn more...