Example - Ladder Diagram
CTU
The CTU instruction starts from 0 and counts up to the largest value, 65,535 (unsigned). The count number is saved in a counter data register, CC. If the value of CC is greater than or equal to the value of v, the counter contact C energizes.
Ladder Diagram Example
The initial value of the BOOL counter data register, C1.0, is 0.
The initial value of the WORD current count data register, CC1.0, is 0.
The initial value of the WORD set count data register, CS1.0, is 3.
![]()
When the contact, M0.0, is powered ON (1), the counter instruction counts up by 1, increasing the current count data register, CC1.0, to 1.
![]()
When the contact, M0.0, is powered ON (1) again, the counter instruction counts up by 1, increasing the current count data register, CC1.0, to 2.
![]()
When the contact, M0.0, is powered ON (1) again, the counter instruction counts up by 1, increasing the current count data register, CC1.0, to 3.
Since CC1.0 is greater than or equal to CS1.0, the BOOL counter data register, C1.0, is set to 1.
As a result, the coil, Y1.0, is energized.
![]()
When the contact, M0.0, is powered ON (1) again, the counter instruction counts up by 1, increasing the current count data register, CC1.0, to 4.
![]()
Since CC1.0 is greater than or equal to CS1.0, the BOOL counter data register, C1.0, remains 1.
As a result, the coil, Y1.0, remains energized.
When the contact, M0.1, is powered ON (1), the value the current count data register, CC1.0, resets to 0.
Since CC1.0 is less than CS1.0, the BOOL counter data register, C1.0, is set to 0.
As a result, the coil, Y1.0, is deenergized.
![]()