|
The dice kit is available directly from the manufacturer at spikenzielabs.com, and from resellers like sparkfun.com. This kit is indeed a clever design, but could still be improved. This page contains information about possible hardware modifications, alternative firmware, and source code that you can modify. |
Dim LED Fix
To make the LEDs brighter, replace the 470 Ohm resistors with lower values. For maximum brightness, you could try 10 Ohm resistors for R1-R3 and 100 Ohm for R4 (R4 needs to be a larger value or the center LED will be brighter than the others because the center LED is driven by one CMOS driver instead of two). This modification may shorten the battery life, but it won't harm any of the kit components.
Tap Sensitivity Fix
If you find that the sensor circuit is overly sensitive (mine seems to go off whenever it feels like it), try these changes:The PIC12F675 PIC input pins are able to clamp up to 20 mA, so the 10K series resistor will provide plenty of protection (more than the original design) from over/under voltage spikes from the piezo sensor.
- Add a 10K resistor in line (series) with the red lead from the piezo sensor.
- Replace the 1 MegOhm resistor with a 100K resistor.
- Replace the diode with a 0.001uf capacitor.
OEM Dice Code
The original source code is written in assembler for Microchip 12f675.
Theory of Operation
It's may seem counter-intuitive, but using the A/D input from the piezo sensor for a random number source is problematic because such analog signals are often surprisingly repeatable. Generating a random number well, especially when using a relatively simple PIC processor, can be challenging. This is because microprocessors are designed to be deterministic rather than random devices.The code presented here uses an overly complicated randomization method that's based on a pseudo-random number generator plus two environmental inputs (the time of the dice roll and the ambient light level). The result is pretty much truly random dice throws with no repeating sequences.
User Interface Improvements
- When the dice is tapped, it the LEDs "roll" (flash a pattern) for a moment before showing the result.
- The dice automatically shut off after 15 seconds, just like the original dice kit. But you can bring it back to life and see the last roll with one tap. Tap it again to throw another roll.
- Double-Roller and Super-Dice options (in the "extended" firmware version). Double-Roller shows two roll values instead of just one. Super-Dice adds a 1 in 100 chance of rolling a "7". These options are selected by removing and inserting the battery; each time the battery is inserted, a new mode combination is selected. The selected mode is indicated by a single or double roll of either "6"(standard dice) or "7"(Super-Dice). With both Double-Roller and Super-Dice selected you can try to roll for double-7's (it's a 1 in 10,000 shot).
Implementation and Source Code
To implement the new firmware, you will need a PIC chip programmer such as the Microchip PicKit. There are a couple of ways that you could program the firmware into the PIC chip:
- Install an 8 pin socket on the dice kit and use a demo board to program the PIC chip separately (the Microchip PicKit 2 Starter Kit includes both a programmer and a demo board that would work for this).
- Wire a 6-pin header to the installed dice kit PIC to plug into the PIC programmer (refer to the schematic diagram for the wiring hookup). The PIC can be programmed in-circuit using the programmer powered mode (remove the battery).
Use the chip programmer’s software to load the firmware hex file and program the PIC chip. If you are using the MPLAB software and a PicKit programmer, this can be done directly from the MPLAB IDE.
To modify the software, use the Microchip MPLAB software (available for free from microchip.com). There's still plenty of ROM and RAM space left in the PIC, so go ahead and invent the greatest (or weirdest if you prefer) electronic dice in the world.
| click here to see the OEM source code |
| click here to see the modified source code |
| click here to download the source code project file folder |
| click here for the standard dice firmware (single roll, 6-sided) |
| click here for the extended dice firmware (double/super modes selectable) |
| click here for the original dice kit firmware |