Q&A Community

Troubleshooting Exponential Calculation Error in Studio 5000

Question:

Hello everyone! It's been a while since I last posted here, but I'm in need of some assistance. I'm working on a differential pressure calculation in a L27ERM CompactLogix controller, which involves calculating the viscosity of water based on temperature. I'm using the CPT instruction to input values for A, B, C, and D. While I successfully obtained the correct exponential value for A, B, and C, I'm struggling with D. Instead of getting the expected value of -0.000005723952, I'm only getting the value I input. I suspect that the REAL value may not be of sufficient resolution. I even attempted this in structured text but encountered the same issue. Despite trying different methods, including using a constant value for D, I'm still unable to get the desired result. Any suggestions on what might be causing this issue and how to resolve it would be greatly appreciated. Thank you in advance. - Dave

Top Replies

Dave Steer inquired about the specifics of entering and obtaining values in the Studio 5000 IDE. Are you experiencing issues with entering a value and receiving a different value? It is important to clarify where you are inputting these values and where you are obtaining them from. Is the IDE currently in offline or online mode? Are the values displayed in the CPT instruction's expression parameter in offline mode, or are they the result of the CPT instruction's calculation in run mode?

drbitboy inquired about the discrepancy between the values entered and obtained during programming in Studio 5000 IDE. He asked whether the IDE was in offline or online mode when entering and retrieving values. Additionally, he sought clarification on whether the values displayed were retrieved from the CPT instruction expression parameter in offline mode or from the calculation result in run mode. Apologizing for the confusion, drbitboy explained that he was working online with the processor in run mode, referencing calculations provided in an Excel spreadsheet. By using CPT instructions, he inputted specific expressions to obtain desired values. While most values aligned with the spreadsheet, one value D resulted in an incorrect calculation due to a decimal resolution issue. Attempting to adjust the decimal places, drbitboy encountered challenges in maintaining accuracy for the final equation, potentially attributed to a lack of resolution in the PLC system's decimal handling.

Apologies, it is indeed Studio5000.

Are you suggesting that the value -5.723952E-06 differs from -5.72395220E-006, causing the issue you're facing?

According to drbitboy, are you suggesting that there is a discrepancy between -5.723952E-06 and -5.72395220E-006? The issue at hand seems to be related to the output, as -5.723952E-06 should translate to -0.000005723952.

More Replies

In a statement by Dave Steer, the value of -5.723952E-06 should be displayed as -0.000005723952. Is there a difference between the two representations of the same value? Click to expand for more information.

According to Dave Steer, the number -5.723952E-06 is equivalent to -0.000005723952. This is simply the same figure represented in scientific notation. If you're encountering a problem, it's unlikely to be related to this specific number. Feel free to click to expand for more information.

For those unfamiliar with scientific notation, it is a method used to represent real numbers in a standardized format using an "E" code to signify multiplication by powers of ten. Any real number can be expressed in scientific notation, with the decimal point shifting based on the exponent. For example, multiplying by 10^1 moves the decimal one place to the left, while multiplying by 10^(-1) moves it one place to the right. The value -0.000005723952 can be written in various forms while representing the same value. Studio 5000 may convert numbers with many zeros to scientific notation for a more concise display, although the actual value remains unchanged. This formatting rule ensures that there is a nonzero digit to the left of the decimal point, with the rest following to the right.

The IEEE floating point format operates by converting base 10 numbers to base 2, shifting the radix point a certain number of times to have one significant binary digit before the point. The value of the shift is then encoded as the exponent section according to Wikipedia. It may seem complex at first glance, but delving into the details can be essential. Through manual conversions, it becomes clear why certain rational decimal numbers become irrational in binary form, leading to display discrepancies caused by rounding errors.

When the number -5.723952E-06 is displayed as -0.000005723952, it may be due to Studio 5000's default number display width. The PLC-internal value remains the same, regardless of the format. Studio 5000 opts for the shorter exponential form to prevent unnecessarily long displayed text caused by leading zeros. For instance, if the value was 5.7E-20, displaying nineteen leading zeros would not be practical.

In this comparison between LibreOffice and Excel, we can see a display of three cells (A1, A2, A3) on the left with their respective values, along with the corresponding formulas shown on the right. The formatting of cell A2 is fixed-point with 12 decimal places, while cell A1 uses the default "General" numeric format that allows exponential display. This demonstration highlights the difference between the numeric value -5.7...E-06 and -0.00000057..., showcasing how the same numeric value can be represented differently. It is important to note that the value in cell A1 is a string, not a number, and it is in cell A2 where the string "-5.723952E-06" is converted into a numeric value. Explore this visual representation to understand the nuances of data manipulation in spreadsheet software.

To improve efficiency and reduce rounding errors, consider replacing the denominator with (T*(T*D+C)). This approach requires one less multiplication operation. Additionally, it is beneficial to examine how RSLogix calculates T^2; ideally, it should use T*T rather than a POW(T) function internally. For more information on this technique, refer to Horner's Method, which involves "Hornerizing" polynomials. Horner's Method is a computational algorithm used to efficiently evaluate polynomials. To learn more about this method, visit the Horner's Method Wikipedia page.

1. Avoid overestimating the precision of your temperature measurements with a PLC, as achieving 7 significant figures would require a 20-bit ADC.2. While it's rare for temperatures to drop below 50 kelvin, it's important to safeguard your calculations against low inputs.3. Simplify your computation by using the formula: exp(ln A + ((1/T + B) / (C + DT))), which reduces the number of operations needed and may eliminate the need for the final exponentiation step due to the function's one-to-one nature.

An even more efficient code solution can be achieved by using the formula A multiplied by the exponential of (1.0 or T) plus B, then all of it is bitwise OR-ed with the sum of C and D multiplied by T. (@Cheeseface was quick to beat me to this update!)

I estimated the blow up temperature to be around 200 Kelvins. I also agree that there are too many significant digits in those constants. The precision of the constants is typically around 1 part in 10 million, but this decreases due to the opposite signs in the numerator and denominator. The accuracy of the temperature measurement is generally within 1 part in half a million. Other measurements, such as pressure (dP), are typically accurate to 1 part in 0.016 million at best, or more commonly 1 part in 0.004 million. In reality, it is rare to measure anything with an accuracy better than 1% in practice, which translates to 1 part in 0.0001 million.

I wanted to thank everyone for their responses. Scientific notation is a new concept for me, as I usually deal more with servos. It's reassuring to know that the PLC was correct and I was mistaken. Thank you once again.

Frequently Asked Questions (FAQ)

FAQ: 1. Why am I experiencing an error when calculating the exponential value for parameter D in my differential pressure calculation?

Answer: Answer: The issue you are facing with parameter D could be related to the resolution of the REAL value. It is possible that the precision of the REAL data type is affecting your calculation.

FAQ: 2. How can I troubleshoot the discrepancy in obtaining the expected exponential value for parameter D in my calculation?

Answer: Answer: To troubleshoot this issue, you can try verifying the data types and resolutions being used in your calculation. Additionally, double-check the input values for parameter D and ensure they are correctly assigned in your program.

FAQ: 3. Are there any specific considerations to keep in mind when working with exponential calculations in Studio 5000 or CompactLogix controllers?

Answer: Answer: When working with exponential calculations in Studio 5000 or CompactLogix controllers, it is important to pay attention to the precision and resolution of your data types, especially when dealing with small exponential values like -0.000005723952. Ensuring proper data type handling and precision can help prevent calculation errors.

You must be a registered user to add a comment. If you've already registered,
sign in. Otherwise, register and sign in.