Random Generator

Thread Starter

aman92

Joined Aug 22, 2012
33
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?
 

djsfantasi

Joined Apr 11, 2010
9,155
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.
 

antonv

Joined Nov 27, 2012
148
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.
 

Thread Starter

aman92

Joined Aug 22, 2012
33
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
 

edwardholmes91

Joined Feb 25, 2013
210
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?
 

Thread Starter

aman92

Joined Aug 22, 2012
33
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
 

Thread Starter

aman92

Joined Aug 22, 2012
33
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
 

WBahn

Joined Mar 31, 2012
29,930
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
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
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?
 

THE_RB

Joined Feb 11, 2008
5,438
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.
 

WBahn

Joined Mar 31, 2012
29,930
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?
 

Thread Starter

aman92

Joined Aug 22, 2012
33
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.
 

THE_RB

Joined Feb 11, 2008
5,438
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.
 

Thread Starter

aman92

Joined Aug 22, 2012
33
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
 

Ron H

Joined Apr 14, 2005
7,063
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.
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.
 

WBahn

Joined Mar 31, 2012
29,930
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
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).
 

THE_RB

Joined Feb 11, 2008
5,438
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.
 

Ron H

Joined Apr 14, 2005
7,063
what problem exactly?
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.
 
Top