Counter – IL
The IEC 61131 standard offers a definition of Counters. PLC3000 integrates up and down Counters. It is necessary to define a preselection value %Ci.PV, which can be set with an integer value. The current value of a counter is set to 0 when %Ci.R is activated. The current value of a counter is set to the preselection value %Ci.PV, when %Ci.LD is activated. The current value of a counter is incremented each time the %Ci.CU input is activated, and decremented each time the %Ci.CD input is activated.
A counter has two outputs; %Ci.QU goes to 1 when the current counter value is equal to or higher than the preselected value %Ci.PV; %Ci.QD goes to 1 when the current counter value is equal to 0.
Generation in IL
Let’s consider a counter %C1 with 5 as preselected value
LD %S1 %C1.PV := 5
Illustration with a Grafcet
Let’s consider the following Grafcet
Programming in IL – Transition/Transition with Crossing Bits
* TIMER LD %S1 %C0.PV := 5 * INIT LD %S2 S %M0 R %M1 R %M2 * FRONT M LD %I1 ANDN %M3 ST %M4 * LD %I1 ST %M3 * TRANSITIONS LD %M0 AND %I0 ST %M10 * LD %M1 AND %IM4 ST %M11 * LD %M2 ANDN %C0.QU ST %M12 * LD %M2 AND %C0.QU ST %M13 * CROSSING LD %M10 S %M1 R %M0 * LD %M11 S %M2 R %M1 * LD %M12 S %M1 R %M2 * LD %M13 S %M0 R %M2 * ACTIONS LD %M0 ST %C0.R * LD %M2 ST %C0.CU