For example, select a random number to be used as a tracking number, every time a scrap part is detected (Which is a random event, picking a random number). But instead of selecting a random number once every second or another preset time, you could program to select a random number each time a random event occurs in the process.
LADDER LOGIC PROGRAM REPEAT CYCLE GENERATOR
Programming Random Number Generator in PLC:Īlso, in this approach, I wanted to keep the program relatively small. Resulting in an exponentially more true random number being selected each time. The approach I took in this PLC programming example is to tap two different timing cycles in the PLC, generate a random number within a certain range for each, then alternate back and forth between the two generators when selecting a random number.
![ladder logic program repeat cycle ladder logic program repeat cycle](https://www.plcacademy.com/wp-content/uploads/2015/06/toggle-flip-flop-single-push-button-on-off.png)
Now the question of ‘How to generate random number in a PLC program on a PLC with no random instruction or function?’, has been answered here. So, I decided to not only answer the question in more detail, but provide example logic, a live video of it working, and this article to explain further. The correct answer given was “Use two independent timing cycles in PLC”. After checking the top 3 PLC discussion boards, I found it had been asked a lot, but only one person had ever answered correctly, and he did not give details or an example. My first thought was this must have been asked and answered many times over the years in the main PLC discussion groups.
LADDER LOGIC PROGRAM REPEAT CYCLE HOW TO
I was asked how to create a random number in an Allen Bradley/Rockwell legacy PLC (SLC 500). The PLC example is also universal with all brands of PLCs after you make necessary address changes for your particular brand and model of PLC. (Exponentially more random) There is an added feature too, random number range selection. This particular example is PLC ladder logic needed to generate a truer random number. This PLC programming example is how to program in ladder logic, the logic to generate a random number in PLCs that do not have an RND function built-in. Truer PLC Exponential Random Number Generator:
![ladder logic program repeat cycle ladder logic program repeat cycle](http://d2vlcm61l7u1fs.cloudfront.net/media%2F449%2F449705dd-5d1b-4f3e-a545-6706f5d95787%2Fphp234JVZ.png)
Autonomous Maintenance Training Program.Constructor Electrical Circuit Simulator.
![ladder logic program repeat cycle ladder logic program repeat cycle](https://ladderlogicworld.com/wp-content/uploads/2020/10/6_LadderLogicProgramming_FeatureImage.jpg)
Fluid Power Training Certificate Course.Mechanical Power Transmission Training Course.Online Electrical Troubleshooting Simulator.