PIC10F200 based dice
This page describes a PIC10F200-based electronic dice. The reason I made this was that I got a small corner left
over when ordering a panel with a couple of other PCBs and thought I would rather use the corner for something fun than leave it unused, so I made a dice.
The PCB is quite small, so it is hard to etch yourself even the layout is available in the zip-file if you want to try, so to
make it easier for you I've made it possible for you to buy PCBs,
preprogrammed chips, and of
from me in my web shop.
Even though this is a very simple project, it requires some surface mount soldering skills, proper tools, and a steady hand as it is built with surface mounted components only. But it might be a good start if you have experience in hole mounted soldering and want to try surface mount soldering. As you can see in the picture to the right it is possible to make it work even if the soldering looks like crap ;)
Schematic for the dice.
The standard solution for a power supply is to use a 7805 but I could not find any 7805 in a sot-23 or smaller capsule so I used an LP2985 that is available in a 5-pin sot-23 capsule with 5v/150mA output. I use a 100nF cap on both input and output side of the regulator to get rid of noise etc. I'm using a standard 9v battery to supply the circuit. In the PCB-layout there is also a hole for the cable to remove mechanical tension from the soldering point of the cable.
The PIC controlling the dice is a PIC10F20X, but it is also possible to use a PIC10F22X (that is what is sold in my web shop. as it is almost the same price so I use the 10F222 to get fewer chips in stock as other projects use the 10F222), both are microcontrollers with very limited RAM and ROM, 16b/256w of RAM/ROM but there are versions with up to 24b/512w, the 10F22X series also has an ADC but that is not needed in this project. Same .hex-file can be used for both the PIC10F200 and the PIC10F222 as the later is set into compatible mode and only disables the 10F222 specific functions in the beginning of the program which has no effect on a 10F200 chip. Two of the six pins are used for power supply, there is one reset (or input only) pin and three IO-pins. The switch is connected to the reset pin that is configured as an input. The three IO-pins left is used to drive a 2x2 matrix configuration of the seven LEDs. The LEDs are connected in series and lit in three sets of two LEDs on opposite sides in series and one single LED in the center. The 2x2 matrix configuration is created with three pins only by putting diodes in both directions so when the common line is "0" LEDs are lit by "1" and when the common is "1" LEDs are lit by "0". This leads to that only two sets of LEDs can be lit at one time, either the LEDs in the corners or the ones in the middle. When changing fast (100Hz) between lighting the different LEDs it look like they are all lit at the same time thanks to the persistence of vision effect. There are of course some resistors in series with the LEDs as the system runs on 5v and the LEDs have a voltage drop of about 2v each.
One nice feature of the PIC10F-series is the current consumption, especially in sleep mode. This removes the need of an on/off switch as the dice only uses 0.4uA in standby, so it can be in standby for many years without discharging the battery.
The roll animation.
The software is very simple, not very good looking and not very optimized but the 16 bytes of RAM and 256 words of ROM is more than enough so there is no need for optimizations (except for the optimizations that are fun to do). It has a main loop lights half the LEDs delays and lights the second half then another delay and then runs the state engine that controls the output. The state engine has four states IDLE,WAIT,ROLL and SHOW. When in the idle state the PIC is set to sleep state and is woken up on pin change (when the switch is pushed). In the wait state, a roll pattern is shown (as seen in the animation here to the right) and a counter is generating a random number based on how long time the user pushes the button (not very good random generator but if the button is pushed longer than the mechanically shortest possible time it is quite ok). In the ROLL state the roll animation is shown for two additional seconds just to make it more exciting ;) Finally in the SHOW state the result is shown for 3.5s before getting back to IDLE, unless the button is pushed and it starts another roll.
How to assemble the system.
It is quite tricky to solder SMD components and they have very small mass they become quite sensitive to heat
so make sure not to warm them too long.
The basic principle is to start from the center and work your way out. Start with the center LED and then the LEDs to the left and right. Note that the cathode is marked with a small dot on the LED and you can see the same dot marked in the placement sketch.
Continue with the 47 Ohm resistors followed by the diagonally placed LEDs. Then you can mount the two sot-23 ICs (make sure not to mix them up, the easiest way to separate them is that the PIC10F222 has a 6-pin capsule and the LP2985 has a 5-pin capsule). Now you can mount the two capacitors and the 100 Ohm resistor. The last SMD component you mount is the switch and finally you mount the battery connector (black wire connected to minus-pad and the red wire connected to plus-pad). Note that you should put one of the wires through the hole to reduce tension from the wire in the soldering point.
Before turning on the power, make sure there are no shortcuts first by looking at your soldering with a magnifying glass and if you are unsure if there is a shortcut use an Ohm meter to be sure.
The schematics, layout, component placement, source code and compiled .hex is included in the following zip-file: dice.zip(109kB)
PIC Dice (C) Rickard Gunee. This is open source, use this at your own risk ! You may use the information on this page for your own projects as long as you refer to the original author (by name and link to authors homepage), don't do it for profit and don't hurt or harm anyone or anything with it. The author can not be held responsible for any damage caused by the information on this and related pages.