My Development Process – Part 2

by Jimmie on December 22, 2009

Well, the great news is that the shield works! I’ve got some basic software up and running, but a full library will be coming in the future. You can go ahead and check the beta software out here. I’ll have some of these in a kit form at 26C3, so you can buy one of the prototypes from me there, in either red or green. After I get back I’ll open up pre-orders on my website. Check back here in a few weeks for that. Continue reading if you want to know more about how this all works, and see something of my development process.

LoL shield fitsI’ve got to say that I was sweating it till I got the PCBs in and put one together. I know that I checked the files 100 times or more, but still I worry. That’s how I am though. This turned out to be the first PCB of mine that was 100% correct, it took me far less time, and was far more complex than anything yet. So I guess that means I’m getting better with EagleCad. The day after I had done the layout, I noticed that some of the LEDs were not lined up properly on the PCB. Some LEDs were off 0.005 of an inch. Yes, you read that correctly, but it was significant enough for me. I re-did the whole LED layout on the PCB side, and measured both the x and y alignment. Even though the difference was imperceptible from even a few inches away, I knew about it, so I couldn’t let it go.

Once I was finally comfortable with the PCB design, I ordered 50 PCBs. It was only $20 more than just getting 10, so I figured it was worth it in case the PCBs worked properly. I’ve been using PCBcart recently because their prices are great, and their quality is really good. I didn’t think I would get them in before 26C3, but once I found out that it was scheduled for a 12/26th delivery (the day after I leave), I asked them to rush the order for me. I got them on the 21st around 9am, but then had to wait around for 5 hours before the LEDs came in.

Soldering lolshieldI started soldering the red LED one together, which took about an hour or so. I’ve soldered quite a few LED through hole displays, so this wasn’t too bad. It was around this time that the name came to me, LoL Shield, for Lots of LEDs. My friend Aaron was around, and he seconded the name. Luckily I’m a little familiar using Charliplexed LED displays with an Arduino. So I was able to copy the Open Heart code, replace the LED pin map, and had test software in minutes.

Lolshield is dimWhen I uploaded the software, I pretty much held my breath. As the LEDs lit up in the correct order I started to feel pretty good, and when it finished with 100% accuracy, Aaron and I jumped up and high-fived. Then I further modified the code, and did a super simple alternating column animation. The first run of the animation, the LEDs were so dim you could barely see them. After playing with the runspeed and blinkspeed settings, I was able to get it to a passable level, but I wasn’t happy with it (see left).

The first thing I did was to set the alloff() function to use port manipulation. Previously there was a little for loop that would set every pin to the input state. The reason you have to set them to input, is that if you set it as output LOW, then the pin will actually sink current. That will cause LEDs to light up that drain to those pins if another one is sourcing. The input state has a really high internal resistance, so very little current goes through. With port manipulation, I’m turning them all off in one sweep, saving microseconds. Since I was calling on this every time I needed to turn off an LED, and there are 126 LEDs in a frame, I was wasting tons of time. The brightness increased about two fold (see below). I also wanted to use port manipulation for the LEDs, but that proved to be far more complicated than the 4 calls I use now to light one up. I didn’t see the possible benefit or time savings for that much work.

Lolshield is brightThe next thing was to then use some bitmath to compress the size of each frame. You can get some more info on using bitmath with the Arduino here. I had originally wanted the Open Heart to use bitmath and port manipulation. However, the code was not very readable compared to what I ended up using, and it didn’t really give you much more than additional storage. With the LoL shield though, both are necessary. Otherwise you wouldn’t have more than about 200 frames with the Atmega328, or half that with the Atmega168. Still a lot, but not as much as the 1,600+ you get when using bitmath style compression.

Briefly, bitmath uses the actual bits of a number to store data. I was previously using a byte to simply store a 1 or 0, but that is really wasteful unless you want grey scale. Since each byte is 8 bits, you have the possibility of toggling 8 LEDs on or off with it. I only want on/off for now, so that works just fine. A 2 byte data type would fit all 14 LEDs in it with room to spare, so that leaves a kill bit. However, you can’t really read back what each line is without converting the number to binary again. Readability in the code was a big thing for me with the Open Heart kit. I would love to be able to do that with the LoL shield, but I don’t think it’s worth the 8x loss in storage for this one.

Since I don’t have a programmer written yet, I had to use old reliable, a spreadsheet. You can check out my google docs template here. Basically you set one of the 0′s to a 1, and that adds the appropriate value to the last field. So it could be anything from 0 to 16,383, which you can see clearly in the Arduino code. I then save it as an Open Office document, and copy just the three columns that are tabulated (google docs doesn’t let you copy more than 1,000 cells), along with the special chars I need for the array. Then I paste it into notepad and strip out all of the tabs. Once that is done, I then remove all of the line breaks so that it doesn’t take forever to scroll through.

This will not be the programming method once the library is complete. I want to be able to send simple serial data to the Arduino to scroll text, show pictures, or video. I will also have some kind of frame by frame editor like I have now for the Open Heart. It will either generate the code for you, or maybe I can work it out so that it programs the Arduino for you right there. It will also include grey scale for video and image stuff. Even though there is only 1-2k of RAM, only a few frames would be more than enough for a buffer.

The next update on this probably won’t be till after I get back early next month. I will hopefully be working on this till then, and maybe I’ll have some more done with it. If you have any questions or suggestions, just leave them in the comments.

{ 2 trackbacks }

Arduino LED Shield by Jimmy P. Rodger | Robot is Happy
December 23, 2009 at 09:05
NEW PRODUCT – LoL Shield GREEN – A charlieplexed LED matrix kit for Arduino « adafruit industries blog
October 11, 2010 at 15:28

{ 13 comments… read them below or add one }

1 j4k3 December 23, 2009 at 06:05

So simple, yet so awesome. I’d love to see them in real but unfortunately I won’t make it to the congress this year. Can’t wait for you to finish the pcbs, though. A purpose for my spare Arduino Boards, finally!

2 Kevin Reid December 23, 2009 at 06:27

This looks very cool, I look forward to buying a kit to play with!

3 drew December 23, 2009 at 20:57

waaayyyy ccoooooolllll. i’ll buy a kit as soon as they’re ready! that or even just a few of the pcbs. but the name is great cause it was exactly my reaction when i first played the video

4 ScionOfBalance December 25, 2009 at 18:25

I want to quote your post in my blog. It can?
And you et an account on Twitter?

5 Christian December 29, 2009 at 13:14

I built a red and a green shield at 26C3. It was lot of fun and your instructions helped alot, Thanks Jimmy! Both of my shields work as expected. However, I have some “ghosts” (not permanent) in the upper right hand corner (top row, LEDs 1, 3, 5 from right to left). Both shields show this behaviour, and even your video above. Design issue? Arduino weakness? Can’t be my soldering skills, since its also in the video. Any idea?

6 Alex Wenger December 30, 2009 at 10:49

i made a interrupt powerded library for the LOL Shield. It controls 11 LEDs in 12 steps, so the shield will be much more bright.

Download at: http://arduinobuch.wordpress.com/downloads/

7 Jimmie January 1, 2010 at 11:12

Sure, that isn’t a problem

8 wrowe May 21, 2010 at 10:06

Ghosting on those LED’s is from the competition from your on-board pin 13 LED, yank it, or at least that LED’s resistor and the problem will be gone.

9 Jimmie May 21, 2010 at 12:00

Yep, getting rid of the resistor going to the pin13 LED is going to be in the instructions as a suggestion.

10 Jason August 31, 2012 at 23:55

I’m thinking about doing something like this for the mbed, since I got one through my school. I will start out by buying one of yours, and figuring out how to program charlieplexed led’s but eventually I could design and use a bigger shield, as the mbed has 26 general i/o pins, along with usb and ethernet.

11 Jimmie September 1, 2012 at 16:18

Hey Jason,

Good luck with it, would love to see it working with the mbed. I’ve got a few of them, but the online-only compiler just doesn’t work with my lifestyle, so they’ve been of little use to me. :-(

12 Jason September 19, 2012 at 02:07

I finally took some time to finish soldering, and then started programming a text scroller.
Here is the result: http://youtu.be/zPXw2Tcew-Q

13 Jason September 19, 2012 at 02:20

oops, sorry wrong link.
here is the real vid: http://youtu.be/6NfDQyB5RcA

Leave a Comment

Previous post:

Next post: