Connect with us

Random 0/1 generation?

Discussion in 'Electronic Design' started by Chaos Master, Oct 16, 2003.

Scroll to continue with content
  1. Chaos Master

    Chaos Master Guest


    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?

  2. Mike

    Mike Guest

    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 --
  3. 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.

  4. Andre

    Andre Guest

    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 ?
  5. Mike

    Mike Guest

    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 --
  6. Rob

    Rob Guest

    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.
  7. Chris

    Chris Guest

    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.
  8. JeffM

    JeffM Guest

    google on "electronic coin toss" (without quotes)
    or, even better, with quotes.
  9. Chaos Master

    Chaos Master Guest

    Rob engraved with a +2 athame:
    Could you please send me the schematic for your solution?

    - please apply ROT13 to discover a valid e-mail.
  10. Chaos Master

    Chaos Master Guest

    Chris engraved with a +2 athame:

    [snip the solution for a random 0/1 generator]
    Thanks for help from everybody.
    Thanks for pointing me to S.E.B.
  11. You're right. The register runs properly with FFFFFF as start value
    and stays still with 000000.
  12. Wim Ton

    Wim Ton Guest

    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.

  13. John Fields

    John Fields Guest

  14. Joe Legris

    Joe Legris Guest

    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
  15. John Fields

    John Fields Guest

  16. Interesting statement.
  17. N. Thornton

    N. Thornton Guest

    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

    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.
  18. Wim Ton

    Wim Ton Guest

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

Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day