TConnolly
Lifetime Supporting Member
LJBMatt said:If in 89 years these pumps are still running off of the same processor and get an overflow fault, odds are you won't be available to take the phone call. I'd say the lifecycle of the system will be shorter than the time it takes for your counter to overflow.
When the counter reaches 32767 it will roll over to -32768 and then count up towards zero. Your PLC program will not care. You don't get an overflow fault on a counter. The counter itself has an overflow bit but you can ignore it. The .ACC/0 bit will toggle as normally because of the two's compliment binary form used for negative numbers. You never need to care what the actual value of .ACC is, only what the value of .ACC/0 is, and it will alternate properly.
It could alternate once a minute and you still don't have to worry about overflow, thats the beauty of twos compliment binary.
A few others have suggested a flip flop. That is also a very good way to solve the problem. Make sure you use a one-shot in your comparisson for the time. The one shot is not necessary with the counter in my example.
0111111111111100 = 32764
0111111111111101 = 32765
0111111111111110 = 32766
0111111111111111 = 32767
1000000000000000 = -32768 <- counter rolls over, notice ACC/0 and 2's compliment form.
1000000000000001 = -32767
1000000000000010 = -32766
Last edited: