Maths overflow/underflow

Join Date
Jun 2003
Posts
3
Hello everybody.
I am new at this game and would appreciate any help i can get.

I am running a allen bradley SLC 5/04 cpu 24K
1747-ls42a

For no known reason it went into fault mode , on investigation it appears that it is suffering from case of overflow or underflow

when i goto the error it comes up as S:6=20H
and the major error bit S:1/13 is set to one also the overflow trap is set to 1(S:5/0)

i have looked for an overflow but can not find one
When i reset this error and attempt to run the processor it reapears.
as i say i am new to this game any assistance or ideas greafully accepted thanks in advance
Regards Barry
 
To establish what causes the overflow can be difficult, as S:5/0 is evaluated at the end of the program scan.

It can be discussed (and has been discussed a lot) if it is even necessary to halt the program in case of a math overflow.

To get your CPU into RUN:
Program a new rung as the last one in program file 2.
Evaluate S:5/0 and if ON, generate an appropriate alarm for your HMI and unlatch S:5/0.

To locate where the math overflow occurs:
Evaluate S:5/0 at the end of each program file. If ON, set a debug bit ON (a unique bit-adress for each program file).
This only tells in which file the overflow occurs. You can add more debug-rungs in the same manner in order to get closer to the malicius instruction. But at this stage you should start to scan the program manually for math or counting instructions.

To avoid math overflow:
Use floating point as much as possible.
Test for zero before performing a division.
Test for limits before counting up or down.

Hope this helps :)
 
Thanks JesperMP

I have not found the overflow yet but have done as suggested and reset the S:5 at the end of file 2 and programme now responds
Thanks for your valuable help it is appreciated.

And yes i can not see any reason to halt the programme especialy if this type of error is so easy to reset (only after JesperMP tells you how)

Thanks again friend
 
Check for N file words containing 32767 or -32767. That is a pretty good indicator of a result overflowed.

Also try putting in a TND temporary end in your ladder. Start as close to the top as you dare, and keep moving it down until the fault reappears. Voila - that's the offending rung!
 
"At Length" or "Ad nauseum"?

This topic, how to find math error and whether to automatically turn off S:1/5 was discussed at length IN THIS THREAD.

Most of the techniques and info have been covered above, but the thread still provides some good ideas.

In addition to checking for 32767's in N files, I'd also suggest looking for 'NaN!'s in Floats (NaN = Not a Number). They stand out, and are usually associated with math faults.
 
Last edited:
Be vary of using TND

I think that a word of caution is in place here:

If you use TND as RoTaTech suggest, then all code "downstream" will be disabled (as is desired of course). So you cant use this approach if your proces or machine has to run during debugging.
Worse: If you have programmed some outputs in the disabled code, then these outputs will be retained in their last state (and that might be ON !).
 

Similar Topics

Hi Everyone, I got a problem of "Maths overflow" and it logs the minor fault for everyscan. The instruction used is SUB with Source A and Source...
Replies
26
Views
9,775
Hi Folks I hope this is not a dumb question,I am a newbie . I want to perform simple math functions like multiplication, addition etc in TIA...
Replies
6
Views
2,816
Hi all, I am trying to copy paste a routine from rs logix500 into rs logix5000, I get an error on rung where they are searching for scada values...
Replies
1
Views
1,853
Hi I am fairly new to PLC programming and I am self learning. I have written a simple program to detect and store the RPM and ultimately the...
Replies
0
Views
1,413
Hi All, Rockwell Compact Logix processor. I'm using an Add function that I trigger by a using an XIC instruction followed by a ONS. The add...
Replies
6
Views
2,105
Back
Top Bottom