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.
I’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.
I 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.
When 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.
The 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.