FSC - Expression Help

For comparing a range of Dints, subtract the highest number that you want to find (1115) from 2147483647 (2147482532), then subtract the span (1115-1101+1=15) from 2147483647 (2177483632) and use that for your comparison. Thus your expression would be

(B_Group_1_Found_Array[zFSC.POS].Lane+2147482532)>2177483632

Assuming the '.Lane' element is a DINT, this computation will generate a minor program Arithmetic Overflow fault for Lane values greater than the largest range value. It does seem to work, though.
 
Assuming the '.Lane' element is a DINT, this computation will generate a minor program Arithmetic Overflow fault for Lane values greater than the largest range value.

The logic works because the math overflows, but in my tests, the controller properties Minor Faults does not show the fault when the logic runs. Where are you seeing this fault?
 
I am testing on a 1756-L61, and under the Controller Properties, Minor Faults tab, I get the following for values over 1115

6/29/2001 4:54:53 PM
(Type 04) Program Fault
(Code 04) Arithmetic overflow. Result of an arithmetic instruction out of range.
Task: MainTask
Program: MainProgram
Routine: MainRoutine
Location: Rung 16

(Also, in testing I noticed a typo on the greater than test...2147...instead of 2177)
 
I am testing on a 1756-L61, and under the Controller Properties, Minor Faults tab, I get the following for values over 1115

OK, I got the 'fault'. I found when I tested the logic that I found the match in the middle of the array. When I added high number to the beginning of the array, reset the .in bit and restarted the logic, the FSC was not starting at 0, but where I found the last match.

I don't like the idea of having code that gives 'faults', but I'd probably use it (with comments on where the numbers come from and the 'fault side effect') over the other methods suggested, since it has less calculations. I am curious as to what other opinionated people here that think they write good code, would choose for a solution, and why.

(Also, in testing I noticed a typo on the greater than test...2147...instead of 2177)
Oops. That's why I explained the math. When I proofread, I am very good at seeing what I wanted to write instead of what I wrote.
 

Similar Topics

Hello, Trying to use an FSC instruction to search an array for part number. Hardware - 5069-L306erms C-More Headless HMI Software -...
Replies
2
Views
1,099
Hello, does anybody know if it is possible to replace a table name within a FSC expression with a variable that updates the table name based off...
Replies
1
Views
1,283
Hello all, I'm trying to use the FSC function in Studio 5000, but i keep getting the error "Invalid Expression". I am hoping one of you might be...
Replies
12
Views
2,502
Maybe this is just not possible, or maybe I am doing something wrong. Background; I have a data array of over 1500 products. For sorting I...
Replies
6
Views
765
I am trying to use the FSC to count how many numbers in my real array are less than a certain value but not sure why I cant for the life of me get...
Replies
11
Views
386
Back
Top Bottom