Dan123
Member
I'm working on a math-heavy project on CompactLogix L45 (Rev. 20) and am running into some issues with a calculation to determine the angle between two vectors. Is there any way to do floating point calculations with more than 9 significant digits in RSLogix5000?
Here's some background. I am trying to make two planes as parallel as possible with each other -- and I am considering them "aligned" when the angle between them is around 0.005 degrees (ideally I'd want to be able to measure up to 0.001 degrees). However, due to floating point limitations, RSLogix is restricting me to a resolution of 0.05 degrees.
The reason I am so limited is because I am using the equation "arccos(A.B/|A|*|B|)" to determine the angle (where the numerator is the dot product of the vectors and the denominator is the product of the vector magnitudes). With arccosine, my numerator and denominator can be exactly the same until the 8th or 9th digit, but a difference in that 9th digit can lead to a completely different result.
An example:
If I take arccos(176250000000000000/176250000090000000), where everything is equal until the 11th digit -- the result is 0.001831 degrees. This is where I want my accuracy to be, so if we assume that 11th digit is garbage I'm still off by about 0.002 degrees at most. But if we assume that 10th digit is garbage: arccos(176250000000000000/176250000990000000) = 0.0061 degrees. And if we assume the 9th digit is garbage: arccos(176250000000000000/176250009990000000) = 0.0193 degrees.
So basically I need that 10th digit of accuracy (would be nice to have more), but it appears that RSLogix floating point can only give me 8 or 9 (per IEEE 754).
There's a LREAL data type in the documentation, but I do not have it as a predefined data type, and can hardly find any additional documentation about this (looks like Micro800s have it, if only I had such a high-end PLC). Is it possible to perform floating point calculations (arccosine) on LINT tags? Is there any other way to get this precision?
Here's some background. I am trying to make two planes as parallel as possible with each other -- and I am considering them "aligned" when the angle between them is around 0.005 degrees (ideally I'd want to be able to measure up to 0.001 degrees). However, due to floating point limitations, RSLogix is restricting me to a resolution of 0.05 degrees.
The reason I am so limited is because I am using the equation "arccos(A.B/|A|*|B|)" to determine the angle (where the numerator is the dot product of the vectors and the denominator is the product of the vector magnitudes). With arccosine, my numerator and denominator can be exactly the same until the 8th or 9th digit, but a difference in that 9th digit can lead to a completely different result.
An example:
If I take arccos(176250000000000000/176250000090000000), where everything is equal until the 11th digit -- the result is 0.001831 degrees. This is where I want my accuracy to be, so if we assume that 11th digit is garbage I'm still off by about 0.002 degrees at most. But if we assume that 10th digit is garbage: arccos(176250000000000000/176250000990000000) = 0.0061 degrees. And if we assume the 9th digit is garbage: arccos(176250000000000000/176250009990000000) = 0.0193 degrees.
So basically I need that 10th digit of accuracy (would be nice to have more), but it appears that RSLogix floating point can only give me 8 or 9 (per IEEE 754).
There's a LREAL data type in the documentation, but I do not have it as a predefined data type, and can hardly find any additional documentation about this (looks like Micro800s have it, if only I had such a high-end PLC). Is it possible to perform floating point calculations (arccosine) on LINT tags? Is there any other way to get this precision?