Topic: DMD0033

UDC - Up/Down Counter


The Up/Down Counter (UDC) instruction is a three input counter that counts up and/or down. Each time the UP input logic transitions from OFF to ON the counter structure's accumulator (.Acc) is incremented by one. Each time the DN input logic transitions from OFF to ON the counter structure's accumulator (.Acc) is decremented by one.

 

If the instruction is configured to use an Up Preset, is ON any time the value in the counter structure's accumulator (.Acc) is less than or equal to the Up Preset value.  If the instruction configured to use an Down Preset, is ON any time the value in the counter structure's accumulator (.Acc) is less than or equal to the Down Preset value.

 

Parameters:

Note: Use the F9 key (Element Browser) or Down-Arrow key (Auto-Complete) at any time to see a complete list of the memory locations that are valid in the current field of the instruction.

 

Counter Struct - a counter structure that will be used by this Up/Down Counter instruction. By default, there are 255 pre-defined counter structures, named CT0 through CT255. Refer to the Memory Configuration section of the System Configuration for information on adjusting the number of available counter structures.

 

>= Preset - enable this option and enter the Up Preset count value. The counter structure's .Done BIT will be ON any time the value in the counter structure's accumulator (.Acc) is greater than or equal to the Up Preset value. The Up Preset value can be any 32-bit constant value or any readable numeric location.
 

<= Preset - enable this option and enter the Down Preset count value. The counter structure's .DnDone BIT will be ON any time the value in the counter structure's accumulator (.Acc) is less than or equal to the Down Preset value. The Down Preset value can be any 32-bit constant value or any readable numeric location.

 

Input Legs:

The Up/Down Counter (UDC) has the following three ladder logic inputs:

 

The first input leg (UP) is the Count Up Input. This input is edge-triggered, meaning that each time this input logic transitions from OFF to ON, the value in the counter structure's accumulator (.Acc) will increment by one.

 

The second input leg (DN) is the Count Down Input. This input is edge-triggered, meaning that each time this input logic transitions from OFF to ON, the value in the counter structure's accumulator (.Acc) will decrement by one.

 

The third input leg (RST) is the Counter Reset. When this input logic in ON, the Up/Down Counter will reset and the counter structure's accumulator value will return to 0 and will remain in this state as long as the Reset input remains ON.
 

Note: The Reset input has priority over the Up input, meaning that if either the Up Count or Down Count inputs are ON at the same time as the Reset input, the Up/Down Counter will not count.

 


Status Display:

The yellow triangle in the upper left corner indicates this is a Multi-Scan instruction.

 

The counter structure contains several "dot" fields that can be used elsewhere in your ladder program. Their values are updated each time the Up/Down Counter instruction is processed. The syntax for using them is <counter struct>.<flag name>.

 

  • .Acc (Read/write) - a 32-bit integer value that represents the current number of counts
     
  • .Done - (Read-only) if the instruction is configured to use an Up Preset, is ON any time the value in the counter structure's accumulator (.Acc) is less than or equal to the Up Preset value
  • .DnDone - (Read-only) if the instruction is configured to use an Down Preset, is ON any time the value in the counter structure's accumulator (.Acc) is less than or equal to the Down Preset value
     
  • .Reset - (Read-only) is ON if the RESET logic is ON, or if the Down Counter is being reset by a Reset Counter (RSTCT) instruction.
     
  • .Zero - (Read-only) is ON any time the value in the counter structure's accumulator (.Acc) is 0

 


See Also:

 

Example: