perjantai 18. huhtikuuta 2014

Tiny PICs: Toy modding

Over last few entries I've written about small PICs, now for the actual implementation. And it's a toy!
We got this book based on certain animation (that shall be remain unnamed, as well as the creator) some time ago and it had this airplane-shaped "projector" with it. When turned on, it could project a picture (you could change the shown picture, one out of about dozen, by pressing button).
Our son loves it, or mostly the light in it. And of course he quickly figured out that tiny switch in bottom turns the light on (and off? never!), so usually he went to sleep holding it, light on, and batteries (3 LR44s) didn't last a week.


No way I'll keep buying more batteries to just have them last a week, so maybe some light modding, say, some electronics in it to turn it off automatically after five minutes or so. I first thought implementing the light with a PFET and analog timer (mainly because I hadn't used those before, unlike MCUs that I considered too easy), but it seems that no suitable simple timer chips exist (or more likely I just couldn't find one).

So, a PIC then. Some quick back-of-the-envelope calculations indicated that by using the sleep mode of these small PICs (approx. 100nA consumption) with wakeup functionality tied to a button, batteries with approx. 100mAh capacity would last approximately "long enough so it's forgotten already". I first thought of using external PFET to turn everything off (including MCU, to be woken up with touch of button) when not needed but the additional energy savings here would be so minimal that I discarded that idea for now.

To determine what would be needed I of course needed to first silently steal it (with empty batteries it held almost no interest to the small one so this was easy) and then take it apart (four standard screws, one of which held battery compartment closed, easy too. Tail was very tightly fit together so it took some careful application of force to not break anything).

So, first impressions. The design is actually pretty well-thought for a simple toy. Two halves have protrusions that hold all the internal pieces in their designated positions with no screws or other fasteners. LED part was pretty much as expected; LED (with 3v forward voltage), 120ohm resistor and simple switch. Button at bottom pushed rod up to rotate wheel with the small pictures in it, and two lenses to focus the image (one fixed and one in propeller "tube" to focus by moving it. If you try this yourself, note that the fixed lens is asymmetrical - if you put it in wrong you won't get any good picture)

All things taken apart. Starting from upper left corner and proceeding right then down; button/push rod to change picture (missing the spring that goes with it); top piece, battery compartment cover, propeller/lens piece, picture wheel and (plastic) lens next to it, some tools, bottom part, led/switch assembly with resistor. Both LED and switch are held in place by LED and resistor wires that are soldered to battery compartment leads in on bottom part of plane. Curiously the solder on battery leads looked a bit too shiny for standard RoHS-compliant stuff but I didn't bother to examine it further.

Closeup of the picture disc. The entire disc is about two centimetres across, so individual images are about 5mm across. It could produce image of approx 10cm across with relatively good detail , so print detail on that slide must be pretty fine. I wouldn't be surprised if that printed slide were the most expensive part of the entire plane with that amount of detail (but then again, I am not that intimately familiar with capabilities of current printing processes so I might be wrong). Counting here is seems to have 10 images total (instead of dozen I guesstimated above), my mistake.

On picture below you can see the modified led/switch holder of right. The original switch has been taken out and replaced with (slightly larger) push button I had available. Due to this the hole at the bottom of the plane had to be enlarged too. The I/O line that is monitors the button is pulled high with 1M resistor. Only later I realized that since the original switch had three poles so I might have been able to use it directly without bothering with the button. Oh well.
The original 120ohm resistor is connected directly to two PIC outputs (the current through LED is only 8 mA with full batteries so just one output would be sufficient, but I still used two). Small bypass capacitor can also be seen here. The MCU is placed on holder for easier testing/reprogramming (take it out from holder and put to programming header - for a proper product I'd put programming pins on tiny surface mount PCB with LED and switch on it, or for really large volumes order pre-programmed chips. Funnily enough I'd estimate that tiny PCB with all electronics on it (plus two wires for battery) might actually be cheaper than current construction where everything has to be hand-cut and soldered, but then again, that might be wrong as I have no idea of the said priced in china.
Unconnected wires are battery positive and negative.

From the other side.

After testing this on desk it was time to put it all together. Here the button/led assembly is in place, battery wires not yet attached. I also added some hot-melt glue the MCU to protect it from mechanical strain (it gets thrown around a lot). LED placement has to be just right for proper light output, so care has to be taken, especially if you change the button.

From front. Note the spring on picture changing pole at front. Spring is not the original one, that one  fell from the table and crawled to some hiding place I have yet to find so I had to salvage some non-functional promotional pen for new one. Note also the changed battery wire; those red wires are thin, single-strand wires, nice for PCB repair where they do not move after placing as they break very easily. In this kind of setup you do not want to use them, as I painfully learned after having to re-solder/replace them a few times. The only reason I used them in the first place was that they were light and I had roll of it available, so lesson learned here.
The MCU blob was a bit tight fit but I managed to push it in cockpit part with two-sided tape. Eventually.

All done and it works! Whee!


Next; more details on schematic and software used.


Ei kommentteja:

Lähetä kommentti