Errors in Exponential Computations in RSLogix 5000

bwill

Member
Join Date
Feb 2011
Location
Georgia
Posts
5
Can anyone explain why the following expression, used in a CPT block, does not work in RSLogix 5000? I am storing the result in a DINT tag.

(2012 * 10**4)

The computed result is 20119996, instead of the expected 20120000.

Thanks!
 
I tried it and I got the same result. I suspect that the ** operator is casting to a float to make the computation.

Exponential operations are incredibly CPU intensive, if 10**4 is a constant then enter it either as 100000 or in scientific notation 10E4.
 
Thanks for the quick reply. The 10**4 I am using is a constant, so I will just replace with 100000.

This does seem a little bit concerning though, if the exponential is offered as a computation, and none of my tasks are running over scan, shouldn't this computation function correctly?

At this point this seems to be a bug in my mind.
 
"That's not a bug, that's a feature"

TConnolly's analysis of the computation being shifted to floating point by the "**" operation sounds correct. His mention of "CPU Intensive" is yet another reason to use integer values if at all possible. The limitation of accuracy in the (apparently) 8th place and beyond is the price paid for the tremendous dynamic range of the values possible in floating point.
 
What's interesting though, if you are reducing one order of power (2012*10**3) the CPT result is what it should be, 2012000...:unsure:
 
Probably not a bug but an artifact of how floating point numbers are represented in a computer. All computers have precision limitations when it comes to floating point numbers. You don't see it as much on your PC because its probably using a 64 bit float, but its still there. I don't know the inner workings of the AB XPY function but if I were to hazard a guess it would be that XPY (**) automatically converts everything to a float and performs the operation that way rather than using two different methods.
 

Similar Topics

From the Red Lion website, after some customer enquiries in the last week or so... Rev. March 25, 2024 [18:30] Just thought it might help a...
Replies
9
Views
258
Hi, I'm trying to add ethernet modules to one of our plcs, but I get about 15 errors that say "Invalid Signature. Reseal instruction to resolve."...
Replies
5
Views
298
Hello, I have a problem with an error that appears when I load the software on the PLC. I'll attach a picture of the error window, but basically...
Replies
1
Views
371
Hi! I'm newer to PLC stuff as it seems to come up at the worst possible times at work. We have an old SLC5-04 connected to a Panelview 900. Over...
Replies
8
Views
773
Back
Top Bottom