TON function block function:When the input is high, the timer starts timing. CV represents the current
value of the timer, while PV is the target value of the timer. When the value of CV equals the value of
PV, the outputis set to 1.
Press F2 at the next place in the main program and add the TON function block.
I named it t1 here
Here, t1_timer and t1_output are bool values, while t1_current is a time value.
Click login and start
Check the running status of the program, as shown in the figure below:The above figure shows
the current situation of t1. We change the value of t1_timer to true, and the result is
It can be seen that when t1_cunrrent=3s, Q is set to 1.
F-TRIG function blockFunction block
function: When the input generates a falling edge, the output will remain at 1 for the next cycle.
Press F2 where the main program continues and add the F-TRIG function block.
I name it TRIG1
Here, trig1_clk and trig1_output are both bool values.Due to the special function of the trigger,
a breakpoint is set at the end of the program to view the program execution result. After the
login procedure, there is a return statement at the end of the program. A breakpoint is set
here, as shown in the figure:
Due to the special function of the trigger, a breakpoint is set at the end of the program to view the
program execution result. After the login procedure, there is a return statement at the end of
the program. A breakpoint is set here, as shown in the figure:
Due to the special function of the trigger, a breakpoint is set at the end of the program to observe the
program execution result. After the login procedure, there is a return statement at the end of the
program. A breakpoint is set here, as shown in the figure:
The word becomes red to indicate that the line where RETURN is currently located is the breakpoint ofthe program. When the program runs, it will stop running when it encounters the breakpoint. After the
program runs, this line will turn yellow and an arrow will appear at the line number in front of it,
indicating that the program is currently staying on this line.
step into in the PLC to achieve single-step execution.
Keep STEP INTO until the following figure appears: At this time, trig1_clk is exactly at the
falling edge, and according to the F-trig function, trig1_output will become true next, as shown in
the figure
After one PLC cycle, it returns to false, so the function block test is complete.