Math Overflow

SeanLee

Member
Join Date
Mar 2004
Location
Minot, ND
Posts
122
I have about 60 Integer Files i am using as a counter for a Panel Display
I dont want to get a Math Overflow and I want to keep my program clean. Can i use the Math overflow Bit S0:1 to dump zeros into these Integer files and catch it in time before the PLC will fault and machine stops

Using a SLC 504

Thank You
 
That would be 60 interigations to watch 60 integer files if they get to big


Right now i use a reset button on the Panel and i use FLL (File fill) to clear them and there are only 6 of them

These counters keep track of number of faults and a specific station for 6 different faults there are 10 stations and i am using Inderect adressing off of just 2 counters (one for each Wheel)
So what i want to do is only put the 6 S:0/1 in along with the 6 reset button instead of using 60 comparisons
 
Then use indirect adressing to watch the 60 counters' accumulators and reset them if it gets too big? Then you'd have it all in probably 4 to 5 rungs?

I don't think you could catch the overflow bit before the processor faults. (unless you can set math overflow to not fault the processor, which I think can be done with ControlLogix, not sure about the 5/04).
 
you can just set the math overflow bit in an unlatch, it will stay out during the whole process.


------------(unlatch S0:1)----

like that, that should work (i've it that way)
 
There is no problem unlatching the math overflow as described, but what you really need to do (as was suggested) is to make your code a little more robust so you won't get math overflows. Just understand that when you get a math overflow and you continually unlatch the bit, you no longer have meaningful data.
 
When looking for the cause of a math overflow, I use this little trap. You could use it to test your new code safely too I suppose.

Use this logic as a trap, to keep the CPU running...paste it in right after your suspect code. If Your_Trap_Bit lights up, there is a problem before it's location in the PLC scan of the logic.

Math_Overflow_____Your_Trap_Bit
---] [---------------(L)

Math_Overflow_____Math_Overflow
---] [---------------(U)

Didn't want to try to draw branches with text, but the above can be one rung with two output branches...

You can have a bunch of these with individual trap bits at the end of each file, and then narrow a search for illegal math that way in a large program with multiple files...

Paul
 
Last edited:
Well, he knows where the problem is. He has free running counters that he just accumulates until they overflow. All he needs to do is add some logic in there to reset them before hand, but he doesn't want to add all the code to watch 60 counters (which wouldn't be that much really).
 
Greetings SeanLee ...



you’d probably get more useful information out of this thread if you’d tell us the details of how you’re writing your program - and what you’re trying to accomplish ... first you said:



I have about 60 Integer Files i am using as a counter




that implies that you’re not using CTU instructions - but rather something like an ADD instruction to increment the integer locations (files? ... words?) ... then in another post you said:



i am using Inderect adressing off of just 2 counters




which implies that you ARE using CTU instructions after all ...



so please tell us ... ARE you - or are you NOT - using CTU counters to manipulate the values that you’re storing in the integers? ... we really need to know the answer to that question in order to help you effectively ...



while we’re waiting for more information, here are a few facts (specifically for the SLC platform) to help you along ...



first of all, when a CTU counter instruction “overflows” it does NOT cause a processor fault ... specifically, the counter’s accumulator can go all the way up to 32,767 and then “roll over” to -32,768 and then still keep right on counting upward ... all without generating a fault of any kind ... what DOES happen when the counter “overflows” is that the counter’s very own “overflow” bit becomes set to a 1 condition (example: bit C5:0/OV = 1) ... note that having this particular bit set (to a 1) will NOT fault the processor ...



next, consider what could happen if you use something like an ADD instruction to increment an integer location - to make a “home brew” counter so to speak ... in this case, trying to add anything more to an integer location which already holds a value of 32,767 WILL indeed cause a processor fault - UNLESS your program takes steps to reset the “overflow trap” bit S:5/0 before the end of ladder file #2 ... note: if you’re using an STI (Selectable Timed Interrupt) routine, then another rule applies ... but let’s try to keep things as simple as possible for now ...



now, notice that the processor’s “Arithmetic Underflow/Overflow Flag” - which is bit S:0/1 - will NOT cause a fault ... specifically, if that particular bit comes on, it CAN be left on (1 status) without faulting the processor ... apparently you’re confusing the operation of the “Arithmetic Underflow/Overflow Flag” (bit S:0/1) with the operation of the “Overflow Trap” (bit S:5/0) ... hint: at this stage of the game, it won’t hurt to think of bit S:0/1 as being “informational only” ... on the other hand, bit S:5/0 is certainly more than just “informational” ... it can actually cause a fault condition - if it’s left untreated ...



and just to nail down my main point, when a CTU counter overflows it will NOT affect EITHER bit S:0/1 or bit S:5/0 ... specifically, the CTU counter has its very own built in “overflow” and “underflow” bits ... so it doesn’t need to use the same bits that the processor uses to perform “regular” arithmetic functions ...



finally (for now) ... in many cases where dealing with large values are an issue, the simplest answer is often to use floating point locations (example: F8:0) instead of integer locations and/or CTU instructions ... using floating point locations will allow you to easily store values up to 9,999,999 without even worrying about exponential notation ... in other words, maybe you don’t really want to use a counter at all ... naturally I can’t say for sure until you tell us more about what you’re trying to accomplish - but take a quick look at this link for an example of a “big counter” that might come in handy for your situation ...



suggested plan of attack: post the code that you’re working on ... we can usually tell more about what’s going on that way ...



hope this helps ...
 
Last edited:

Similar Topics

I have Logix v21 running in Emulate. I am getting runtime faults at random times, typically it takes anywhere from 30 seconds to 5 minutes for...
Replies
7
Views
2,130
Hi Gurus I have an issue with 2 similar programs. One faults and the other doesnt. When i enter a number on the HMI larger than 546 ( MUL x 60 =...
Replies
3
Views
3,386
Hey guys, I have MLX LOGIX1400 running fine except that it faults sometimes on math over flow. I examined the program and spotted a...
Replies
8
Views
2,317
Hi I need help solving this Fault Code 20h (Math Overflow Trap S5:0). I download the code into the ML 1400 PLC. When choosing RUN it gives me a...
Replies
22
Views
17,185
We are getting a fault...... Math Overflow Trap S:5/0 = 1 Apparently we are getting a value greater than 32767 or less than -32766. If...
Replies
6
Views
7,814
Back
Top Bottom