 # RsLogix 500 Training - Counters - CTU and CTD

## In this lesson you will learn about the CTU and CTD counter instructions.

Rung 0

Each false to true transition of the CTU will increment C5:0.ACC by "1".

-CU-If the CTU is false, it will write a "0" to the CU (Count Up Enable) bit. If the CTU is true, it will write a "1" to the CU (Count Up Enable) bit.
-CD-The CTU does not write to the CD (Count Down Enable) bit.
-DN-If the ACC (Accumulated) value is less than the PRE (Preset) then the CTU will write a "0" to the DN (Done) bit. If the ACC (Accumulated) value is greater than or equal to the PRE (Preset) then the CTU will write a "1" to the DN (Done) bit.
-OV-If when the CTU is incrementing, it "rolls over" (goes from +32767 to -32768), it will write a "1" to the OV (Count Up Overflow) bit.
-UN-The CTU instruction does no write to the UN (Count Down Underflow) bit.
-UA-The UA (Update Accumulator) is only used by the HSC (High Speed Counter) of the Fixed SLC Controller. Rung 1

If the CTU is false, it will write a "0" to the CU (Count Up Enable) bit.  If the CTU is true, it will write a "1" to the CU (Count Up Enable) bit. Rung 2

The CTU does not write to the CD (Count Down Enable) bit. Rung 3

If the ACC (Accumulated) value is less than the PRE (Preset) then the CTU will write a "0" to the DN (Done) bit.
If the ACC (Accumulated) value is greater than or equal to the PRE (Preset) then the CTU will write a "1" to the DN (Done) bit.

To see this toggle the B3:0/0 bit until the ACC is equal to the PRE. Rung 4

If when the CTU is incrementing, it "rolls over" (goes from +32767 to -32768), it will write a "1" to the OV (Count Up Overflow) bit.

To see this set the ACC (Accumulated) value to "32767" then toggle B3:0/0 allowing it to "rollover" to -32768. Rung 5

The CTU instruction does no write to the UN (Count Down Underflow) bit. Rung 6

The UA (Update Accumulator) is only used by the HSC (High Speed Counter) of the Fixed SLC Controller. Rung 7

Each false to true transition of the CTD will decrement C5:1.ACC by "1".

-CU-The CTD does not write to the CU (Count Up Enable) bit.
-CD-If the CTD is false, it will write a "0" to the CD (Count Down Enable) bit. If the CTD is true, it will write a "1" to the CD (Count Down Enable) bit.
-DN-If the ACC (Accumulated) value is less than the PRE (Preset) then the CTD will write a "0" to the DN (Done) bit. If the ACC (Accumulated) value is greater than or equal to the PRE (Preset) then the CTD will write a "1" to the DN (Done) bit.
-OV-The CTD instruction does no write to the OV (Count Up Overflow) bit.
-UN-If when the CTD is decrementing, it "rolls over" (goes from -32768 to +32767), it will write a "1" to the UN (Count Down Underflow) bit.
-UA-The UA (Update Accumulator) is only used by the HSC (High Speed Counter) of the Fixed SLC Controller. Rung 8

The CTD does not write to the CU (Count Up Enable) bit. Rung 9

If the CTD is false, it will write a "0" to the CD (Count Down Enable) bit.  If the CTD is true, it will write a "1" to the CD (Count Down Enable) bit. Rung 10

If the ACC (Accumulated) value is less than the PRE (Preset) then the CTD will write a "0" to the DN (Done) bit.
If the ACC (Accumulated) value is greater than or equal to the PRE (Preset) then the CTD will write a "1" to the DN (Done) bit.

THIS IS IMPORTANT! Even though the CTD counts down, its DN bit operates the same as the CTU. Rung 11

The CTD instruction does no write to the UV (Count Up Overflow) bit. Rung 12

If when the CTD is decrementing, it "rolls over" (goes from -32768 to +32767), it will write a "1" to the ON (Count Down Underflow) bit.

To see this set the ACC (Accumulated) value to "-32768" then toggle B3:0/1 allowing it to "rollover" to +32767. Rung 13

The UA (Update Accumulator) is only used by the HSC (High Speed Counter) of the Fixed SLC Controller. Rung 14

The next two rungs show that two different counter instructions can address the same address (C5:2). There is nothing "illegal" about this. A common example of a use of this would be a part counter using a CTU instruction and there being a CTD for rejected parts.

Toggling B3:0/2 will increment C5:0.ACC and B3:0/3 will decrement the same C5:0.ACC. Rung 15 Rung 16

You can do more with counters than just look at the status bits. You can compare their ACC (Accumulated) values as well.

The next two rungs show examples of this. Rung 17 Next you will do some basic PLC fault understanding in the RsLogix 500 - The Big RED Fault - Finding, Understanding, and Clearing lesson.

## Next Steps

Go to the Allen Bradley RsLogix 500 PLC Training PLC Training Getting Started Lesson series to select your next lesson.  There are also many other Lesson Series on PLC Programming and Industrial Automation.