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 » LED Marquee acting weird

April 21, 2009
by FWSquatch
FWSquatch's Avatar

OK, so I'm not sure exactly where this question should go, but I built the LED Marquee and powered it up and found a few joints I had to solder again. No biggie. Got that done and fired it up and it looks like this:

http://www.youtube.com/watch?v=yTkArsU0j1s

Basically, the letters are all messed up and when it runs through the test of each LED, half of the columns begin to fade after they light up. I'm not sure if the problem is in my workmanship (first time I ever soldered) or if it is wired or programmed wrong. I didn't change anything about the code before I flashed the chip and I even reflashed it again later to no avail. I tried changing some wires but that just rearranged the columns and rows. Anybody got any ideas?

April 22, 2009
by mcai8sh4
mcai8sh4's Avatar

FWSquatch - I've made the LED marquee and on my first run I had similar problems. For me it wasn't the wiring on the board, but more the wiring on the breadboard. I think basically I disconnected the display, and re-wired it to the breadboard very carefully. One thing to mention - due to me rushing first time through, I connected some up completely wrong. I used cat5 cable one length for the rows and two lengths for the columns (6 wires in each length)

Rows (top to bottom) connects to pin numbers 15 to 19 (PC1-5)

First half of the columns (starting left to right when looking at the front of the display) connects to pin numbers 23 to 26 (PC0-5)

Second half of the columns (again left to right) connects to pin numbers 4, 5, 6, 11, 12, 13 (PD2-7)

I suppose your best bet might be to trace each wire through to make sure none are getting mixed up. If it still doesn't work, then it may be the soldering.

Let us know how you get on. (I used amber LEDS - your green ones look much better)

April 29, 2009
by FWSquatch
FWSquatch's Avatar

I figured it out...kinda. I went back through all the wiring on the breadboard and found that I had taken off the wires running from pins 20-22 to 5V and ground and forgotten to replace them. I did that and got all the columns staying lit. I was still getting funky lettering though. Turns out, I had wired the column wires backwards. I just reversed their order and everything worked fine.

Now I am trying to get the python listener going. I can get the listener running and I can netcat a string over to it, but for some reason when it comes time to write the text, the LED goes blank and everything seems to hang. This is what it looks like on my terminal:

josh@Washburn:~/nerdkits/Code/ledarray2$ python python-listener.py &
[1] 23476
josh@Washburn:~/nerdkits/Code/ledarray2$ echo "HI MOM" | netcat localhost 6666
Connected by ('127.0.0.1', 41895)

Can anybody tell what I'm doing wrong?

October 25, 2009
by FWSquatch
FWSquatch's Avatar

OK, so I'm back. I moved...life got in the way...etc etc. Anyway, I dug out my nerdkit and half finished LED Marquee and started playing with it again. I rewired everything, reflashed the chip and have been able to get the Marquee up and running again. Unfortunately, I'm stuck at the same place. I get it to fire up and run the test pattern with Hello printing across the LEDs but when I try to send it text through the python-listener.py using netcat, I get nothing. The LED finishes its test pattern and then goes dark. I can't get it to come back on without disconnecting and reconnecting the power.

I am using Python 2.6.2 on Ubuntu Jaunty. Any ideas?

October 25, 2009
by Farmerjoecoledge
Farmerjoecoledge's Avatar

When it goes dark is when it's connected but the data's not getting there. When that happens to me i run another .py script behind it so to speak, i called my .py script theboot.py like boot it in the ass.py. That's what works for me, the .py can be anyone of the other scripts for the array. I assume you opened another terminal and did the nc localhost 6667 thing, so open "another" terminal and run just another python script and leave nc open.

October 26, 2009
by FWSquatch
FWSquatch's Avatar

Thanks Joe! I'll try that out tonight.

October 26, 2009
by FWSquatch
FWSquatch's Avatar

Well, I tried all kinds of things tonight and didn't have a lot of luck. I was able to use the simple python script from an earlier thread and it worked fine, but trying to use the pythonlistener.py script was a total no-go. I opened a few other terminals in the background to try and jumpstart it to no avail. I've been trying to debug for a while but I'm not seeing exactly where it is hanging. The code that DID work was from Soybean and looked like this:

<code>

 import serial

 serial = serial.Serial("/dev/ttyUSB0", 115200)
 mystring = "TEST STRING\n"

 serial.write('b')
 for data in mystring:
      if not data == '\n':
           serial.write(data)
           response = serial.read()
           if not response == 'n':
                print "Received: " + response
                #This is a debug line, since I'm a bit fuzzy on some details
                break
 serial.write('a')

</code>

I think I'm going to try using that as a starting point and try to build back to the functionality of the pythonlistener.py script. This could be a good opportunity to learn more python.

October 26, 2009
by Farmerjoecoledge
Farmerjoecoledge's Avatar

I hate to do this but i have to ask you a question instead of answering. When you say python-listener.py is a no go, do u mean it won't start? Is there some kind of error? So to explain further, i haven't had your issue with just getting the listener running, opening another terminal and entering nc localhost 6667 and then entering some capital text.That always works. My hanging happens when i'd send a feed to the array via a pipe. So that's when it would hang and then i'd send the theboot.py(which looks like the same code) and then the feed would start. So if the listener will not start period then there should be a port error connection refused, if that's the case a reboot normally fixes that.If not i got another trick for that. For more info on the "pipe" read this post from wayward on. http://www.nerdkits.com/forum/thread/184/

October 26, 2009
by Farmerjoecoledge
Farmerjoecoledge's Avatar

And this one, at the end. http://www.nerdkits.com/forum/thread/203/

October 27, 2009
by FWSquatch
FWSquatch's Avatar

OK, so now I am having some limited success. Progress! I start up the LED, then I run python-listener.py. It seems to be running. I open another terminal and do nc localhost 6667 No luck. I Ctrl-C to break out of the listener program and then fire it right back up. This time when I do nc localhost 6667, I get the time to show up! Then it seems to be working. It will scroll text and then go back to the time. After a while with me putting in messages (like a few lines), it will go blank. Sometimes it will mess up in the middle of the message and put in some weird characters followed by a ?. For example, SHE SELLS SEASHELLS will end up like SHE SELLS SE'''''''?. After one of those, the sign will go blank, but every minute, it will scroll across three question marks. If I kill the python-listener script and then restart it, it goes back to doing the same old thing.

October 27, 2009
by FWSquatch
FWSquatch's Avatar

I uploaded a video of it doing the weird character thing.

LED Video on Youtube

October 27, 2009
by Farmerjoecoledge
Farmerjoecoledge's Avatar

That's a good one! I've had a similar thing happen, i'd be trying to start the array sometimes it would need to be boosted by unplugging it and plugging it again from the wall. Sometimes it would start to scroll stuff like a pile of ? in a row. I never did quite figure out what exactly was going on. Just recently i was looking through the library and took a look at uart.h and found a bunch of ? like what was scrolling across my display. So i'm thinkin now that that had to have been what it was. It's some sort of a glitch it runs the uart.h instead of ledarray2.c. I just remembered some of my text was upside down once, until i reflashed it. That was totally cool. Like how was it doing that. I almost hated to change it. I got some video maybe i should post it. Anyway try a reflash, maybe load the initialload again first. So it's good to hear you got some of it, remember none of this stuff works the 10th time, 20th maybe.

October 28, 2009
by hevans
(NerdKits Staff)

hevans's Avatar

Hi FWSquatch,

In the latest version of your code, are you using our python-listener.py, or a different version? It seems like the problem you have might be caused by the computer sending the bytes too fast down the serial port. This would happen because your python-listener.py isn't waiting for the 'n' reply from the MCU before sending the next character. If you are using our version of python-listener.py, try increasing the calls time.sleep() from .5 to 1, that might alleviate that problem a bit.

Most importantly though, don't be discouraged. All of these projects take tweaking to get it right, and the best thing you can do to learn is get experience debugging weird issues.

Humberto

October 28, 2009
by FWSquatch
FWSquatch's Avatar

Thanks for helping me, Joe and Humberto. I've narrowed it down. The problem has to do with the time part of te script. In the youtube video, when you see it go from letters to the '''''? that just so happens to be when the time changes. As long as the time stays the same, it works great, but when the minute changes, it goes haywire. I think I'm going to have to take the clock completely out of the loop and see how it goes. Of course, that'll have to wait until tomorrow because I'm getting dirty looks from the old lady! :)

October 30, 2009
by Farmerjoecoledge
Farmerjoecoledge's Avatar

I'm from Canada but i'm not from another planet. Like what are you guy's talkin about? "a different python-listener.py" and "changing the calls time.sleep() from .5 to 1". And you with the, "when the minute changes it goes haywire" and "take the clock completely out of the loop". Help me out here, are you using another version of the listener? and what's this haywire thing? and what loopin clock? There's nothing wrong with the supplied listener. Why are you messin with it? And while i'm at it,the "n" the cpu sends must be invisable because i've never seen one come back to the terminal. I always thought i was a little "alien", now i'm sure.

October 30, 2009
by FWSquatch
FWSquatch's Avatar

The haywire I'm referring to is the funny characters followed by a ? that happens in the middle of a message like in the youtube video I posted a couple of days ago. The version of pythonlistener.py that I am using is the one downloaded from the nerdkits website. I have used another script with the sign, but not a listener type script. It was a simple "run the script, it prints a message". It is the code I posted a few days ago in this thread that I took from another nerdkits forum thread. By "take the clock out of the loop" I mean that I plan on reworking the code so that the sign does not display a clock when it is not displaying messages. I might be able to find some time this weekend to do some tinkering if I'm not tricked.....or treated.

October 30, 2009
by Farmerjoecoledge
Farmerjoecoledge's Avatar

I think i'm going to stay on this side of the planet from now on. With my python"-"listener.py that came on the cd with the kit.( They don't post the listener on the web page i get). That works just the way it is, and i'm leaving the time on, which means it's still ready and go, and then get myself "treated", at least i know what you mean by that. Take care.

farmerjoe

October 30, 2009
by FWSquatch
FWSquatch's Avatar

I can't find my CD so I am using the code pulled from here:

http://www.nerdkits.com/videos/ledarray2/ledarray2.zip

I really don't know if it is the same or not. The python file is called python-listener.py. I'll keep messing with it and let you know how it goes.

November 01, 2009
by FWSquatch
FWSquatch's Avatar

OK, so I've figured out most of my problems. I wrote a short script based on the one by Soybean. Right now, it just checks a text file and prints that message three times. It runs great unless the clock on my computer flips to the next minute during a message. That's when I get that ''''''? like what you see on this video: youtube video

The code running on the chip is the code from the link in the post above, running with no changes to it. Here is my python code. I added some debug lines trying to trace the problem.

import serial
import time

serial = serial.Serial("/dev/ttyUSB0", 115200, timeout=None)
text_file = open('../GVoiceServices/led_message.txt', 'r')
message=text_file.read()
text_file.close() 
#print message
mystring = str(message) + "     \n"
#print mystring
serial.write('z')
serial.write('b')

for i in range(1, 4):
    for data in mystring:
         if not data == '\n':
              serial.write(data)
              print "Sent " + data + " at " + time.strftime("%H:%M")
          response = serial.read()
              print "Received  " + response
          if not response == 'n':
                   print "Received: " + response
                   #This is a debug line, since I'm a bit fuzzy on some details
                   break
else:
    serial.write('a')

Here is an example of the terminal output when it runs (Text file reads: TEST MESSAGE 2):

 Sent T at 12:22
 Received  n
 Sent E at 12:22
 Received  n
 Sent S at 12:22
 Received  n
 Sent T at 12:23
 Received  n
 Sent   at 12:23
 Received  n
 Sent M at 12:23

So, it seems to be sending ok until the time changes. Then after the time changes it sends 2 letters just fine and then on the third one, it sends the letter but does not receive a response from the chip. This is the behavior no matter what point of the message it is on (letter, number, or space). At this point I have to Ctrl-C to stop the script because it is stuck. I hope this is enough information for someone to help.

November 01, 2009
by FWSquatch
FWSquatch's Avatar

Woohoo! I finally figured it out and boy do I feel dumb! The problem was with my crontab. I also have an Arduino and I was playing with it and created a little gmail checker flag. Here's what it looks like if you're interested:

Gmail Checker Flag Video

While messing with that, I created a cronjob that ran it every minute. Afterward, I forgot all about it. So, every minute, my laptop would try to see if the Arduino was connected and that was throwing the LED array out of whack. I commented out that cron job and now everything works flawlessly! I think I'm finally ready to stop posting in this thread! :)

November 01, 2009
by Farmerjoecoledge
Farmerjoecoledge's Avatar

Just in case any Canadians were wondering if we get a different web page, i was mistaken, the listener code is at the link above and not on the cd.:|

And I just added a new word to my vocabulary,"cronjob" good goin.

farmerjoecoledge

November 02, 2009
by mcai8sh4
mcai8sh4's Avatar

FWSquatch - congrats on getting things working. Also, I'm loving the 'You've got mail' flag, that's really made me smile :D

-Steve

November 02, 2009
by hevans
(NerdKits Staff)

hevans's Avatar

Glad you got it working. I guess the lesson to be learned here is that the problem is always in the last place you look.

Humberto

Post a Reply

Please log in to post a reply.

Did you know that you can generate hundreds of volts AC from your microcontroller with a little bit of circuitry? Learn more...