Maker Pro
Maker Pro

Random PICAXE Output for 4026

Louis Bates

Oct 21, 2014
19
Joined
Oct 21, 2014
Messages
19
Hello!

I am using a 4026 decade counter and I was wondering if you can use a PICAXE 08M or 08M2 to act as a clock producing a random output.

I need to limit this random number to 36 too

Thanks :)
 

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
You want your roulette wheel to use seven-segment LED displays?

Yes you could do that. You would need two control signals. One to reset all of the 4026es, and one to clock the first one, with the others cascaded from that. The PICAXE would reset them to start the count at zero, then clock them until the count reached 36, and then on the 37th clock, issue a reset instead, so you get a continuous sequence of 0~36 (I assume that's what a roulette wheel has?)
 

Colin Mitchell

Aug 31, 2014
1,416
Joined
Aug 31, 2014
Messages
1,416
To get a random number, produce a 36 table of numbers in random order and reproduce it 3 times and pick down the table, starting at a random point.
This is the sort of thing if you want a random LOTTO number selector.
 

Gryd3

Jun 25, 2014
4,098
Joined
Jun 25, 2014
Messages
4,098
To get a random number, produce a 36 table of numbers in random order and reproduce it 3 times and pick down the table, starting at a random point.
This is the sort of thing if you want a random LOTTO number selector.
That would still be pseudo-random. If this has any kind of currency associated with it, you will need additional hardware to help generate a truly random number. You can't rely on software, as software is merely mathematical equations.
Some OSes rely on internal voltages, timers, and clocks to help produce a seed for the random function which will be very difficult to control or predict resulting in more of a random number than relying on code alone.
 

Colin Mitchell

Aug 31, 2014
1,416
Joined
Aug 31, 2014
Messages
1,416
For the gaming machines we produce, every number must be produced out of a sequence, so 3 sequences are produced and the numbers are picked randomly and crossed off the list.
It depends on how often you want the numbers to balance.
 

Gryd3

Jun 25, 2014
4,098
Joined
Jun 25, 2014
Messages
4,098
For the gaming machines we produce, every number must be produced out of a sequence, so 3 sequences are produced and the numbers are picked randomly and crossed off the list.
It depends on how often you want the numbers to balance.
Can you elaborate?
Is the list a set of non-contiguous numbers? What do you mean 'balance'?
Sounds like it would be easier to just generate the random number than to randomly pick one from a list. The resulting pattern would be the same, just with a different set of numbers.
When you say 'random' are you referring to the function within a microcontroller, or a random external influence?
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
On simple way of getting a pretty random number is to use one of the many random number generators (the one inside the picaxe is fine. But the trick is to keep getting random numbers during a random event.

If your device requires a person press a button to start the roulette wheel, then keep getting random numbers while the button is down. If your code is fast enough it will be impossible to press it the same time twice and hence impossible to predict the number generated.
 

Gryd3

Jun 25, 2014
4,098
Joined
Jun 25, 2014
Messages
4,098
On simple way of getting a pretty random number is to use one of the many random number generators (the one inside the picaxe is fine. But the trick is to keep getting random numbers during a random event.

If your device requires a person press a button to start the roulette wheel, then keep getting random numbers while the button is down. If your code is fast enough it will be impossible to press it the same time twice and hence impossible to predict the number generated.
Yes, good call! Random external influence. The button would not simply pick the next number in series, but would continually roll the numbers until released. Worst case is that a user may be able to predict from a smaller subset of numbers if the hardware and source were somehow acquired.
 

Colin Mitchell

Aug 31, 2014
1,416
Joined
Aug 31, 2014
Messages
1,416
If you are required to pick every number out of 40, as you are with LUCKY NUMBER ENVELOPES, you need a random list to pick from and keep track of the numbers picked.
You haven't stated your requirements.
 

Louis Bates

Oct 21, 2014
19
Joined
Oct 21, 2014
Messages
19
On simple way of getting a pretty random number is to use one of the many random number generators (the one inside the picaxe is fine. But the trick is to keep getting random numbers during a random event.

If your device requires a person press a button to start the roulette wheel, then keep getting random numbers while the button is down. If your code is fast enough it will be impossible to press it the same time twice and hence impossible to predict the number generated.

Thank you I will try this. :)
 
Top