Up/Down Counters

cucgs

Member
Join Date
Mar 2003
Posts
2
Alright, I've read another post where it was said that you don't mind helping students, but you don't hand out freebees. Well, I'm a student in need of help. I'm trying my best to find the answer, but I'm not doing so well. I'd appriciate some help.

The Question: When using an up/down counter with a preset value of 10, what would happen if 11 pulses come into the counter before it is reset? What happens to the extra pulse?

The only info. I can find is "Again note that the counter accumulated value ONLY changes at the off to on transition of the pulse input. "

My interpretation is that the counter would change at 10, so it should never get to 11. However, the wording of the question implies that I am wrong. I can't find anyother relivent info.

Any help? :( <-----Looking sad in hope that you will take pity on me
 
Well! I dont know if i answer your question but this is what I have seen happening when I use RS logix 500..which is that..if you dont resent the counter..and a pulse comes in..the done bit goes true at say ur preset value..but the accumulator increments. This maybe becos of the fact that in the scan cycle the rung stays true to increment the accumulator.
 
This one goes to eleven.

Hey, cucgs, it sounds like you're thinking it through, and you cared enough to spell all your words correctly.

When the accumulated number of counts equals the preset value of the counter (*.ACC = *.PRE, in the vernacular nomenclature), the Done bit is set.

If a RESET instruction is not given for this Counter before the next counting pulse (0 -> 1 transition), then the counter's accumulated value simply increments by one when that pulse arrives. The DN bit stays on, no matter how much higher the Accumulated value gets, until the RESET instruction is given.

There are special cases, of course, when you overflow or underflow the limits of the memory element you're using for an Accumulator. Usually PLC controllers have special Underflow and Overflow flags that can be set, and fault handling routines to determine what the controller can do in such a circumstance. Probably that's not germane to your fundamentals class.

[attachment]

Now, tell me what instruction you would add to the input conditions on the Counter rung to prevent the accumulated value from ever exceeding 10 ?

counter_example.jpg
 
Last edited:
to count or not to count

PLC counters are just like any other counter, they keep on accumulating counts until they are reset. However, with mechanical counters they just roll over at the terminal count, with PLC counters your get the overflow/underflow error Ken spoke of. Not exactly rocket science is it?
 
The answer to your question is one of the favorites around here, "It depends". It depends on the brand and model of PLC.

Most PLCs follow this model for Up counters: The counter's accumulated value increases by one whenever the enabling logic transitions from false to true. The 'done' bit will be true whenever the accumulated value is equal to or greater than the preset value. The accumulated value can continue to increase beyond the preset value up to a maximum value of 32767 (16-bit counter). When logic controlling the reset signal is true, the counter's accumulated value is forced to zero.

I'll leave it as an mental exercise for the student to decide what should happen to the accumulator beyond 32767. Should it roll over to zero, to -32768, or freeze at 32767? Defend your choice.

I have run into one model of PLC where the Up counter counted up to the preset value then stopped incrementing. In that model, the done bit was true only when the accumulated value was equal to the preset. I learned this the hard way. The application was using a counter to keep track of the number of items being placed in a box. When the box was full, it got moved to the next station, and a new box got moved into position to be filled. They had two sizes of box, one filled with 6 items, the other with 12. They had a selector switch wired to the PLC to choose between the two sizes. When the switch was in one position, the PLC used a value of 6 for the counter preset; in the other position, the preset value was 12. Everything worked fine until one day, when they changed from a 12 count to a 6 count. The operator didn't notice he had forgotten to change the switch setting until the machine had placed seven items in the box designed for 6. When he changed the switch setting, the counter stopped counting because now the ACC value was greater than the preset. To make matters worse, the program logic used the 'done' bit to reset the counter, so it was stuck. It couldn't count any more and it couldn't be reset.
 
The tendency when starting PLCs is to make some things more complicated than they really are. I think this is your situation.

You are looking at the counter like an odometer on your car, which rolls over when it gets to the preset (999,999 on older models.) A counter doesn't work like this.

Look at it more like dropping marbles into a bucket, with the bucket being on one side of a simple balance scale - the type with two platforms and a center pivot. The other side of the scale has a weight - this weight is your pre-set. It is equal to the weight of a specific number of marbles - say ten. (OK, you also need to add weight exactly equal to the bucket!)

When you start out the side of the scale with the weight is lower. Every time a light comes on you drop marbles one at a time into the bucket. When the weight of the marbles equals the weight of the bucket the scale will "trip" - it will tip so that the two sides are level. If you had been counting marbles, you would notice that the scale tipped when you had ten marbles in the bucket.

If you continue dropping marbles, they just build up in the bucket until they overflow. The scale will tip so the bucket is lower than the weight, but that really doesn't matter.

Most PLC counters work that way. (Not all, as Steve indicated). The accumulated count is the number of marbles dropped, the pre-set is the weight, and the done bit or set coil or whatever it is called is turned on when the count equals the preset. The counter can keep on counting until the data overflows the available counter data size limit OR until you reset the counter. Resetting the counter essentially means you dump the bucket out and start over again with more marbles and an empty bucket.

"The Question: When using an up/down counter with a preset value of 10, what would happen if 11 pulses come into the counter before it is reset? What happens to the extra pulse? "
The answer, like the bucket, is nothing. They just sit there - you can't get more done than done!

"The only info. I can find is "Again note that the counter accumulated value ONLY changes at the off to on transition of the pulse input. " "

That rather obscure statement just means that you only drop a marble when the light changes from off to on. If the light stays on, you don't drop another marble, you just wait. When the light goes off, you don't drop another marble, you just wait. When the light comes back on again, you immediately drop another marble.
 
Last edited:
A couple of points of intrest here is:
1) The counter acumulated ACC value may be used elsewhere in the program so once the preset is reached and the done bit is set, the accumulated value could be used with other compare statments, like setpoint 1,2,3,4,etc.
2) Two weeks ago I had a micro 1200 fault and shut down, I checked and found a counter had reached it's maximum 32,764, or something like this and set a fault bit. This fault stopped the program scan and shut down the machine. (My fault, I left out the reset command. It took months for the counter to reach max.)

So the counter reaches its preset, the done bit is turned on, and then the accumulated value continues to accumulate (11,12,13,14etc)until it reaches the maximum value, and then the processor shuts down, (if it's a micro-1200). And, the acc value may be reset at any time, even if the preset is not reached. I think you guys said this already..
 
As usual, I was making the question harder than it needed to be. Simple answer.... nothing happens and the counter continues to count.

Thanks for everyone who replied to help me.

Ken Roach, It looks like you put a lot of effort in trying to help me, so a big thanks to you.
 

Similar Topics

Hi All, Can this be done ? I looking at writing code for "stand alone" Micrologix500 (No other control purposes intended) - Trying to track...
Replies
3
Views
2,451
I'm upgrading an existing machine with a Honeywell HC900 controller, and I'm trying to do some data processing in the controller. I have variables...
Replies
0
Views
48
Hi: For ControlLogix. Is there a way to "trap" when processor is powering down? This mean leave a bit latched or a value written to a tag? Is...
Replies
6
Views
245
I do have a problem with a GE Versamax micro PLC. By going online (on Port 1) the "OK led" goes down. Power led stays On Port 2 no reaction at...
Replies
4
Views
387
Hey guys, I got a carriage that can move with X and Y axe, each side got their own cylinder so left and right. It doesnt happen very often but...
Replies
0
Views
322
Back
Top Bottom