Skip to content

hjohnson/Dice-Rolling

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The DigiDice is an easy to use electronic die that is powered by 2 AA batteries, and uses a hardware random number generator to replace the six standard sizes of dice used in most games (D4, D6, D8, D10, D12, D20).  

Extended Version, for official writeup:

	ÒAny one who considers arithmetical methods of producing random digits is, of course, in a state of sin.Ó Ð John Von Neumann, 1951

   When I started this project, I had several design goals in mind: I wanted it to be extremely small and easy to carry, yet have 6 buttons to ÒrollÓ each of the standard sizes of die (D4, D6, D8, D10, D12, and D20). I also wanted it to based on a Random Number Generator (RNG) implemented in hardware instead of using the built in pseudo-random number generator. As those who have been watching the Show And Tell will know, IÕm proud to say that IÕve succeeded. 
   My first step was to learn as much as I could about the Random Generation process, so I could design my own generator. I found an open source design that I was able to implement. In this design, the Zener Effect of a 1.22V Zener Diode is used to generate Avalanche noise, which is then amplified through a 2n3904 NPN transistor and a pair of high-speed Op Amps, then delivered to the Microprocessor as a digital input. The microprocessor implements a debiasing algorithm known as the Von Neumann corrector to take the input noise distribution, which could have an uneven balance of 0s and 1s, and turn it into an even distribution of 0s and 1s. When the conditions of the corrector are met, the new random bit is mixed into a 32 bit number. Since this is implemented within a timer interrupt that triggers every 32 microseconds, the random number is updated extremely quickly. If you want to learn more about the RNG support circuitry or the software, check out the source files for this project. The Hardware process is described on the Schematic, and the software process is documented within the source code.
   To check that this device worked properly, I sampled the D20 option 250 times, and performed a PearsonÕs Chi-Squared test based on the null hypothesis that the source data is uniformly distributed. Suffice it to say, it passed, and I could not reject the null hypothesis. I also borrowed the method of testing from the original designer of the RNG hardware, so if youÕd like to look at the precise statistical methods, feel free to check them out at http://tinyurl.com/diyrandomgen 
   To make the device easy to use, I selected a two-digit seven-segment display, and found small tactile momentary switches that I could use for the UI. Since I wanted this project to be as small as possible, I decided to use Surface Mount devices for the RNG components and microprocessor and put them beneath the seven-segment display, on the underside of the board. I selected the Atmega8 to keep the LED driving simple (it has enough pins to drive both digits simultaneously, to keep the input switches on as few pins as possible (IÕm using a resistor ladder, and an ADC to read the result), and to have a small package to fit within the .6Ó spaced rows of pins on the seven-segment display. Because I was able to place all of the components (besides the switches and display) on the underside of the board, the top of the device is clean and simple and the PCB is kept to 1.1Ó x 1.25Ó, small enough to easily attach it to a 2xAA battery pack. Since the batteries would run out in under 10 days due to the high (~10mA) quiescent current use of the ADC and RNG circuitry, a simple power switch is included to turn power to the whole device on and off. At one-off prices, all of the components can be bought for about $10. The PCB is small, so if you buy from Laen over at DorkbotPDX (Who, by the way, awesomely accepted several last-minute design file changes, on a weekend no less) itÕs about $7 for 3 boards. 
   In short, this is a simple, easy to use artificial die. When a button is pressed, the machine generates a random number in the appropriate range, displays it on the screen for several seconds, and then turns off the display. If you use this device, you donÕt have to worry about carrying around a bag of dice, finding an even rolling surface, or losing a die. And in the process, I learned about Hardware RNGs, and designed my first mostly surface-mount PCB. This project is released as Open Hardware under the CC BY/SA License.

About

Small device that can act as multiple sized dice (D4, D6, D8, D10, D12, D20), and output on a seven-segment display.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages