Connect with us

Strictly Logic Random Number Generator

Discussion in 'General Electronics Discussion' started by Stuart, Jan 24, 2013.

Scroll to continue with content
  1. Stuart

    Stuart

    23
    0
    Jan 24, 2013
    I'm trying to produce a random number generator for an Electronic Roulette Wheel I'm designing using Logic Gates only. The random number generator is to produce a number from 0 to 36 (Standard UK Roulette Wheel, No double 0).

    My only problem is I have no idea where to start, was wondering if any enthusiasts could help point me in the right direction.

    :)

    Stu
     
  2. Harald Kapp

    Harald Kapp Moderator Moderator

    11,513
    2,651
    Nov 17, 2011
    From standard logic you can't produce a true random number generator.
    You can build a pseudo random number generator whose output looks more or less random to the naked eye, but is inherently deterministic, meaning that the sequence of numbers is clearly defined by the mathematical principle behind the generator and will repeat after a time. Here is a description how to use shift registers and logic gates for that purpose.

    You could also use a simple scheme that is used for electronic dice (Google): Build a counter (0...36) that is clocked by a fast clock. Add a gate so the counter will run only as long as (for example) a button is pressed. Once the croupier releases the button, the counter stops and displays the number. Since no two presses of the button will take exactly the same time, the number displayed is approximately random.
    To improve this, you may add a timer (monoflop) that forces the gated clock to last for a certain minimum of time.
    You might also make that time variable by adding a simple pseudo random generator to the timing gate.

    Here is some information on "true random number generator hardware". This, however, may be cracking a nut with a sledgehammer.

    Since after the counter you will need additional logic to decode and display the number, you may want to consider using a simple microcontroller and implement all the necesssary algorithms in software.
     
    Last edited: Jan 24, 2013
  3. Stuart

    Stuart

    23
    0
    Jan 24, 2013
    Thank You

    Thank you for your reply, I really appreciate it.

    I'm relatively new to the world of Electronics and am trying to improve my understanding by undertaking this task.

    I wasn't 100% sure if it were even possible to produce a random number generator with strictly logic gates but I assumed it could be done (there you go you learn something new everyday.)

    You have certainly pointed me in the right direction and I think I should be able to start working on it now.

    Thanks again,

    Stu
     
  4. JimW

    JimW

    59
    5
    Oct 22, 2010
    Harold is right, except that there is another factor involved in what you are doing: the human involved. And this will allow you to make a essentially perfect random number generator. The human is going to push a button to start the roulette ball rolling. So there is a random length of time from the last time it was pushed. If you had a high speed counter that counted up to 36 and then started over, then the count from when the previous number was latched, and the next time the "start" button was pressed would be (for all intents and purposes) random. No human could control to the microsecond when to push the button, so each roll would be random. Not good enough for a casino, but easily good enough for a game or toy.

    If you wanted something closer to pure random, use the human invoked time delay to be a seed for a microprocessor random number generator program.

    -Jim
     
  5. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,496
    2,837
    Jan 21, 2010
    Yes, I second that. I recall seeing designs based on an oscillator that runs *very* fast when the button is pressed, then is made to slow down until it stops. That oscillator was used (in the example I remember) to clock a LEDs showing a dice pattern, but to expand that for a roulette wheel would seem to be fairly trivial.
     
  6. CocaCola

    CocaCola

    3,635
    5
    Apr 7, 2012
    Some things to consider, external input even if not totally random can increase randomness, including but not limited to human interaction of a button press duration for example...

    Other options include the use of a thermistor, photo diode, photo resistor, or a simple variable resistor circuit based on audio detection levels can all help generate randomness if integrated into say a timer or oscillator circuit to shift speed...

    If you use a micro, may I advise you to a few locations of the EEPROM to store multiple increasing and decreasing values that change with each power up and/or change based on the duration the micro is powered up or a routine is activated and/or are based on and external reference, an analog read of a floating pin actually produces a pretty random value in many instances... Use these ever changing values to seed the internal random routines, using your own equation to derive at the seed, use another equation to generate some new numbers to put in the EEPROM for the next cycle... Doing this for all intents and purposes is random...
     
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

-