Maker Pro
Maker Pro

Random 0/1 generation?

C

Chaos Master

Jan 1, 1970
0
Hi!

I want to make a device that randomly generates a 0 or 1(heads/tails). What IC's
could I use? Or a microcontroller is better?

Thanks.
 
M

Mike

Jan 1, 1970
0
Hi!

I want to make a device that randomly generates a 0 or 1(heads/tails). What IC's
could I use? Or a microcontroller is better?

Thanks.

If you want a standalone device, noise diodes and zener diodes are often
used to generate noise. Amplify it up and sample it, and you can get a
virtually random noise source. In the simple digital department, you could
also use a Linear Feedback Shift Register (look for more information at
Xilinx). It's a simple state machine, so it's far from random (if you know
the last N bits out of an N bit LFSR, you can predict all future bits), but
it might be adequate. If someone has to push a button to show the head or
tail, then a simple clock (a few kHz is adequate) and a T flip-flop should
work well enough: stop the flip-flop when the button is pressed, and
display the state. If you use a microcontroller, you could program just
about any algorithm you want to.

-- Mike --
 
J

Jacques Fournier

Jan 1, 1970
0
Hi!

I want to make a device that randomly generates a 0 or 1(heads/tails). What IC's
could I use? Or a microcontroller is better?

Thanks.

You can use a 24-bit shift register (B23 ... B0) where the input =
(B23 XOR B22) XOR (B21 XOR B16)
The output can be any bit of the register. I used B0.
The speed of the bit output is equal to the clock frequency.
Important : before running the register hexa value must be different
of 000000 and different of FFFFFF. I choose 555555.

I used an Atmel AVR Tiny11 microcontroller. Only a few lines of
software is necessary to compute this algorithm.

Jacques
 
A

Andre

Jan 1, 1970
0
Mike said:
If you want a standalone device, noise diodes and zener diodes are often
used to generate noise. Amplify it up and sample it, and you can get a
virtually random noise source. In the simple digital department, you could
also use a Linear Feedback Shift Register (look for more information at
Xilinx). It's a simple state machine, so it's far from random (if you know
the last N bits out of an N bit LFSR, you can predict all future bits), but
it might be adequate. If someone has to push a button to show the head or
tail, then a simple clock (a few kHz is adequate) and a T flip-flop should
work well enough: stop the flip-flop when the button is pressed, and
display the state. If you use a microcontroller, you could program just
about any algorithm you want to.

Use a PIC with more than one output, run four shift registers out of
sync, and then use the outputs of those four to select one of the
random bits stored in a table in the program memory ?
 
M

Mike

Jan 1, 1970
0
You can use a 24-bit shift register (B23 ... B0) where the input =
(B23 XOR B22) XOR (B21 XOR B16)
The output can be any bit of the register. I used B0.
The speed of the bit output is equal to the clock frequency.
Important : before running the register hexa value must be different
of 000000 and different of FFFFFF. I choose 555555.

If you check, you'll find that your shift register contents will equal
FFFFFF at some point. The only value that won't occur is 000000. So, FFFFFF
is a valid starting point.

If you aren't committed to 24 bits, you could save a few gates by
implementing a 23 bit or 25 bit LFSR - they only require a single XOR.

-- Mike --
 
R

Rob

Jan 1, 1970
0
It just so happens that I've put one of these together for a project I
was working on. Generates an output which randomly switches between 0
and 1.
Will send by reply.
Rob
 
C

Chris

Jan 1, 1970
0
Chaos Master said:
Hi!

I want to make a device that randomly generates a 0 or 1(heads/tails). What IC's
could I use? Or a microcontroller is better?

Thanks.

If all you want is a "heads/tails" indicator, set up a 555 as a 100
KHz oscillator. Use a N.O. pushbutton to switch the output into the
clock of a D flip flop set up as a toggle (connect the Q! output to
the data input). Since the pushbutton will always be pressed for a
different amount of time, the Q output of the D FF will be random.
Use the Q and Q! outputs to drive transistors, which drive your
red/green heads/tails LEDs.

Do a google on "electronic coin toss" (without quotes) for several
circuits of this type.

Kits are also available from Ramsey Electronics and most of the other
kit manufacturers for heads/tails projects. Sci.electronics.basics is
a better forum for questions of this type.

Good luck.
Chris
 
C

Chaos Master

Jan 1, 1970
0
Rob engraved with a +2 athame:
It just so happens that I've put one of these together for a project I
was working on. Generates an output which randomly switches between 0
and 1.
Will send by reply.
Rob

Could you please send me the schematic for your solution?

[email protected] - please apply ROT13 to discover a valid e-mail.
 
C

Chaos Master

Jan 1, 1970
0
Chris engraved with a +2 athame:

[snip the solution for a random 0/1 generator]
Do a google on "electronic coin toss" (without quotes) for several
circuits of this type.

Thanks for help from everybody.
Kits are also available from Ramsey Electronics and most of the other
kit manufacturers for heads/tails projects. Sci.electronics.basics is
a better forum for questions of this type.

Thanks for pointing me to S.E.B.
 
J

Jacques Fournier

Jan 1, 1970
0
If you check, you'll find that your shift register contents will equal
FFFFFF at some point. The only value that won't occur is 000000. So, FFFFFF
is a valid starting point.

You're right. The register runs properly with FFFFFF as start value
and stays still with 000000.
 
W

Wim Ton

Jan 1, 1970
0
You can use a 24-bit shift register (B23 ... B0) where the input =

This is not random, but pseudo-random. It has all the properties of a random
signal in distribution of values etc, except that it is totally predictable.

It is fine for stimuli or measurements, but not for security.

Wim
 
J

John Fields

Jan 1, 1970
0
This is not random, but pseudo-random. It has all the properties of a random
signal in distribution of values etc, except that it is totally predictable.
 
J

Joe Legris

Jan 1, 1970
0
There's no skewness - it's a perfectly rectangular distribution. All
2^24 - 1 states occur with equal frequencies. The mean is shifted
slightly from what it would be if all 2^24 states were available, but
that's not the same as skewness, which means asymmetry
 
J

John Fields

Jan 1, 1970
0
There's no skewness - it's a perfectly rectangular distribution. All
2^24 - 1 states occur with equal frequencies. The mean is shifted
slightly from what it would be if all 2^24 states were available, but
that's not the same as skewness, which means asymmetry
 
R

Richard Henry

Jan 1, 1970
0
There's no skewness - it's a perfectly rectangular distribution. All
2^24 - 1 states occur with equal frequencies. The mean is shifted
slightly from what it would be if all 2^24 states were available, but
that's not the same as skewness, which means asymmetry

Interesting statement.
 
N

N. Thornton

Jan 1, 1970
0
Re random 0/1 gen: a single opamp is probably the simplest option. Set
it to oscillate, nd use a push button or an incoming 0/1 to permit
oscillation. Whatever state it settles on when osc stops is your
output.

To control the osc with a logic input, as opposed to a switch, just
put the control in line to the opamp input thru a diode. Vola.

Regards, NT

PS the lower the capacitor stability the better if very predictable
triggering pulses are used. Keep osc freq high relative to trig pulse
length to maintain randomness.
 
W

Wim Ton

Jan 1, 1970
0
N. Thornton said:
Re random 0/1 gen: a single opamp is probably the simplest option. Set
it to oscillate, nd use a push button or an incoming 0/1 to permit
oscillation. Whatever state it settles on when osc stops is your

A common circuit is a ring oscillator with an odd number of invertors, the
seem to be quite noisy.

Wim
 
Top