IEC_COUNTEREUCOUNTERUSIEC_COUNTERCOUNTER Counter
Also called: counter, IEC_COUNTER, counter structure
A counter's memory: one variable per counter.
What it does
You declare a counter variable (C1, Parts…) and give it to a CTU, CTD or CTUD instruction. The instruction decides whether it counts up, down or both; the variable holds the preset, the current value and the status bits.
When to use it
Counting parts, cycles or presses, then acting when the preset is reached.
Instance members
Each instance has its own memory, readable anywhere in the program, for example C1.Q / C1.DN.Each instance has its own memory, readable anywhere in the program, for example C1.Q.Each instance has its own memory, readable anywhere in the program, for example C1.DN.
| European mnemonic | American mnemonic | Name | Data type | Access | In |
|---|---|---|---|---|---|
| .CU | .CU | Count up | BOOL | Read | CTU, CTUD |
| .R | — | Reset | BOOL | Read | CTU, CTUD |
| .PV | .PRE | Preset | DINT | Read and write | CTU, CTD, CTUD |
| .Q | .DN | Done | BOOL | Read | CTU, CTD |
| .CV | .ACC | Accumulator: current value | DINT | Read and write | CTU, CTD, CTUD |
| — | .OV | Overflow | BOOL | Read | CTU, CTD |
| — | .UN | Underflow | BOOL | Read | CTU, CTD |
| .CD | .CD | Count down | BOOL | Read | CTD, CTUD |
| .LD | — | Load | BOOL | Read | CTD, CTUD |
| .QU | .DN | Preset reached (done) | BOOL | Read | CTD, CTUD, CTU |
| .QD | — | Zero reached | BOOL | Read | CTUD |
| Mnemonic | Name | Data type | Access | In |
|---|---|---|---|---|
| .CU | Count up | BOOL | Read | CTU, CTUD |
| .R | Reset | BOOL | Read | CTU, CTUD |
| .PV | Preset | DINT | Read and write | CTU, CTD, CTUD |
| .Q | Done | BOOL | Read | CTU, CTD |
| .CV | Accumulator: current value | DINT | Read and write | CTU, CTD, CTUD |
| .CD | Count down | BOOL | Read | CTD, CTUD |
| .LD | Load | BOOL | Read | CTD, CTUD |
| .QU | Preset reached (done) | BOOL | Read | CTD, CTUD |
| .QD | Zero reached | BOOL | Read | CTUD |
| Mnemonic | Name | Data type | Access | In |
|---|---|---|---|---|
| .CU | Count up | BOOL | Read | CTU |
| .PRE | Preset | DINT | Read and write | CTU, CTD |
| .DN | Done | BOOL | Read | CTU, CTD |
| .ACC | Accumulator: current value | DINT | Read and write | CTU, CTD |
| .OV | Overflow | BOOL | Read | CTU, CTD |
| .UN | Underflow | BOOL | Read | CTU, CTD |
| .CD | Count down | BOOL | Read | CTD |
Behaviour in detail
- One counter variable can serve any counting instruction.
- The current value is a DINT: it stops at −2,147,483,648 and 2,147,483,647 (in the American style UN and OV say so).
- RES (or the R input) sets the current value back to 0.
European (IEC) and American styles
European: IEC_COUNTER type, members PV, CV, CU, CD, Q / QU / QD.
American: COUNTER type, members .PRE, .ACC (DINT), .CU, .CD, .DN, .OV, .UN.