Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

random element on ladder programming

Status
Not open for further replies.

kounoupis

Electrical
Mar 21, 2006
7
0
0
GR
I 'd like to know if we can use a random function on ladder programming
For example, if we have -lets say- 12 memories (M1, M2...M12), can we activate/deactivate randomly?

thanks a lot
 
Replies continue below

Recommended for you

kounoupis

Im not entirely sure what you mean but if you have say "12 memories" or data memory areas, then each particular memory will contain a piece of information which may or may not change like if you are monitoring an analouge input it will change. When you say activate or deactivate randomly im not sure what you are trying to achieve? As each of the twelve areas maybe used in twelve different circumstances. If you can be a bit more specific then maybe i or others could help.

Regards

Taggy
 
ok well i guess you mean you just want to randomly switch your twelve outputs on and off. Personally im unaware of function that would do this well on PLC's i use, but the easiest way (From my known knowledge anyway)would be to write some code that would switch different outputs on and off for a cycle then on then when this small routine is complete begin another which switches them on and off in a different order and different times say. All depends how random you want it to be i suppose. Hope this makes sense?

Taggy
 
Yes it does. I already thought of this, but I want them to be really random and not just some routines
Can you tell me the function your PLC uses?
I use Microsmart PLC. Maybe it swiches :/
 
Just had a quick look through our manuals and software for the PLC's i use and i can not see a function that would do this' which i did expect to be honest. Sorry i cant be of any help and keep us informed of anything you do find.
 
A common way to generate random numbers in a PLC is to use a time value, either a free running timer value or a system clock.
With a timer, each time the PLC program scans the logic it should see a different accumulated time, since the program scan and the timer typically run asynchronous.
If you have a system clock, you could just look at the current seconds or milliseconds value, each time the program scans the rung. Again, if the clock and program scan are asynchronous, you should get a different value on each program scan.
 
in c programming, there is a rand() function that generates a pseudo-random number. but each time the function is called, it generates the same sequence. in order to generate truly random numbers, there is a function called srand() that uses time as the base for generating the numbers.

i would look up the source code for those functions to see if it could be translated into ladder logic.
 
Status
Not open for further replies.
Back
Top