# exponential in float

## Recommended Posts

Hey All

I have a data monitoring control that talks to a mass flow meter via modbus.
I"m simply reading a float number and storing it to a data table every minute.
I then use DataXport to put the data table into an Excel file that our bean counters use for what ever they do....

An issue I've been shown is that occasionally I get an number in exponential form, and this of course muks up the bean counters report.

At this point I'm trying to figure out if this is what Unitronics does when it sees too many decimal places in a float or if that's what I'm getting from this mass flow device.

Anyone have any insight on this?

Is there an easy way to limit how many decimal places, or round it off at X number of places

UPDATE I was thinking that I was getting an exponential when the number had too many decimal places.

but I've dug out my scientific calculator and see this is not the case

two numbers on yesterdays  data are ;

9.24E-02 which converts to 0.0924

8.56E-02 which converts to 0.0856

so at this point I'm leaning to the issue being from the device not something with in unitronics

Opinions????

JohnR

##### Share on other sites

Hi John,  ( and in posting this I've now just had your update come up, so maybe this is irrelevant!)

1).  I'd first be looking at the exponential number and seeing if it is way out of range compared to those around it, indicating a gliche in the actual reading and might be the real reason for the exp.  If it is, then it likely needs to be replaced with an average derived from a suitable sample either side of it.  This would mean a delay system in your table writing.

2).  If it isn't way out of range, then look at it directly in your table before conversion.  If there is an odd structure to the number then one possibility would be to do some simple maths (X 1 and quotient usage) on every read before you put it in the table, to ensure that it only has structure that will be recognised correctly.

3).  Pre-format a complete Excel sheet area to your desired style?  This would likely involve a cut and paste process which might be a PITA, and may or may not work anyway.

4).  Can the meter output it in a different format that might be easier to work with?

5).  Scratch head and wait for other answers from someone who might have encountered this already?  I haven't....but I don't deal with floats a lot.

cheers, Aus

##### Share on other sites

Hey Aus,

Thanks for the input....

Unfortunately, I blow out the data table every morning, so by the time I wanted to compare that to the data in the excel file it was already gone.

I will have to monitor it through out to day and see if I can catch it misbehaving.

in yesterdays data my numbers range from 0.1059184 up to 7.88904 (and everything in between), and the two exponents come in with one zero after the decimal place. 0.0924 & 0.0856, so perhaps this device just outputs  in exp when the numbers get this small.

I will have to get hold of the tech from the mass flow place and see if he can confirm

JohnR

##### Share on other sites

The thing I have trouble with is that I can't understand how the modbus read of an exponential is actually happening.  I would have thought that the read would go totally pearshaped with the introduction of the "E-".  Because of this, to me it appears that it is being applied somewhere else through the path.  It would be a little exercise for you to add in a few things so that you can do a trial and test what happens with sending various amounts to a modbus float read.  It would actually show where in the path the "show this as an Exp" rule is being applied.    I can't find any reference at all to behaviour like this in the Visi literature.  Perhaps the creators or Joe or others might know some quirk I don't.  It might actually be in the conversion process coming out of DataXport.

cheers, Aus

##### Share on other sites

I captured this today, the Vision data table on the left, the DataXport created Excel file (.csv format) on the right

the number is stored in the data table as E-notation, and shortened when stored into the excel file

at this point I'm still guessing this is created within the mass flow device, I've not yet been able to verify this with the oem

but I cant see that vision would be reformatting this on a modbus read

##### Share on other sites
On 8/22/2019 at 8:48 AM, JohnR said:

in yesterdays data my numbers range from 0.1059184 up to 7.88904 (and everything in between), and the two exponents come in with one zero after the decimal place. 0.0924 & 0.0856, so perhaps this device just outputs  in exp when the numbers get this small.

Yes.

The floating point format in Unitronics is 8 significant digits.  When 0.0xxx or smaller  is encountered it automatically converts it to an exponent.  Depending on how much precision you actually need, you may have to intercept the numbers as they are read and do something to round them out.

I tried converting floats to integers and back using both MIs to get four decimal places and MLs to get six.  Assuming six is enough, this may work for you.

Joe T.

##### Share on other sites
11 hours ago, Joe Tauser said:

The floating point format in Unitronics is 8 significant digits.  When 0.0xxx or smaller  is encountered it automatically converts it to an exponent.

Well, there ya go....
I could see that the conversion to exponent was happening on numbers smaller than 0.0xxx
but never thought this would be happening within the Vision logic/math.

The mass flow sensor has a lower threshold setting that below this setting it outputs a zero.
The Quality Assurance guy working with this data was freaking out because he was getting zeros (even though I affirmed that this is the nature of the process, sometimes the control backs off enough that it stops the flow).

I had turned down this threshold setting so we we getting more numbers than zeros,
which I believe is when we started seeing the exponents, which freaked out the QA guy even more.
probably my quickest fix is to bump up that threshold until I get above that 0.0xxx point.

Thanks Joe......

JohnR

##### Share on other sites

Unfortunately I'm like a dog with a bone on this sort of thing.  It was gnawing away at my brain, saying there was something I was missing.    During all this topic's progress, I couldn't do a test-bench trial.  Joe's answer also reinforced my "missing something" thinking.  As is usual for my brain, I woke today to the (exceedingly obvious!) revelation that I could have gone online to any of my remote plcs and simply entered various amounts in an unused MF to test theories.   Duhhh!

Anyway, here are some screen shots to show examples, both small and large.  The one you can't fully see the real amount entered is 0.000000000012345678954..................tiny amounts are actually able to be worked with!

cheers, Aus

my name is Gomez

##### Share on other sites

I like your Float Family Album.  Which one is Gomez?

😁

Joe T.

##### Share on other sites

Hmmmm.  To  clear up your question, Mr. Cheeky,  look closely.

cheers, Aus

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×

×