rslogix DN counter (CTD)

johnmck66

Member
Join Date
Aug 2007
Location
Manchester
Posts
96
There has been posts on this before I guess

I have used down counters in Siemens quite easily. But with RSlogix I am finding it difficult.
I am trying to count down from 200 to 0, from an incoming pulse.

Do I store 200 in the preset, or the accumulator? I have tried various methods using -200 etc.

I just need a bit HI when the 200 value has decremented, maybe the DN bit, then I can use the bit in my code, as well as to reset the CTD.

Not much hair left to tear out.
 
Hi Garry
I just could not grasp it from that link, I am just trying to emulate the Down counter as used in Step 7 or LOGO or TIA portal.

Regards
John M
 
I really avoid using the CTD. It just can be too confusing. If you insist on the CTD and need 200 counts, you would ignore the Preset and load 200 into the ACC value. You would also ignore the .DN status tag. Us an EQU to compare when the ACC reaches 0 to trigger whatever you need to happen.

What I typically do is count up instead. 200 for the Preset and 0 for the ACC. Then use a SUB(tract) instruction to subtract the incrementing ACC from the PRE. I display that value to show the count decrementing.

OG
 
Use a up counter with a preset of 200. Then monitor the DN bit to be true.
In Siemens you would use a down counter in AB a up counter is easier.
 
I'm not sure if this is directly relevant to the discussion but you can use the CTU and CTD in pairs, each invoking the same counter, to form an Up/Dn counter.
 
Last edited:
Yeah, the CTD I still maintain is confusing, particularly if I take how I use a CTU and apply it to a CTD. If I want 200 counts and then turn on a DN bit, it just doesn't work the same way.

If I start with an ACC of zero then the CTD is going to count negative. If I put -200 in the PRESET then the done bit remains on until I hit -201 at which point it turns off. So I would really need -199 as a preset and examine for the DN bit to turn OFF.

I think the ONLY time a CTD makes any sense at all is when it is used with a CTU to count up and down on the same counter. I like the FBD version since it included both pieces in one block.

OG
 
Having read through this post, I think it needs to made clear...

In the Allen-Bradley world, there are no such things as UP COUNTERS, or DOWN COUNTERS. Ther is only a COUNTER data-type (file-based, or tag-based in Logix5000)

A counter's accumulator value can be manipulated by executing either of two instructions, CTU and CTD (actually there's another, RES, but that's not counting as such, just resetting the accumulator to zero).

Operaghost... the .DN bit is set if the .ACC is >= to the .PRE, simple... but be aware that this is true even if the rung with the CTU or CTD instructions on is FALSE, the instruction will still execute its "macro flowchart", part of which compares the .ACC to the .PRE, and sets the .DN accordingly.
 
I think I was making the same point. People don't understand the operation of the CTD. And specifically the DN bit. People frequently think the DN works differently because they are using the CTD when in fact, the DN doesn't care a wit about whether the instruction is a CTU or a CTD.

OG
 

Similar Topics

Tonight I'm contemplating using a technique I saw the other day while troubleshooting an installation of a legacy machine for a customer of mine...
Replies
9
Views
4,082
Hello, first of all thank you for reading this post. I am pretty new at PLC programming! I have a problem with a CTU and the reset function. You...
Replies
3
Views
4,995
The counter instruction has an OV, a UN and a UA flag but they don't seem to do anything. For example, the OV (over flow flag) doesn't turn on...
Replies
5
Views
3,869
Hi, I'm using RsLogix 500 micro starter edition with a micrologix 1200 plc. I want to use a counter where I can change the preset via variable. I...
Replies
3
Views
3,678
Here's the situation: operators print off labels for finished products, scan the barcode on the label, apply the label to the products and place...
Replies
8
Views
5,212
Back
Top Bottom