Step 6Design the Board
The Microcontroller
_______________________________________________________________________
I ended up designing the whole thing around the Microchip PIC12F508 , the smallest, cheapest microcontroller I could find with the right number of pin outs. With no interrupts or PWM, the PIC12F508 is nothing fancy, but it definitely gets the job done. At the time of writing, they run around 46 cents apiece. Similar chips are available from ATMEL, under the AVR banner, and are more full featured, but cost about twice as much. And in the quantities I want, that matters.
The PICF508 runs nominally at 4MHz on its internal oscillator. It has only 750 bytes of program memory, and 25 bytes of RAM, but we don't need that much, anyway. It also does not have interrupts or PWM, but, again, we can get by without those. As far as I/O goes, it has exactly enough. There are 8 pins, two for power, and 6 I/O pins, one of which is input only. We already know what that means: It will have five LEDs and one sensor, and that's it. The most important feature is that it is programmable in-circuit (ICSP), meaning you don't have to take it off the board to reprogram it; an important point when you are dealing with a soldered on SMD part.
When running a program, pins 2, 3, 5, 6, 7 of the PIC are configured as 3V LED ouputs, pin 4 as an input, and 1 and 8 are 3V dc power inputs.
In ICSP mode, the PIC is programmed over five pins:
Pin Function
1 Vdd
2 (unused)
3 (unused)
4 Vpp
5 (unused)
6 ICSP CLOCK
7 ICSP DATA
8 Vss
_______________________________________________________________________
That decision made, the rest comes easy, up to a point. Aside from the five LEDs and their current limiting resistors, a tilt switch that pulls Pin 4 (GP3) low when the the board is tilted, a bypass capacitor across pin 1 and 8 (.1 uF C1) to prevent erratic CPU behavior, and a momentary power switch to prevent battery drain, there isn't much to it. It's simple, as promised. And with the right program, it can do anything! Anything at all. The only limit is yourself!
I spent a bit of time obsessing about the other components; I ordered about 20 different tactile switches from DigiKey to find the thinnest, nicest looking, softest feeling tactile switch possible. SInce the battery will overheat (and potentiall explode) if soldered to, I played around with conductive epoxy and conductive tape, with no luck. In the end I bit the bullet and paid the 26 cents apiece of nice, solid, SMD battery retaining clips. They ended up fitting into the design fairly well, too.
Now all there is to do is obsess about the artistry of the PCB layout, and we're done. Ironically, I put more time into proportion and layout than anything else on this project, and it gets three sentences of description.
Well, the thing does have be pretty, after all.
Improvements
_______________________________________________________________________
The final design does leave room for improvement. For one thing, it needs much brighter LEDs so it can be seen better in bright light. Also the tilt switch makes it seem kind of cheap, e.g. "What is that thing rattling around? Is it broken?" Other flaws, such as having to wave it to see anything, are intrinsic to the design and were accepted before I even began. Incidentally, it ends up being something of an intelligence test if you don't explain how it works, but there is a definite advantage of that; only the people who can figure it out will be giving me a call. :)
In order for ICSP to work there cannot be any interfering components on the pins it uses I had quite a bit of trouble with this. After modifying the original copper trace design, and rearranging the ICSP pads (but still matching the schematic exactly!), I found that I could not program boards anymore. The easy solution is to remove the capacitor connecting pin 1 and 8, and it works properly now. The component isn't integral to the design, anyway.
References
Parts
- PIC12F508
- CR2032 3V Lithium coin cell
- Battery retainer clip
- SMD tactile switch
- Tilt switch (though a mercury tilt switch would work just as well :)
- RED SMD LEDs, 20 mA (LTST-C930EKT is what I used, part listed is superior, cheaper substitute) x 5
- 100 ohm SMD resistor, 0805 1/8 W 5% x 5
- 47k ohm SMD resistor, 0805 1/8 W 5%
- .1 uf SMD capacitor, 1206
| « Previous Step | Download PDFView All Steps | Next Step » |
![]() |
Add Comment
|


































































