Floating numbers show exponential in the PLC

Hello
I have a Numeric Text Field that should write a speed set points to my PLC.
The tag is Floating points type. I did set the numeric text field number type to Float ant i did bind the value(float) to the Tag. I set the decimal format to 0.# cause i want only one digit decimal.

The PLC is an Allen-Bradley 1756-L72S v31.

The Problem is the number i write from ignition is showing in exponential in the PLC.
So if i write 24.2 in ignition the number in the PLC is 3.36311631e-044

Does the problem only occur when you write from Ignition, or is it both ways? If you write the value from the PLC end, does it show the value you wrote in the PLC as expected in Ignition?

Regarding display format in Ignition: if you want one decimal to show at all times, you want decimal format 0.0 (0.# will only show the first decimal if the decimal value is not zero).

When i write the value in the PLC directly in the tag it does show ok in Ignition, but not in the other way.

Was the tag created by dragging from the OPC browser to the tag folder? If not, do you have the same issue on a tag created that way?

Thats something like that! It started to work when i drag the tag from the tag browser to the NumericTextfield Value property. Prior to that, i was binding the properties using the binding icon. I don’t understand why, but Ignition seem acting differently when you drag the tag then when you use the binding icon… That is not the first time i experience problems with one or the other method.

What driver are you using to get the data from the PLC? It almost looks like a byte order problem.

Glad you got it working! Chances are the default binding created on tag drop is slightly different than the one you manually created. If you want to figure out the difference, you could do one your way, another copy by dragging, and then inspect the bindings.

My PLC is Version 31 so i used the drivers for V20+

If you cast 24.2 to an integer (so 24), its binary representation is 00000000000000000000000000011000

if you interpret that as a float, it’s indeed 3.36311631E-44

So I guess somewhere down the road, it gets cast to an int, and interpreted again as a 32-bit float. Warning: if you bind it to a numeric text field, the type you use for binding also matters.

If I may do a wild guess, is it possible you have two bindings on the numeric text field? They can influence each other.

I used this tool to do some conversions: https://www.h-schmidt.net/FloatConverter/IEEE754.html

1 Like