2-147
2 Instruction Descriptions
NJ-series Instructions Reference Manual (W502)
Counter Instructions
2
CTUD_**
A CTUD_** instruction creates an up-down counter that operates according to an up-counter input sig-
nal and a down-counter input signal. The counter has the functions of both an up counter and a down
counter. The preset value and counter value must be one of the following data types: DINT, LINT,
UDINT, or ULINT. The name of the instruction is determined by the data type of PV and CV. For exam-
ple, if they are the LINT data type, the instruction is CTUD_LINT.
When reset signal Reset changes to TRUE, counter value CV changes to 0 and up-counter output QU
changes to FALSE. When up-counter input signal CU changes to TRUE, CV is incremented. When the
value of CV reaches the value of PV or higher, the value of QU changes to TRUE. After the value of CV
reaches the value of PV or higher, the value of CV does not change even if the value of CU changes to
TRUE.
When load signal Load changes to TRUE, counter value CV changes to the value of preset value
PV and down-counter output QD changes to FALSE. When down-counter input signal CD changes to
TRUE, CV is decremented. When the value of CV reaches 0 or less, the value of QD changes to TRUE.
After the value of CV reaches 0 or less, CV does not change even if CD changes to TRUE.
CU and CD are ignored while Load or Reset is TRUE. CV is not incremented or decremented. If both
CU and CD change to TRUE at the same time, CV will not change. If Reset and Load are both TRUE,
Reset has priority and the value of CV changes to 0. If Reset changes to TRUE, CV changes to 0, and
so QD changes to TRUE. If Load changes to TRUE, the value of CV changes to PV, and so QU
changes to TRUE.
Boolean
Bit string Integers
Real
numbers
Times, durations,
dates, and text strings
BOOL
BYTE
WORD
DWORD
LWORD
USINT
UINT
UDINT
ULINT
SINT
INT
DINT
LINT
REAL
LREAL
TIME
DATE
TOD
DT
STRING
CU OK
CD OK
Reset OK
Load OK
PV OK OK OK OK
QU OK
QD OK
CV
Must be the same data type as PV
Function
Operation as an Up Counter
Operation as a Down Counter
Common Operation for Up and Down Counters