micrologix counter roll over

gbeaker

Member
Join Date
Sep 2012
Location
earth
Posts
148
What is the best practice for letting a counter roll over? Do I need to set the preset or use a compare to make it go back to 0 or will it do it automatically?

I am not concerned with the value, I just need to make sure the counter will always keep counting.
 
I am not concerned with the value, I just need to make sure the counter will always keep counting.
Curious, what are you using it for if not concerned about the value?


But you don't have to reset it. It will count up to 32767 then rollover to -32768 and keep counting
back up to 0 and so on.

counter.PNG
 
Last edited:
Curious, what are you using it for if not concerned about the value?

I use a counter as a flip/flop to toggle certain outputs from an HMI. The hmi button press increments the counter by one and I use bit 0 of the ACC to enable the output.
 
If you are using it as a flip flop then just leave the PRE at zero and let it run, never reset it. ACC will roll over and go negative but because integers are 2's compliment the bit toggle will work just as it should. Counter roll over doesn't affect math minor error bits so just let it go.

The only thing to be aware of is that ACC/0 is a retentive flip flop.
 
IMHO, a "toggle" or "flip/flop" or "alternating" bit in your control logic should always be retentive, and am whole-heartedly in favour of using a counter's bit 0.

It is then up the system designer/programmer to decide which bits should be reset on power-up, and put the appropriate code in to do so.

It should not be left to the controller itself to just reset all flip/flops on power-up (or even mode change, PROG to RUN !!), without regard for what state they were remembering.
 

Similar Topics

trying to do division on the hsc:1 value which is on a Long (32bit) word. If I do a divide by 100 and try to put the result in an integer or even...
Replies
9
Views
2,393
I'm tring to move the data in F8:30 to st10:60. Anyone have a suggestion?
Replies
14
Views
3,549
I am having an issue with a little Micrologix program. Counter 1 increments each time item passes sensor on input 0 When Counter 1 increments to...
Replies
4
Views
1,600
hello Sir, I am trying to program for the speed(1000 rpm) with a sensor input and for this i used micrologix1400 BXB plc. I am not able to use...
Replies
1
Views
2,528
Back
Top Bottom