random sequance

hesham

Member
Join Date
Jan 2003
Location
cairo
Posts
328
Sir's
Can any one help in this task.
For Some trining purposes for ubnormal chields (Mangholian)
we need to use a plc with 12 output .This Output will goes on(for a time) in a random sequance when the trainer press the start button (One time will be applied to all the 12 O/p's).Only one O/P will be on at a time for example the 2nd output of the sequance will not go on untill the 1st on goes off.
Last year i was asked to do it for 3 O/P it was very simple to include the 6 possible combination in my ladder.Then i asked to do it for 6 O/p so i include only 12 of 720 combination in my ladder.
Now they ask for 12 (it is 12! combination) for me it's impossible to only write combinations). I really need a new idea or some one suggest a usuful PLC instruction .
In my last two programs i implement it by grafset for Mitsubishi FX2N
And Step controllers for LG Industrial System Product(K80S-series)
Thanks In advance
 
Does your PLC have an increment command? I have used @INC in Omron PLCs as a free running timer with a 0.02 pulse as the input. Use this value as the timer input. Use 2 timers - on time and off time - and when the on timer times out move the data to the off timer as the value etc etc. Gives a very random pattern. If you keep the timers short, you can for example, reset the channel to 0000 every time the channel reaches 1234. Works like a charm if you program it right. You can expand to use as many channels as you like and use different internal pulses to increase the randomness. Is that a word? Oh well I guess it describes what I mean.
:eek:
This pattern is not random.
 
Along the same lines:
If your PLC has a word which represents the value of scan time, you can use this to seed a number generator. Include some heavy duty math in your program triggered by a clock pulse and watch the scan time really jump around!
 
I already posted a procedure to compute a random number. It was derived from the Basic interpreter from the old Sinclair ZX Spectrum homecomputer. Go to the thread Is there or should there be a RND instruction by Goody and scroll down.

Good luck

Jean Pierre Vandecandelaere

BTW A search on this forum for the word "random" would have gotten you there as well!
 
jvdcande said:
Go to the thread.....and scroll down

I think this tip has been mentioned before, but you might have missed it...

Notice the "Post #" link at the top right of each post. If you use this URL in your link, it will link directly to the post you want.

For example, clicking HERE will link directly to YOUR post in that thread... :cool:

Phil makes our life VERY easy around here!... :D

beerchug

-Eric
 
Thanks for all the repliers
BoBb
Acually your method is not clear for me.would you please clearify.

jvdcande
i read the thraed which you recomend but it talks about generating a random number not a random sequance for 12 output.unless if there is a method to generate this pattern from this random number.
Eric
you didn't give your opinion
thanks
is there any more clearification for my description?. :unsure:
 
Is my math correct?

With 12 outputs there would be a total of 8916100448256 combinations for the sequences. 12 to the 12th power..correct?

Thats alot of numbers to play with. Why not just use jvdcande's number generation (or any method for number generation) to get the numbers between 1 and 12 then place them in the output table as they come up. I would think that to make this work each number generated would have to be removed from the generator or ignored if brought up again.

I have another thought but not sure how to do this exactly. You create batch or sequenced files that you use the number generator to call...ie number generator comes up with 8 then it starts sequencer file 8. That was a simplistic example but maybe you see what I am saying.

I think it may help to state what plc you are using then more specific assistance could be given. I have worked around many machines where "batch" files were created because different products were made on the same line. Seems you could create X amount of "batch" files then use the number generator to call one. The "batch" file would then provide a sequence, since it could be setup never to repeat the same "batch" it could have the appearance of randomness (yes that is a word).

IF I get time I may play around with this.
 
Thanks RS
Actually it's 12! combination(12x11x10x....x1=479001600 combinations.
First
I tried to generate a random number between 1 & 12 using a counter activated internally by a built in clock function .because the system is activated once by pressing a PB i take a snap shot for the value in the counter when the user push the start PB moving this value to a register and then using the Decode instuction to decode this value will set a certin Bit for example if the number 8 is moved to register d0 then we decode the word D0 into word M1 so we will get bit m18 on.by this we have two problem
1- the system as is mentioned is activeted once by a PB running continuosly to out all the 12 output then stop.so i need to move the value in the counter each time the activated output if off.
2-the major one is that repeation.may be the same value is transfered again to the register cause an output to goes on again in the same sequance which is not allowed. banghead
Second
if i try to create a sequance files i will need 12! files .as you see above it's 12! files. bawling

third
I am using Mitsubishi Fx2N series or if you suggest a brand to do this task i will switch to. 🔨
thanks
 
Use the routine that Jean-Pierre cited to generate a random integer between 1 and 12. Use that integer as an index to turn on an output (if the RND function generates a 6, turn on the sixth output). If the light has already been turned on once during the current sequence, generate another random number and try again.

One potential drawback would be that as you get closer to the end of the sequence, it will take longer to select from the remaining outputs. You'll probably need to test it to see if that causes a problem.
 
Let's step back a moment. Just how "random" do you need this to be? And does the thing have to keep the "sequence"?

Your concern about 12! combinations implies that when a light comes on, it doesn't come on again until ALL other lights have come on (within a group of 12). Is this a requirement?

Or do you not really care which light comes on next, as long as it is different from what's currently on?

Does it need to be truly random, or just enough to look like it is to a not-very-observant audience? Have you ever watched the "random" blinking lights in 1960's bad Sci-Fi movies? The pattern repeats fairly often.

I suspect that if you were program a series of 100 "arbitrary" (not random) numbers, no one would notice.

But it sounds like you were on the right track. Here's a quick fix to your problems:
Problem 1 - Sequnce only works with PB. Seperate the sequences from the outputs. Have the "random" sequence drive internal bit only. The internal bits go on-and-off, all the time, but they don't drive the outputs until another internal coil driven by the START button is energized.

Problem 2 - Randomizer sometimes comes up with the same value twice in a row You know the number of bulb currently on = the last random number used, right? Instead of creating a random number 1 to 12 (or 0 to 11), generate a number 1 to 11. If the new number is greater than equal to the old number, add one to it. If the resulting number is greater than 12, make it 1. Move the new number to the old number register. The old number register is decoded to drive the internal coil.
 
Your concern about 12! combinations implies that when a light comes on, it doesn't come on again until ALL other lights have come on (within a group of 12). Is this a requirement?

Thats 100% true

Problem 2 - Randomizer sometimes comes up with the same value twice in a row You know the number of bulb currently on = the last random number used, right? Instead of creating a random number 1 to 12 (or 0 to 11), generate a number 1 to 11. If the new number is greater than equal to the old number, add one to it. If the resulting number is greater than 12, make it 1. Move the new number to the old number register. The old number register is decoded to drive the internal coil.

I think this will not going to work because for example the 1st RND o/p is #6 the 2nd is #3 (till here no problem) but if the 3rd is #5
then i will added 1 so it becomes #6 again(refused)

Folks
Let me explain mor details about the system
Each O/p will be wired to a solonoied to let a certin picture appear for a pre-determined time (T sec).The Mangholian child should identify what is this picture for within (T) then it disapear and another picture appear and so on
The operation will be as follow:
1- Press the PB
2-1st RND O/p(may be #12) goes on fot T sec
3-after T 1st Rnd O/p goes off-2nd RND O/p goes On
4-After T 2nd RND o/p goes off-3rd foes on
.
.
.
.
finally after T 12th RND O/p(may be #1)goes off and the system stop.
The start Again must show another sequance for the chield
I hope that this makes the system more clear.
Thanks to all those showing assistance
 
I don't know how much programming is possible is a plc as a c-man but,

if you take a 16 bit word in the memory of the plc, like MW X, and u send each off the seperate bits randomly chosen to a set of exor ports like in the picture, then modulo 2 adding the result of those exor ports , moving this into the left upper bit of MW X (Now is the time for reading the word) and then just move each seperate bit one place to the right (trowing the most right one away). this should give a pseudo-random 16 bit word. If you need for example only 6 bit ( from 0 to 31 ) you can move again 6 randomly chosen bits to the right most bits of an 8 bit word. But the shifter should be at least 16 bit long. Ofcoarse you wil have to load the word in the beginning with a random number .

I think i may work ... or not ?

http://home.pi.be/~cverheye/crooked/radomgenerator.gif
 
hesham, you do not mention the PLC brand or type you are working with. Do you have Omron Syswin or Cx-Programmer? If so I will send you some ladder to play with.
:eek:
 
bitske
thx i will try it and let you know

BobB
I am using Mitsubishi Fx2N With Gx developer S/w. but i have also syswin installed in my lap-Top.

RS
Thanks for the site .🤷 it may also help in any thing .
 

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,674
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,515
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
879
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,512
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,668
Back
Top Bottom