Counter LD
The IEC 61131 standard offers a definition of Counters. PLC3000 integrates up and down Counters. It is necessary to define a preset 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 preset 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 LD
A Counter and its preset value are defined during the declaration of variables in the Ladder code editor. For example, the counter %C1 with the preset value %C1.PV=10 is defined as:
![](https://plc3000.com/wp-content/uploads/2022/02/Counter_LD.png)
Illustration with a Grafcet
Let’s considering the following Grafcet
![](https://plc3000.com/wp-content/uploads/2021/05/Grafcet3Etats_Compteurs-300x257.jpg)
Programming in LD – Transition/Transition with Crossing Bits
Initialization
![](https://plc3000.com/wp-content/uploads/2022/02/Init_Compteur.png)
Test on Receptivity
![](https://plc3000.com/wp-content/uploads/2022/02/Test_Recept_Compteur.png)
Transition Crossing
![](https://plc3000.com/wp-content/uploads/2022/02/Franchissement_Compteur.png)
Output declaration
![](https://plc3000.com/wp-content/uploads/2022/02/Actions_Compteur.png)