Page 1 of 1

electronic dice

Posted: Sat Apr 06, 2013 4:01 pm
by jdboy3020
I've always wanted to have electronic dice but can not find any that output in decimal numbers. How easy would it be to add a circuit to this kit to output to two seven segment LEDs? http://www.ramseyelectronics.com/cgi-bi ... &key=K3400 Lamar

Re: electronic dice

Posted: Sun Apr 07, 2013 7:24 am
by sghioto
The schematic for this kit uses a 4022, a 1 of 8 decoder driving the transistors which control the LEDs. Using a CD4511 display and some isolation diodes will do the trick. The resistor values for the segments may need to be adjusted depending on the supply voltage used.

Steve G

Re: electronic dice

Posted: Sun Apr 07, 2013 1:04 pm
by jdboy3020
Thanks a lot. How complicated would it be to have the to numbers added together, for example instead of showing a 3 and 4 it would show 7? Lamar

Re: electronic dice

Posted: Mon Apr 08, 2013 3:10 pm
by sghioto
:eek: What? Add them together! Can't you just do that in your head. :mrgreen:
Yeah it's possible but I would use a microchip.

Steve G

Re: electronic dice

Posted: Mon Apr 08, 2013 6:23 pm
by haklesup
The problem with that is results greater than 9 cannot be displayed on a single 7 seg display.

A binary adder might work since you are only using digits 1-6 (binary adders have base 16 count not base 10). I'm not 100% sure for that reason and would need to do a few test additions on paper to confirm it. Do an image search on binary adder for some logic diagrams implemented with various types of logic. The addition would happen before the 4511 and results greater than 9 may be displayed as A thru F (hex) and you may have to substitute the 4511 BIN to DEC with a BIN to HEX decoder (I did not look up the datasheet for the 4511, it may already be HEX)

Re: electronic dice

Posted: Sun May 05, 2013 2:23 pm
by jdboy3020
sghioto wrote: :eek: What? Add them together! Can't you just do that in your head. :mrgreen:
Yeah it's possible but I would use a microchip.

Steve G
I've always wanted to get started with micro-controllers, maybe this would be a good reason. Next I need to figure out which. I'm thinking I need a micro that would come up with a random number between 1 and 6 (or 1 and 12 depending on the position of a switch) and display it on a double 7 seg LED. Would a PIC be a good candidate? What books would you recommend for a newbie with 0 experience with micros?
LEM

Re: electronic dice

Posted: Sun May 05, 2013 5:13 pm
by sghioto
Would a PIC be a good candidate?
Pic is a good candidate, although I started out in and still use the PICAXE family of micros. These are Pic microchips pre-programmed with the PICAXE bootstrap code. I believe this is the easiest, least expensive and most simple way of getting into micro's. Check out the link.

Steve G

http://www.picaxe.com/Getting-Started/PICAXE-Manuals

Re: electronic dice

Posted: Mon May 06, 2013 12:59 pm
by haklesup
Truely Random numbers are notoriously difficult to produce in software. You can produce pleudo random but true random is elusive. Alterantively, you can create a randomly oscillating analog circuit between 1 and 12V (or .1 and 1.2 if you like) then on command sample and hold the value and display its voltage rounded to 2 digits.

In software you can seed a fractal with a time code (say when the operator pushes a button) then sample it at another randomly selected time as determined by when the operator releases the button. Pseudo random code times random human timing input. There are other methods you can learn about by searching.

Its hard to beat the simplicity of real dice

Re: electronic dice

Posted: Tue May 07, 2013 8:45 am
by Lenp
For a really random and totally unpredictable number, you will probably need a female to help you! :wink:

Re: electronic dice

Posted: Tue May 07, 2013 8:42 pm
by MicroRem
Lenp, I believe that if you were any more right you would be wrong.

Tom

Re: electronic dice

Posted: Tue May 14, 2013 10:12 pm
by haklesup
come to think that the odds in dice are not random at all. My suggestion of a single variable 2 to 12 number would not produce dice like odds.

The odds of getting a 6 or 7 are much greater than getting a 2 or 12 for example because of the way 2 dice combine. To get true dice odds, you need to have 2 seperate number generators which you can then add together as a seperate step. My comments about randomness are valid but only if applied to one dice at a time before adding. the circuit in the second post is perfectly suitable starting point in that respect.

In response to adding, it could be confusing since 12 could accidently be interpreted as 1+2=3 not 6+6 Its technically possible but ill advised from an application standpoint

Re: electronic dice

Posted: Thu May 16, 2013 6:00 am
by avionicsmaster1958
I haven't been exposed to other PIC programming languages or their chips other than PicBASIC. I don't think it's any harder to learn than others but I have been told it's a bit more versatile than some companies IDE designed for PICs. Though there are a plethora of programs written for PICAXE and other lanugages all using PICs. I think PicBASIC is easier than PICAXE becasue it is the basic language where, to me, PICAXE is alot like C. Which in itself is bad and good. Bad to me as it's a bit harder to learn but I think PICAXE is more efficient and you can pack more bits into a chip. Those are my thoughts on languages. Please don't shoot the writer.

If you decide to use PicBASIC I'd recommend the 12F683 chip. It's got just enough pins for the project if you get creative with a RS bit. It has the most memory of its class and is only a few pennies, US, more than the next lower chip.

For random numbers, I knew of a guy who wrote a program that tracked all the displayed numbers. He then averaged the times each number came up and somehow increased the possibility the other numbers would show until the averages were more balanced. His client seemed to be happy with it but I don't know if I could ever replicate that approach. I've often been told there are not truly random numbers in computers. They are predictable unless you muddle them enough.

Good luck on your programming and remember, don't shoot the writer.

Re: electronic dice

Posted: Thu May 16, 2013 6:43 am
by sghioto
avionicsmaster1958 said:

[quote][ I think PicBASIC is easier than PICAXE because it is the basic language where, to me, PICAXE is a lot like C. Which in itself is bad and good. Bad to me as it's a bit harder to learn but I think PICAXE is more efficient and you can pack more bits into a chip/quote]

Not shooting anybody here :mrgreen: but I think you may have these two mixed up. PIC is definitely more powerful and faster then PICAXE because PICAXE has firmware pre-programmed to allow for easier download of programs which does not require a compiler, but is programmed in Basic as well.

Steve G

Re: electronic dice

Posted: Thu May 16, 2013 1:40 pm
by haklesup
"I've often been told there are not truly random numbers in computers. They are predictable unless you muddle them enough."

For example if you just used the RND function in basic, each time you restarted the hardware, you could get the exact same sequence of dice rolls as the last time it was powered on.