Randomly Chosen Output

J

Thread Starter

Johan Stoute

Totally new in PLC's and being a mechanical & process engineer, I would appreciate some information at beginners' level.

Have purchased a Siemens LOGO PLC and I would like to program such that I can randomly choose 1 out of the 4 available outputs (later expand to more outputs, say up to 16) to start one of the 4 fountain solenoid valves.

After this particular fountain ran for a random time, this I know how to do :), the next randomly selected solenoid valve should open (1 out of the other 3) and again run on a random timer.

So the actual question: how to randomly choose one of the outputs?
Siemens LOGO has a lot of build-in functions of which menu I still not understand.

Being a process engineer, it also seems foolish to look for randomly unknown things to happen, but this is meant for kids' fun.

Thanks, Johan
 
The Logo has something called a "random generator". I don't know if you can have more than one "random generator" instruction in a program, but if so then you could combine their inputs or outputs using boolean logic so that whenever any one turns on the others are locked out until it turns off.

 
J

Johan Stoute

Thanks for the quick reply and apologies for the slow delay!

I have been playing with the random generator, but concluded that this can only get me a random time. Still haven't figured out how to get this into a random selection of 4 outputs.

Being a total layman in PLC's it would help to get more detailed instructions/hints?

Thanks again !
 
W

William Sturm

Can you convert this random number to an integer? If so, use the bits of the word to control the outputs. You may be able to compare the time to constant values to generate truth bits. Not much help, I know, but hopefully you get some ideas.

Bill Sturm
Abbeytronics LLC
 
It has been quite a while since I've used a Logo, so I can't write the program for you. However, if you used four Random Generators and interlocked the outputs such that only one output can be on at a time, then you would have a randomly selected output. When another RG turns on, it could turn off any other output and latch itself in until another RG turned on.

As an alternative to the above, you could run four shift registers for a set period of time (shifting as fast as you can) and then look at the results (and then repeat the process). The scan rate and timing won't be consistent, so the result will be somewhat random.
 
C

Curt Wuollet

Imagine 4 bins that cover the range of random numbers you get. Get a random number and test it to see which bin it falls into. So if your random numbers range from 0-1000 for example, your bins which you can test with greater than would range 0-250,251-500 501-750, 751-1000.

With a little logic, if its greater than 750 that's one output. greater than 500 but not greater than 750 is another, greater than 250 but not greater than 500 that's another output and not greater than 250 is the last.

Regards
cww
 
Top