Random Generator

Discussion in 'The Projects Forum' started by aman92, Mar 19, 2013.

  1. aman92

    Thread Starter Member

    Aug 22, 2012
    33
    0
    Basically I am doing a project which interfaces 7 segment displays with the 8085 microprocessor. I need to display some random values on the 7 segment displays and process them to produce some results.

    So what is the best way for a relative newbie like me to achieve this.
    I know about LFSR's but any other method?
     
  2. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    2,795
    830
    Can you press a button for each random number? Or perhaps drive a relay... I used swicth bounce in the past as a method of generating random numbers for a display. One time you don't want to debounce that cheep RS pushbutton.
     
  3. antonv

    Member

    Nov 27, 2012
    149
    27
    Or run a 555 timer as a clock to a counter with the micro. Since the timer is not synchronized to the microprocessor clock things should be pretty ramdom.
     
  4. DickCappels

    Moderator

    Aug 21, 2008
    2,647
    632
    Or an analog noise generator and an A/D converter or an analog noise generator, a comparator connected to a counter and timer (frequency meter).

    Some other ideas are at the link below.
    http://lmgtfy.com/?q=pn+genator+circuit
     
  5. aman92

    Thread Starter Member

    Aug 22, 2012
    33
    0
    I just need to find out the most conveninet way to achieve this.....from what you have told me LFSR's still seem the easiest to implement
     
  6. edwardholmes91

    Member

    Feb 25, 2013
    181
    18
    Using a switch without debounce is good... or you could use a 555 astable circuit and when you press the button it will cycle through values really quickly until you let go?
     
  7. aman92

    Thread Starter Member

    Aug 22, 2012
    33
    0
    The thing is my project involves generating random numbers and displaying them in three 7 segment displays and then process the numbers to generate winnings , kind of a slot machine. I need the the best way to achieve than using 8085
     
  8. mitko89

    Member

    Sep 20, 2012
    123
    19
    If you have ADC on the 8051 you can use the LSB, do 8 samplings with shifting to get a byte. Rest is just a lookup table.
     
  9. aman92

    Thread Starter Member

    Aug 22, 2012
    33
    0
    The Timer method seems interesting but won't it become too complex with 8085 since I need to implement random nos in three different 7 segments
     
  10. WBahn

    Moderator

    Mar 31, 2012
    17,715
    4,788
    Now you have competing specs. First you wanted the "most convenient" way to generate some randome numbers for a display, and now you want "the best way" to generate random numbers for a "kind of a" slot machine. These are two very different requirements. Which is more important for what you are doing?
     
  11. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    I agree! The OP should define the exact specs. How many random numbers need to be generated at one time? How many are displayed? How many digits is each number? What is the range of randomness (0-X) for each number? etc.
     
  12. WBahn

    Moderator

    Mar 31, 2012
    17,715
    4,788
    And how important is it that someone that knows the exact implementation of the random number generator and all of the random numbers it has generated since last reset not be able to predict the next random number?
     
  13. aman92

    Thread Starter Member

    Aug 22, 2012
    33
    0
    Ok to clear few things up-
    1. I am implementing a game( a bit like slot machine) where I need to generate three random numbers at the same time using an 8085 and display them on a 7 segmented display
    2. The exact implementation of the random nos need not be known to the user, just that the numbers are fairly random

    3. I need the most convenient way to achieve this( need not be the most ideal way) since generating random numbers is just the first step of the project. I need to process the values to generate 'winnings' and show them on a LCD display.
     
  14. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    OK, so trying to understand that (and since you still have not given all the info), I'm going to guess;
    1. it is a "slot machine", with three single digits?
    2. And the three "random numbers" are each in the range 0-9?

    You can do it the same way a real slot machine used to do it, when someone presses the button you "roll" all the 3 numbers by counting from 000 to 999 really fast (many thousands of times a second).

    Then when they release the button it stops the count, and is fixed on a number "randomly" in the range 000 to 999.
     
    absf likes this.
  15. aman92

    Thread Starter Member

    Aug 22, 2012
    33
    0
    That could work but won't the three 7 segments display the same number then?Unless I create a button for each display separately to stop
     
  16. Ron H

    AAC Fanatic!

    Apr 14, 2005
    7,050
    656
    Or, just leave the high speed 000-999 counter running continuously, and sample it each time the button is pressed. This could be a problem if the unit is battery powered.
     
    absf likes this.
  17. WBahn

    Moderator

    Mar 31, 2012
    17,715
    4,788
    The counter is running from 000 to 999. Let's say it stops at 385. You display 3 on the first digit, 8 on the second, and 5 on the third.

    Note that this method has pretty weak security (which is why they "used" to do it this way). This is probably acceptable for your purposes, though. But you might talk about ways to improve it. In general, the longer it runs the less predicatble it will be. If possible, start it as part of something the user has no control over. You can also have it so that the oscillator frequency changes with each play. If you have a mechanical component, such as a slot machine arm, you can have the arm rotate a pot that varies the frequency and if the counter is already running then the amount the counter counts is not only a function of the initial and final values of the oscillator, but also the exact manner in which the arm was pulled. Lots of games you can play, some of them simple and weak and others complex and maybe strong (but maybe still weak).
     
  18. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    You could also improve security by having three separate oscillators (at slightly different speeds) for the 3 digits.

    You run the three oscillators (counters) very fast when the button is pressed, then just stop all three when the button is released. If they count at many thousands of times per second no human will be able to influence the result by pressing the button.
     
  19. aman92

    Thread Starter Member

    Aug 22, 2012
    33
    0
    what problem exactly?
     
  20. Ron H

    AAC Fanatic!

    Apr 14, 2005
    7,050
    656
    I just meant that, if your unit is battery powered, you could possibly have it off, or in sleep mode, until the button is pressed. Thinking more about it, though, a free-running oscillator doesn't require much power. Your display will be the item that requires the most power.
     
Loading...