Posted by kohsuke
on December 7, 2006 at 12:29 AM PST
My previous DIYOrb article got some attention, so this is a follow up to that.
I'm happy to hear from many folks that they liked the DIY Orb project . It even made it into the ServerSide ! This is a follow-up to my previous post.
Schematics and Software
First, the schematics:
LEDs are all connected in parallel. The one that I used was cathode common, so it's connected to the ground and I used PNP transistor, instead of more "normal" NPN. In my case there are 8 tri-color LEDs plus 4 extra red LEDs . Tri-color LEDs always seem to be weak on red, so you'll likely need more red LEDs like I did, but do the math and experiment to figure out exactly how many you want to even out the colors.
Each LED consumes 20mA, so blue and green eat 160mA and red eats 240mA. But in practice, I measured only about 130mA and 200mA. I suspct that the datasheets are wrong about LED's Vf, and it also depends on the transistor you use. So you'll probably want to do some trial and error to figure out the right resistors (good thing those things are cheap!) for Rred, Rblue, and Rgreen. Just FYI, I used Rred=18ohm Rgreen=Rblue=8.2ohm.
One more note about LED is that connecting LEDs in parallel like this is probably not very good in terms of protection, since if a few LEDs die out, the rest will get over-current and hence the whole LEDs would be wiped out. I just didn't feel like soldering 28 resistors and connecting them all, so I did it like this. I figured since I'm running lower current than 160/240mA, a few die-out should still keep the rest safe.
Also, be careful that USB device can draw only up to 500mA according to the spec, although in practice most computers do allow more. Unless you turn on all three colors, 240mA+160mA=400mA, so you should be still safe.
For transistors, I used 2N2907 . I guess it could be really anything — I just picked this one because it seemed popular (hence I thought it a safe bet), and it only cost 8 cents each (gotta love HSC Santa Clara shop!). It can drive 500mA easily, so it's good enough for driving 160mA LEDs.
The base resistor Rb should be also computed based on the transistor. Mine is 820 ohm. Those are connected to USB Bit Whacker, B0, B3, and B6, but it can really be any pins. You just need to tweak the software accordingly.
This is the software for PIC . It probably contains a bunch of unneeded files. The actual binary is in _output/FW_D.hex. The project file has some hard-coded directory names in it, so you'll likely have to tweak it a bit if you want to recompile it. I guess folks at Microchip has been sleeping when they designed the project files to contain absolute paths.
Oh, and I'm not completely done with the orb yet. It turns out that components soldered on two boards can touch with each other, and when that happens the circuit shorts and that's not pretty! So I'm thinking about covering them with a little plastic to make sure that won't happen.
This is the compiler that translates the "color program" into the bytecode that the firmware understands. You'll see src/main/language.g that defines a language.
The agent program is the one that sends bits to the device , but you probably won't need it. On Windows, just open "COM4" or some COMn — you have to figure 'n' out — as a file and write the bytecode to it. On Linux use /dev/ttyUSBn.
Replies to the comments
For everyone who wanted this orb — if you are local to the SF bay area, I'd be happy to build a few more with the exact same configuration. But remember, this is a hobby and I'm not an electronic enginner, so don't come after me if it breaks! I've bought all the tools, so it's just a matter of ordering parts. But I think you'll have a lot more fun if you do it by yourself :-)!
Eduardo — this PIC chip is powerful enough to drive other devices simultaneously, like maybe LCD matrix and some switches. With a small LCD, I think one orb can display different information (by switching from one to another every 5 seconds, for example, with LCD showing what it is.) Another related idea is to connect an RFID reader, and if you bring the tag closer to the orb it will display information related to that tag. I think our employee badge has an RFID-chip, so I think it could be a lot of fun. You put the orb at the door and everyone that comes in gets to see something tailored to his own interest (maybe the new bugs he has. it's quite configurable) displayed in the orb.
Maybe that should be my DIYOrb v2 plan :-)
Jean-Francois — Yes, it would be very nice to build an orb connected to wireless ethernet. I think Microchip sells a version of PIC that does understand TCP, and I think SparkFun has a small pre-assembled board for 802.11, so I think it's just a matter of putting them together. You'd have to build a power circuit into the orb, so it will be a bit more work, but I bet someone with a reasonable electronics knowledge should be able to do it.
atchy — thanks for the info. Sounds like there're a lot more options other than UBW. I quickly looked at some of them, but I wasn't sure if you need a separate programmer to flash the chip (which usually is expensive, AIU) or I can still download the program via USB. I wish I could attend your session, but it'll be in Japan, right?