Jouke already told you that WHILE
is the reason. Here is your code example refactored. This is how it should be done if you want 100 milliseconds impulse work.
timer(IN := TRUE, PT := T#100MS);
IF timer.Q THEN
calculate();
timer(IN := FALSE); // reset timer
END_IF;
But remember that your main PLC cycle should not be longer than 100ms.
The object will be a PID controller. And I want in the main program just call the start method when I want it to regulate and stop when I need it to shut down.
Every PID function block has Enable
input parameter. You can use that to start and stop PID.
Just set you Start
variable to PID function block input, that is it.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…