advertisement
from the Lost in the Sauce and don't ask me how to department...
Scada PLC and Floating-point math
Human-Machine Interface and SCADA. topic
Posted by Tom Howe on 5 February, 2004 - 12:05 pm
I would like a better understanding of how Scada Packs do Floating-point math. The programming referance manual says that is uses the IEEE single precision floating-point format. I have done a little bit of reading on this and I still can't make sense of how to look at and correctly interpret the info in the Scada Pack registers after doing a floating-point math equation, you see they are displayed in decimal format not binary nor hex. What I am specificly trying to do is break apart the information in the registers and see if my equations are working out correctly. I would like to know which number is the sign, which in the whole number and what is the decimal/fraction. Can anyone help me out? Thanks.


Posted by Jiri Baum on 7 February, 2004 - 1:40 am
Probably best to do some more reading - it's not that simple.

A floating-point number is stored as sign-mantissa-exponent. The first bit (MSB) is the sign, 0 for + and 1 for -. Then comes (exponent + 127) in 8 bits
followed by (mantissa - 1) in 23 bits. Even just dividing the number up into those three parts will be a pain, and then you have to do the whole M * 2^E calculation. Don't forget to subtract the 127 to get the exponent or add the
1 to get the mantissa. Check for the largest and smallest possible exponents, whch reserved for various odds and ends, like zero (all zeros), Inf, NaN...

Alternately, get yourself a short program for converting one to the other, and ignore the details. In C, that'd be a union overlaying the two types - read in one, print out the other.

Jiri
--
Jiri Baum <jiri@baum.com.au> http://www.csse.monash.edu.au/~jirib
MAT LinuxPLC project --- http://mat.sf.net --- Machine Automation Tools


Posted by J on 7 February, 2004 - 1:35 pm
Hi Tom,

SCADAPacks from Control Microsystems use Modbus addressing. When you designate values in the processor for floating point it acutally uses two floating point addresses. The only addresses (I think) that you are allowed to use for floating point are 40001 to 49999. To use the floating point correctly then you must use sequential addresses - i.e. 40001 would also by default use 40002 to store the lower and higher portion of the information. What I think they mean by the IEEE standard is that the values are actually reversed (lower from higher) in that if you look at the register as an integer (so only 40001 or 40002) the number you would see is completely not what you would expect. Too add to the confusion some HMI programs (or IO drivers) require that these register actually be flipped, so in the processor you have to use to different registers again in sequence and flip the lower and higher level word. When you are online with the SCADAPack (assuming TelePace is the program) you have to designate the register you want in the register assignment table for floating point, otherwise the online value will be out of whack as it will appear in integer form and give you the inncorrect value as I described earlier.

I don't know if this helps you understand it any beter but follow up with an additional post and I can maybe help you more.

Regards,

J


Posted by Bruce Durdle on 9 February, 2004 - 3:41 pm
Tom,

The IEEE format uses 32 bits. The first bit is the sign bit, 1 for negative, 0 for positive. The next 8 bits contain the value of the (exponent + 127). The remaining 23 bits are the FRACTIONAL part of the mantissa - the actual mantissa is 1+ this string interpreted as a binary fraction. (First bit weighting of 0.5, second 0.25, 3rd 0.125, 4th 0.625, ...)

So a floating point value of 0100 1100 0010 0100 / 1100 1011 1000 0000 can be separated out to give: (sign) 0 (exponent) 1001 1000 (mantissa) 010 0100 1100 1011 1000 0000

The first bit of 0 is the sign bit and indicates that the value is positive.

The next 8 bits - 1001 1000 are the exponent. The raw value of this in decimal is 152. Subtracting the offset of 127 from this gives (152 - 127) = 25.

The mantissa is given by 1.010 0100 1100 1011 1000 0000. This is 1 + .25 + .0375 ++++ = 1.28746.

The combined value is then + 1.28746 x 2^25 = 43.2 x 10^6.

However, in order to get there from a pair of 16-bit registers, you ned to know:

1) what is the order of the registers
2) what is the order of bits in the register.

I have found, when trying to interpret the floating-point data from a poorly-documented instrument, that the best way is to inject a known signal of some sort and work out how the reading can be interpreted to give the known required floating-point result.

Hope this helps,

Bruce.


Posted by Michael E. Crossman on 7 February, 2004 - 2:10 pm
Using the Telepace software, use the Monitor Element command from the Controller menu, then choose the register and select to view in Floating point.

Best regards,

Michael E. Crossman
PLCs Plus International, Inc.
http://www.bkppi.com


Posted by Joe on 7 February, 2004 - 2:13 pm
checkout http://www.psc.edu/general/software/packages/ieee/ieee.html

it was the first hit on google


Posted by BobB on 8 February, 2004 - 12:17 pm
I presume you are referring to IEEE 754. This is the format that most PLC systems are now using as "REAL".
The most significant bit is the sign, the next 8 bits are the exponent (power) and the least significant 23 bits are the mantissa with an assumed 1.
So the format would be MSB 1 - negative, 0 - positive, exponent 10101010 - 170 decimal, then an assumed 1. with the 23 bits in the mantissa representing the decimal portion to be multiplied, including the assumed 1. , by the exponent.

Your use of this site is subject to the terms and conditions set forth under Legal Notices and the Privacy Policy. Please read those terms and conditions carefully. Subject to the rights expressly reserved to others under Legal Notices, the content of this site and the compilation thereof is © 1999-2014 Nerds in Control, LLC. All rights reserved.

Users of this site are benefiting from open source technologies, including PHP, MySQL and Apache. Be happy.


Fortune
"I like being single. I'm always there when I need me."
-- Art Leo
Advertise here
advertisements
Servo, stepping motor control, analog & web HMI in one system!
Control.com is the largest Automation community on the web. Learn how to advertise here now...
Servo, steppers, analog, digital & web HMI - Fully Integrated!
Time to incorporate data handling, web HMI and motion in one system!
our advertisers
Help keep our servers running...
Patronize our advertisers!
Visit our Post Archive