Studio 5000 Exponential error

Dave Steer

Member
Join Date
Nov 2002
Location
Devon
Posts
27
Hi Everyone. Not posted on here for a long time, but I am hoping someone can help me.

I am doing a differential pressure calculation in a L27ERM CompactLogix controller.
The dP test requires to calculate viscosity of water using temperature. The formula is below

1714126248196.png
so I use CPT instruction for A, B, C and D and with 1.257187E-02 and I get the correct exponential value of 0.01257187 for A.

B and C also give the correct result but when I get to D, I should get a value of -0.000005723952 but I just get out the value that I put in. I am guessing that the REAL value is not a high enough resolution. I have also tried this in structured text and got the same result. Because the value of -0.000005723952 is a constant, I even tried just doing a move and entering the value, but it just goes to 0.01257187.

Has anyone any ideas what is wrong and how to do this?

Thanks in advance
Dave
 

What do you mean by "when I enter [a value] I get [a value]?"

Where are you entering these values? Where are you "getting"these values?

Is it in the Studio 5000 IDE? Is the IDE in offline mode or in online mode?

Are the values you "get" the ones displayed in the CPT instruction expression parameter in offline mode, or is the value you "get" the result of the CPT instruction's calculation in run mode?
 
What do you mean by "when I enter [a value] I get [a value]?"

Where are you entering these values? Where are you "getting"these values?

Is it in the Studio 5000 IDE? Is the IDE in offline mode or in online mode?

Are the values you "get" the ones displayed in the CPT instruction expression parameter in offline mode, or is the value you "get" the result of the CPT instruction's calculation in run mode?
Sorry I was not very clear.

I am working online to the processor with it in run.

The customer has provided me with an Excel spreadsheet with all the above calculations entered. This allows me to see what the expected values will be.

So using a CPT instruction for each required calculation I add the expression;
1.257187E-02 the destination REAL gives me A= 0.01257187 This corresponds with the value I see in the spreadsheet.
-5.806436E-03 the destination REAL gives me B= -0.005806436 This corresponds with the value I see in the spreadsheet
1.130911E-03 the destination REAL gives me C= 0.001130911 This corresponds with the value I see in the spreadsheet
-5.723952E-06 the destination REAL gives me D= -5.72395220E-006 This is incorrect as the calculated value should be -0.000005723952
I have tried using the same value but with -5.723952E-03 at the end. It does give me the correct number but without 3 decimal places. This totally messes up the final equation. This is why I think a lack of resolution for the number of decimal places in the PLC.

Hope this made a bit more sense.

Dave
 
So you are saying you don't think -5.723952E-06 is the same as -5.72395220E-006, and that is the problem you are having?
 
Just to add some clarification to the above.

You may have never come across the concept of scientific notation. It is a way to express real numbers in a standard format using a code. The "E" in the code means "times ten to the power of the number after the E". Any real number can be represented in scientific notation. The effect of multiplying by a power of 10 is that the decimal is moved the number of places designated by the exponent. Multiplying by 10^1 moves the decimal point one place to the left. Multiplying by 10^(-1) moves the decimal point one place to the right.

the value you say you want, -0.000005723952 can be expressed by ALL of the following. They all represent the same underlying value:

-0.000005723952
-0.00005723952 * 10 ^ -1 => -0.00005723952E-01
-0.0005723952 * 10 ^ -2 => -0.0005723952E-02
-0.005723952 * 10 ^ -3 => -0.005723952E-03
-0.05723952 * 10 ^ -4 => -0.05723952E-04
-0.5723952 * 10 ^ -5 => -0.5723952E-05
-5.723952 * 10 ^ -6 => -5.723952E-06

The "rule" for scientific notation is that you pick the exponent of 10 so that you have one, non-zero digit to the left of the decimal point and the rest of the digits to the right of the decimal point.

Studio 5000 probably has a default number display width. If the resulting number has a lot of leading or trailing zeros, it will convert that number to its equivalent scientific notation representation to make the overall display narrower. It looks different but the number is EXACTLY the same as the one without the Exx version.
 
Incidentally, that's how the IEEE floating point format works. You convert the base 10 to base 2 and then shift the radix point (decimal point in base 10) X times until you have 1 significant binary digit before the radix point. The value of "X" then gets encoded as the exponent section. This is from Wikipedia:
IEEE 754 Floating point format.PNG

You can really get into the weeds with this, but sometimes it's necessary. If you think about it (and do a few manual conversions), you'll understand why some rational decimal numbers end up irrational in the binary world and then don't seem to display correctly due to rounding errors.
 
No -5.723952E-06 should output -0.000005723952
why?
...

Studio 5000 probably has a default number display width. If the resulting number has a lot of leading or trailing zeros, it will convert that number to its equivalent scientific notation representation to make the overall display narrower. It looks different but the number is EXACTLY the same as the one without the Exx version.

This. It does not matter if the displayed text is "-5.723952E-06" or "-0.000005723952", the PLC-internal value that is the result of the CPT instruction is the same; as Norm suggests Studio 5000 uses the shorter exponential form (-5....e-06) because the leading zeros of the non-exponential form (0.000005...) make the displayed text unnecessarily long.

Consider if the value was 5.7E-20; would you want to see, and have to visually count and mentally track, nineteen leading zeros?
 
This is LibreOffice not eXcel showing three cells (A1, A2, A3)
  • on the left with their displayed values, and
  • on the right the same three cells with their formulas displayedl
  • it also shows the formatting of A2 i.e. fixed-point (non-exponential) with 12 decimal places displayed
    • The formatting for A1 is the numeric default called "General", which allows exponential display

It demonstrates that the numeric value -5.7...E-06 is the same as the numeric value -0.00000057...

Note that the value in cell A1 is a string, not a number; cell A2 is where the string "-5.723952E-06" is converted to a number.

xxx.png
 
Last edited:
1. You have too many significant digits. There's no way you're measuring temperature to 7 sigfigs with a PLC; you'd need a minimum 20-bit ADC.
2. This blows up below 50ish kelvin which isn't likely but you should guard the computation against small inputs.
3. Compute like this instead: exp(ln A + ((1/T + B) / (C + DT))) .. doing it like this you reduce the number of operations and you could probably get away without doing the final exponentiation since it's a one-to-one function.
 

Similar Topics

Hi Everyone, I am facing an issue while installing the STUDIO 5000 in my windows 10 PC. During installation I am getting an error that " Error...
Replies
2
Views
71
I am connecting to a remote device. When attempting to upload I receive an error that states: Error: Auto_Functions: The Import was aborted due...
Replies
3
Views
155
I recently did a program conversion from logix 500 to studio 5000 and when machine runs it depends on two ton instructions to keep the machine in...
Replies
17
Views
524
Hi, how do I convert 2x Integer registers to a Real? The two integers are from Modbus registers that contain a floating point value, I need to...
Replies
2
Views
141
Back
Top Bottom