Performing Polynomial Fitting on Mitsubishi FX5u PLC

Question:

Is there a method for performing a third-degree polyfit on a PLC? I have input data with a minimum of 5 X and Y values. For instance, the measured values are as follows: Input Value X Y 350 1025 460 987 530 853 680 765 800 556 I am seeking a way to calculate the corresponding Y value by inputting an X value within the range of the measured data. I have achieved this using Python, but the challenge lies in connecting the PLC to a computer, which the customer prefers not to do. Any insights would be appreciated. Thank you.

Top Replies

Data on the variables X and Y, along with their rate of change, are presented in the table above. The question is how frequently these values are updated. Are you looking to dynamically adjust the sampled X and Y values to a polynomial with real-time coefficients in the Programmable Logic Controller (PLC) and subsequently evaluate the polynomial (Y = P(X)) within the PLC program? Alternatively, do you prefer to calculate the fitting coefficients externally, embed them into the PLC program, and solely conduct polynomial evaluations within the PLC?

One alternative to consider is whether the PLC being used offers motion control capabilities. Can the desired action be programmed as a "cam profile" or similar function in the PLC? Additionally, exploring the use of splines can result in more straightforward interpolation algorithms between points on the profile compared to fitting a single set of third-order polynomial coefficients across the entire dataset.

Hello DrBitboy, I need to perform all tasks internally within the PLC as I do not have access to an external PC. Unfortunately, this PLC does not have motion control capabilities. Apologies for the inconvenience. - Luca.

The FX5 PLC is known for its powerful capabilities. Currently, I am unable to load an FX5 Project due to a broken GXW3. I can only load GXW2, which does not support the FX5. However, the FX5 has ample memory and offers a wide range of over 200 instructions, allowing for nearly limitless possibilities. As part of the I/Q/F series, I have successfully completed tasks such as horizontal tank level calculations and implementing a comprehensive recipe system stored in retentive memory.

Is the FX5 capable of performing matrix calculations and handling structured text? If not, you may find yourself entering lengthy equations in ladder logic, which can be tedious. Another challenge is the uneven spacing of x locations. Is it possible to convert the python code into ladder logic, or are you utilizing a python library? When dealing with a third-order equation, does it need to pass through each point precisely, or just provide the best fit? Only 4 points and 4 equations are needed to determine the 4 coefficients for a third-order equation. Since the system of equations is overdetermined, a best fit solution is necessary.

If direct communication between the PLC and Python isn't desirable, you might consider implementing the polynomial regression directly within your PLC code - many PLCs have mathematical function blocks that could be used for this purpose. The coefficients of a third degree polynomial can be determined by a method like Gaussian elimination or using Excel's trendline tool from your given set of points, then used as constants in your PLC code to calculate Y for any given X. Though, the exact method would largely depend upon the capabilities and limitations of your PLC model. Do refer to your PLC documentation to see what might be feasible.

While Python is a versatile tool for these kinds of calculations, I understand your dilemma with needing to connect to the PLC. You could potentially explore using Structured Text (ST) language, often supported by PLCs, to execute more complex mathematical computations like your third-degree polyfit. It holds similarities to high-level languages like Python and can be utilized to write a cubic regression function within PLC. Another alternative could be the use of Ladder Logic, although it's substantially more complex for tasks like these compared to ST. Remember to perform sufficient testing to ensure functionality and increase the robustness of your control system.

The key here would be the capability of the PLC in question, as many PLCs vary in their ability to perform advanced mathematical calculations. You may need to program the PLC to perform the polynomial fitting algorithm. If it allows that level of function, you'd likely want to use a third-degree polynomial regression formula. That said, because this is complex and requires significant computational power, you might want to check if that's feasible with your specific PLC model. Alternatively, if the data points allow, you could approximate the curve with several straight lines which might be more straightforward to implement on a PLC. It really comes down to the exact requirements of your use case and the specifics of your PLC.

More Replies ā†’

Streamline Your Asset Management
See How Oxmaint Works!!

āœ…   Work Order Management

āœ…   Asset Tracking

āœ…   Preventive Maintenance

āœ…   Inspection Report

We have received your information. We will share Schedule Demo details on your Mail Id.

To add a comment, please sign in or register if you haven't already..   

Frequently Asked Questions (FAQ)

FAQ: 1. Is it possible to perform polynomial fitting on a Mitsubishi FX5u PLC?

Answer: - Yes, it is possible to perform polynomial fitting on a Mitsubishi FX5u PLC.

FAQ: 2. What degree of polynomial fitting can be achieved on the PLC?

Answer: - The PLC can perform up to a third-degree polynomial fitting.

FAQ: 3. How many minimum X and Y values are required for polynomial fitting on the PLC?

Answer: - A minimum of 5 X and Y values are required for polynomial fitting on the PLC.

FAQ: 4. How can I calculate the corresponding Y value by inputting an X value within the range of the measured data on the PLC?

Answer: - You can calculate the corresponding Y value by implementing the polynomial fitting algorithm on the PLC with the provided input data.

FAQ: 5. Is it necessary to connect the PLC to a computer for performing polynomial fitting?

Answer: - No, it is not necessary to connect the PLC to a computer for performing polynomial fitting.

Ready to Simplify Maintenance?

Join hundreds of satisfied customers who have transformed their maintenance processes.
Sign up today and start optimizing your workflow.

Request Demo  ā†’