Introduction
A Motoman Application Engineer recently developed logic to allow a background (system) job to implement a PID Loop. This document explains the concept and provides a copy of the job for possible use by others.
What is a PID Loop?
“A proportional–integral–derivative (PID) controller, or three-term controller, is a feedback-based control loop mechanism commonly used to manage machines and processes that require continuous control and automatic adjustment. It is typically used in industrial control systems and various other applications where constant control through modulation is necessary without human intervention. The PID controller automatically compares the desired target value (setpoint or SP) with the actual value of the system (process variable or PV). The difference between these two values is called the error value, denoted as e(t).
It then applies corrective actions automatically to bring the PV to the same value as the SP using three methods: The proportional (P) component responds to the current error value by producing an output that is directly proportional to the magnitude of the error. This provides immediate correction based on how far the system is from the desired setpoint. The integral (I) component, in turn, considers the cumulative sum of past errors to address any residual steady-state errors that persist over time, eliminating lingering discrepancies. Lastly, the derivative (D) component predicts future error trend by assessing the rate of change of the error, which helps to mitigate overshoot and enhance system stability, particularly when the system undergoes rapid changes. The PID output signal can directly control actuators through voltage, current, or other modulation methods, depending on the application. The PID controller reduces the likelihood of human error and improves automation.”
Implementation
Our engineer reported:
“For an upcoming dispense project I needed a PID loop function to control an output.
Attached is a system job that is written to modulate a control output (pressure) to target a setpoint (volumetric flowrate). I used variable aliasing so I could write it out in the equations I was copying.
I included tunable gain factors as well. I am controlling the gain on an IF panel.”
If you are unfamiliar with variable aliasing, the Knowledge Center article linked here explains it.
The System Job Function is explained here: System Job Function When enabled, it allows the creation of a non-motion job to run continuously in the background. Contact Yaskawa Technical support to request System Job functionality be enabled on your controller.
The Job
Below is an excerpt from the PD job (without the job header. A complete JBI file is attached.
NOP
*PID_LOOP
'
'________________________________
'Error Calculation
SET Error_Sum EXPRESS Set_Flowrate - Feedback_Flowrat
'
'________________________________
'Proportional Calculation
SET Proportional_Val EXPRESS Proportional_Gn * Error_Sum
'
'________________________________
'Integral Calculation
SET Integral_Calc EXPRESS Intergral_Gain * Error_Sum * Loop_Cycle_Time
SET Integral_Value EXPRESS Integral_Value + Integral_Calc
'
'________________________________
'Derivative Calculation
SET Derivative_Value EXPRESS Derivative_Gain * ( Error_Sum - Previous_error ) / ( Loop_Cycle_Time )
'
'________________________________
'Output Calculation
SET Output_Pressure EXPRESS Proportional_Val + Integral_Value + Derivative_Value
'
'________________________________
'Saving current error
SET Previous_error Error_Sum
'
DELAY 10
JUMP *PID_LOOP
END
Comments
0 comments
Please sign in to leave a comment.