random sequance

OK, now I get it. You are looking for "shuffle" logic to re-order 12 different "cards".

One possible method:

Start with a set of 12 registers containing the numbers 1 through 12 in some order ("OLD ORDER"), and a second set of 12 registers that are empty (NEW ORDER).

After having run through the sequence, generate a random number between 0 and 4095 (i.e, 2[super]12[/super]). Seqence through the bit pattern of the random number. If the first bit is set, move the first number in the OLD ORDER stack to the top of NEW ORDER stack. If the random number bit is not set, do nothing. If the second bit is set, move the second number in the OLD ORDER to the NEW ORDER, and so on.

Once all 12 bits have been checked, repeat the proccess, checking to see of the random number bit is NOT set. At the end, you will have 12 unique numbers in NEW ORDER, but in a different order than in OLD ORDER.

Block move all of NEW ORDER into OLD ORDER. Repeat the "shuffle" process, generating a new random number, until the START button is pressed again. The START button runs whatever sequence happens to be present in the OLD ORDER.

This logic would word best with for-next looping and indirect addressing, or pointer functions, but could be hard-coded if needed.
 
YOU CAN TRY THIS ONE.
RUN A CONTINUES RUNNING TIMER SET AT 12 AT HIGH SPEED AND SET TWELVE REGISTERS TO INITIAL VALUES OF ZERO, ONCE THE PB BUTTON IS PRESSED,SET A BIT SOMEWHERE, AND COMPARE THE COUNTER VALUE TO VALUES OF THE REGISTERS ONE BY ONE, IF IT EQUALS ONE OF THEM INCREMENT IT UNTIL NO MATCH IS FOUND THEN SEND IT TO THE OUTPUT AND TO ONE OF THE 12 REGISTERS -DO THIS WHILE THE BIT IS STILL SET AND WHEN FINISHED, RESET THE BIT. WHEN ALL 12 OUTPUTS AND 12 REGISTERS ARE USED ALREADY RESET ALL REGISTERS AND DO THE CYCLE AGAIN.
THE CYCLE OF A PLC IS USSUALLY FAST THAT 12 COMPARATION ISN'T FAST ENOUGH TO GET AN ATTENTION.
 
Last edited:

Similar Topics

Looking for some advice for backing up the programs on a bunch of old random PLCs. All I'm really concerned about is getting the program out of...
Replies
43
Views
4,738
We have several Powerflex 4M (22F-D013N114) VFD’s controlled by compactlogix PLC’s. Control is simple, a run and direction signal with the speed...
Replies
6
Views
1,542
Hi all, I know this is a PLC forum, but I know there is a gread deal of knowlege on drives as well. This drive has been running on stone...
Replies
2
Views
896
Hey folks, I was just wondering what thoughts were about a completely 100% random number generator. I looked on The Google but didn't really open...
Replies
54
Views
16,584
Hello Friends I need to activate random outputs (0-9) and ask for random inputs (0-9). I have created in s71200 a program to generate a random...
Replies
13
Views
4,743
Back
Top Bottom