HOME


either use it as is... or add your triks!

Electronic dice

how to use Nutchip -HOLD input

Schematic | Truth table | Building | Cheat

 

"Iacta alea est"

"Iacta alea est" is the Latin for sayng that dice is rolling, as Julius Caesar in person said crossing Rubicone river. At a glance, it could seem impossible to build an electronic dice with a Nutchip alone. To look like the real thing, a 7 leds are needed - far beyond the Nutchip's 4-utput limit! Well, we are going to demonstrate how 4 outputs are more than sufficient for a great deal of applications - if you add your own salt.

A deeper analysis shows how to group the original 7 leds in a way to make it possible to show all the dice numbers. Leds are numbered from 1 to 7 (see schematic below) and grouped as:

DL1 + DL2
DL3+DL4
DL5+DL6
and DL7 alone.

Four groups, four Nutchip outputs. Let's see how to drive each group to get dice's numbers:

dice_1.gif (730 byte) Number 1 needs just DL7 dice_4.gif (755 byte) To get a 4 switch on two pairs: DL1-DL2 and DL5-DL6
dice_2.gif (763 byte) To get number 2 switch on DL1-DL2 pair. dice_5.gif (752 byte) To get number 5 add the mid LED, DL7, to the configuration as per #4 (DL1-DL2 and DL5-DL6)
dice_3.gif (743 byte) Number 3 comes from DL5-DL6 plus DL7 dice_6.gif (758 byte) Finally, numero 6 requires three pairs to be switched on, namely DL1-DL2, DL3-DL4, DL5-DL6

Our electronic dice incarnation spins at the pressing of a button. All the LEDs flash frantically, until we release the button in order to stop them to a random number - the dice result.

Schematic diagram

This project takes advantage from -HOLD input, which is connected to push-button P1. As long as the -HOLD input is low, truth table's timeouts have no effect because this input serves to disable any state change provoked by timers. The effect is to freeze Nutchip's counting, stopping the LEDs on the number they were displaying at the time of key release. Notably, we could have used -STOP input to get the same effect, although this does not apply as a general rule - there are occasions where these two pins behave differently.

A 390 ohm resistor (R5) keeps -HOLD pin at low-level when P1 is released: so the numbers do not change and the LEDs display steadily the last number drawn. When pressing P1, the -HOLD input goes to +5V because of the button's action - ovverriding R5 effect. Nutchip timer is no longer blocked and it keeps changing state at a fast rate, giving a random rolling effect as long as P1 is pressed.

 

dice.gif (16169 byte)

Electronic dice schematic diagram. The coloured dots match wire colors as used in our prototype (see photo).

At first glance, the way the LEDs are drawn can look messy. Don't be fooled by appearences - the schematic is drawn to simplify breadboarding, and the way the parts are placed reflects the actual solderless breadboard prototype. Follow carefully every connection to discover that we have just three LEDs pair connected to outputs OUT2, OUT3, OUT4 and a looney LED connected to output OUT1.

Every LED has a current-limiting resistor (R1, R2, R3, R4). LED pair's resistor is lower (220 in place of 390 ohm) to compensate for the voltage drop introduced by each LED. With the values given the resulting current is about the same for single LED and pairs, in order to get uniform brightness.

Truth table

The truth table is simple: its only job is to show all six dice sides one after another, in an endless sequence. The sequence is so fast that the player won't be able to stop it at some predetermined point. Whe choose 30 mS as rolling time, which yelds more than 30 sides per second - a value that is greater than human eye retina capbilities! When running, this speed results in a beatiful flashing. You can find the table ready for loading from the file "dado.nut"

 

state  out 1..4  inp 1..4 remote next
---------------------------------------    
st00   0 1 1 1   timeout 30 mS   st01
---------------------------------------
st01   1 1 1 0   timeout 30 mS   st02 
---------------------------------------
st02   0 1 0 1   timeout 30 mS   st03 
---------------------------------------
st03   1 1 0 0   timeout 30 mS   st04 
---------------------------------------
st04   0 1 0 0   timeout 30 mS   st05 
---------------------------------------
st05   1 0 0 0   timeout 30 mS   st00 
---------------------------------------

 

Assembling

This circuit is suitable for breadboard assembling. The photo shows how to place the parts on a solderless breadboard. The process requires careful LED placement, in order not to reverse or exchange them. All of the LEDs have their cathode pin towards Nutchip, except the mid one (#7) whose cathode is faced up. Common LEDs have their case flattened in proximity of cathode pin. Also, LEDs have the pins divaricated enough to allow an extra bradboard hole between them. E.g., LED #2 anode goes to red wire, and cathode to yellow. The green wire is routed through..

To make breadboarding easier, resistor and LEDs are placed in the same posiotions as in the schematic draft. Compare your bradboard against our example, and see also the wire color table below. A criticalpath is outlined in the yellow frame: the orange-wire should not touch the 390-ohm resistor, in case insulate resistor pin with plastic tubing.

dice.jpg (35430 byte)

Parts listi:

DL1 to DL7: red LEDs
R1, R2, R3: 220 ohm resistor, 1/4 W
R4,R5: 390 ohm resistor, 1/4 W
P1: pushbutton (normally open)
OSC: 3-pin, 4MHz ceramic resonator
C1: 100 nF capacitor
IC1: NUT01-AK (Nutchip)

You need also: a 5 volt stabilized power supply, PC interface for Nutchip programming, a PC running Nutstation.

We suggest you to temporarly modify the truth table increasing timeouts to 2 or 3 seconds (in place of actual 30 mS) in order to perform a circuit test - and to understand fully how the circuits works and reacts to user action!

Chip programming is easy: if you have an interface like ours, plug it into breadboards holes, they are highlighted with a red border and a "PC" label in the photo. Right after table programming, the circuit is ready to work. Press P1: as long as you keep it down, the numbers must run on the LED display. As soon as you release P1, display must freeze on the last numpber shown. After this test is completed OK, reload the table with timeouts set to 30 mS, and you're finished.

Electronic cheat...

With the truth table above, all dice sides have the same likelyhood of being drawn. This fact is a direct consequence of all the timeouts being the same. But what if we make timeouts different each other, e.g doubling it fo some faces and halfing it for some other? The net result will be a greater probaility for the numbers with longer timeouts, a trick very hard to discover. An interesting experiment is to make statistics playing a large number of times - let's say 100 - at first with the unmodified truth table, then to repeat the same experiment with the altered truth table. How many times did you get 1? And 2, 3? This is an impressive work to show the class: try drawing a graph of how numbers sum up using with a spreadsheet program like microsoft Excel, and you will clearly see how timeouts effect results.