Introduction
A count-down counter helps track how many times something happens by counting down from a set number to zero.
CTD(counter_name, preset_value, current_value, input_signal)
CTD(Counter1, 10, CV1, Input1)CTD(CountDown, 5, CV, StartButton)VAR CountDown: INT := 10; InputSignal: BOOL := FALSE; i: INT; END_VAR // Simulate input signal turning TRUE 3 times FOR i := 1 TO 3 DO InputSignal := TRUE; IF InputSignal THEN IF CountDown > 0 THEN CountDown := CountDown - 1; END_IF; END_IF; InputSignal := FALSE; END_FOR // Output the current count WriteLn('CountDown value: ' + INT_TO_STRING(CountDown));
CTD1 with a preset value of 10 in a typical PLC program?CTD1.PRE := 10; uses CTD1.PRE := 10; which is correct syntax. Others use incorrect property names or assignment operators.Pass the test and this pattern moves unknown