Multiple Programs
Sometimes, multiple programs are needed to perform different functions at different intervals within a project. Here's a simple demonstration:
- Similar to the ladder diagram program in section Single Program,
create a program Part_trig to get an input signal and trigger another
program:Note:
trig is a variable that triggers another program and needs to be defined as External in this program and declared as Global in Res0:
- Then, create another program that is triggered by program ‘Part_trig’. Programs in different languages can be in the same project, so a new POU using FBD(Function block diagram) can be created in this project:
- To run this program, an instance should be declared for it in the Res.0:
- Moreover, if programs need to run at different intervals, a new task should be created and bound to corresponding instance:
As shown above, program ‘part_trig’ will run at 20ms intervals while program ‘part_triggered’ on 10ms. It should be mentioned that the program may not be able to run on this interval. The minimum interval of the program depends on the real-time performance of the system.