Hello there,
I am looking to make a PLC program, to generate random outputs ( about 8 ) for a game. Is there a way a PLC can do it ? Any ideas are appreciated.
Search for what is called a Pseudo-Random Number Generator (PRNG) algorithm. And also look for some control inputs whose timing will be unpredictable, if not random, that can be used to "seed" the PRNG. If nothing else, you can use the low order digits of the clock, captured when a button is pushed.
To implement a PRNG, you need a capable programming language (C, Java, Basic, Perl, etc.) , not just a special PLC relay control code language.
petersonra,
Can you give me some more tips about this? I am using Omron CS1H-H CPU. Thanks for your input.
I am afraid that my knowledge of Omron PLCs is very limited.
There are simple ways to get something that is random enough for most purposes.
what is it you are trying to do?
petersonra
I am thinking of a game called whac -a - mole
Hello there,
I am looking to make a PLC program, to generate random outputs ( about 8 ) for a game. Is there a way a PLC can do it ? Any ideas are appreciated.
The human brain is fairly easily fooled in fact. I once did a program for a "dancing waters" fountain feature where the user wanted a specific routine that played once per hour, but when running in between shows, they wanted a "randomized" set of changes in water flow and squirts and such. I set up a simple 10 step timer function that repeated itself every 5 cycles, people noticed. But once I changed it to 7 cycles, they perceived that to be random... :angel:Notice that even the 'function' that is available at higher than ladder programing languages alludes to PSEUDO Random Number Generator. Whenever a formula is used, and it is used repeatedly, it can no longer be random, just gives the appearence of randomness as most human brains can not detect the repetition. Just like in cryptography, there is a 'key'.
Can you give me some more tips about this? I am using Omron CS1H-H CPU. Thanks for your input.
Aside from that, the suggestion of using the lower digits of the clock is probably going to be your best bet. The randomness would come in via the random delay caused by human interaction.