Loading... Please wait...

RsLogix Lesson - Counters - CTU and CTD explained

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.

counter0.png

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.

counter1.png

Rung 2

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

counter2.png

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

counter3.png

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.

counter4.png

Rung 5

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

counter5.png

Rung 6

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

counter6.png

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.

counter7.png

Rung 8

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

counter8.png

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.

counter9.png

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.

counter10.png

Rung 11

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

counter11.png

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.

counter12.png

Rung 13

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

counter13.png

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.

counter14.png

Rung 15

counter15.png

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.

counter16.png

Rung 17

counter17.png