Example - Ladder Diagram
CTUD
The CTUD instruction starts from 0 and counts up to the largest value, 65,535 (unsigned).
The CTUD instruction also counts down from the current value, CC, until it reaches 0.
The count number is saved in a counter data register, CC. If the value of CC is greater than or equal the value of v, the counter contact, C, energizes.
Ladder Diagram Example
The initial value of the BOOL counter data register, C2.8, is 0.
The initial value of the WORD current count data register, CC2.8, is 0.
The initial value of the WORD set count data register, CS2.8, is 5.
![]()
When the contact, M2.0, is powered ON (1), the counter instruction counts up by 1, increasing the current count data register, CC2.8, to 1.
![]()
When the contact, M2.0, is powered ON (1) again, the counter instruction counts up by 1, increasing the current count data register, CC2.8, to 5.
Since CC2.8 is equal to CS2.8, the BOOL counter data register, C2.8, is set to 1.
As a result, the coil, Y0.5, is energized.
![]()
When the contact, M2.0, is powered ON (1) again, the counter instruction counts up by 1, increasing the current count data register, CC2.8, to 6.
Since CC2.8 is greater than or equal to CS2.8, the BOOL counter data register, C2.8, remains 1.
As a result, the coil, Y0.5, remains energized.
![]()
When the contact, M2.1, is powered ON (1), the counter instruction counts down by 1, decreasing the current count data register, CC2.8, to 5.
Since CC2.8 is equal to CS2.8, the BOOL counter data register, C2.8, remains 1.
As a result, the coil, Y0.5, remains energized.
![]()
When the contact, M2.1, is powered ON (1), the counter instruction counts down by 1, decreasing the current count data register, CC2.8, to 4.
Since CC2.8 is less than CS2.8, the BOOL counter data register, C2.8, is set to 0.
As a result, the coil, Y0.5, is deenergized.
![]()
When the contact, M2.2, is powered ON (1), the current count data register, CC2.8, is reset to 0.
![]()