PID controller
A typical proportional/integral/derivative controller that supports feedforward and rate limiting.
JCS Network Configuration
structure.yaml Configuration
type | proc_pid |
Signals - From Process
Signal name | Type | Required | Description |
---|---|---|---|
u | float32 | required | Controller output Signal name can be renamed by the user |
Signals - To Process
Signal name | Type | Required | Description |
---|---|---|---|
setpoint | float32 | required | Setpoint / command input |
feedback | float32 | required | Process / feedback input |
feedforward | float32 | optional | Feed forward input |
kp | float32 | optional | Proportional term gain If not connected, then must be set by parameter proc_pid_kp |
ki | float32 | optional | Integral term gain If not connected, then must be set by parameter proc_pid_kd |
kd | float32 | optional | Derivative term gain If not connected, then must be set by parameter proc_pid_kd |
output_limit | float32 | optional | Output and integrator limit Defines both output limit high and low |
Note: The PID controller breaks out the gains as optional signals. If they are not connected as signals the gains can be set via parameter.
Configuration Parameters
Parameter name | Type | Required | Description |
---|---|---|---|
proc_pid_kp | float32 | optional | Proportional gain term Ignored if signal kp is connected |
proc_pid_ki | float32 | optional | Integral gain term Ignored if signal ki is connected |
proc_pid_kd | float32 | optional | Derivative gain term Ignored if signal kd is connected |
proc_pid_kff | float32 | optional | Feedforward gain term |
proc_pid_limit_out_h | float32 | optional | Controller output limit - high (output_units) |
proc_pid_limit_out_l | float32 | optional | Controller output limit - low (output_units) |
proc_pid_rate_limit_rising | float32 | optional | Controller output rising rate limiter (output_units/s) |
proc_pid_rate_limit_falling | float32 | optional | Controller output falling rate limiter (output_units/s) |
proc_pid_startup_rate_limit | float32 | optional | Startup output limits rate limiter (output_units/s/s) |
proc_pid_derivative_tau | float32 | optional | Derivative filter time constant (s) |
proc_pid_use_derivative_on_measurement | boolean | optional | False: uses derivative on setpoint error computation True: uses derivative on measurement/feedback computation Default value: false |
proc_pid_is_rotational_error | boolean | optional | True: wraps the computed error term \(e[k]\) to the interval \([-\pi, \pi]\) Default value: false |
Normal Operation
The PID controller is implemented via backward Euler transform in parallel form as the following difference equations:
If the parameter option proc_pid_is_rotational_error
is set to false, then the error term is computed as:
If the parameter option proc_pid_is_rotational_error
is set to true, then the error term is computed as:
Here, \(r\) is the setpoint signal and \(y\) is the feedback signal.
The proportional term is computed as:
The integral term is computed as:
If the parameter option proc_pid_use_derivative_on_measurement
is set to false, then the derivative term is computed based on the error:
If the parameter option proc_pid_use_derivative_on_measurement
is set to true, then the derivative term is computed based on the measurement (feedback):
The derivative filter time constant \(\tau\) is set by parameter option proc_pid_derivative_tau
.
The final PID is computed with the added feedforward term \(k_{ff} * ff[k]\):
Limits configured in proc_pid_limit_out_h
and proc_pid_limit_out_l
are applied to the output and the integrator:
Following the limits, a rate limit may be applied to the output by parameters proc_pid_rate_limit_rising
and proc_pid_rate_limit_falling
. If these parameters are set as \(0\) or left unconfigured the rate limiter is disabled.
Startup
During controller startup an aggressive rate limit may be applied via parameter proc_pid_startup_rate_limit
.
This parameter rate limits the controller limits (and in turn the controller integrator), starting from \(0\) until the limits reach the value defined by parameters proc_pid_limit_out_h
and proc_pid_limit_out_l
or the value defined by signal output_limit
(whichever is configured).
Once the rate limited limits equal the pre-defined limits, the startup rate limiter is disabled.
The effect of this limiter is to provide a 'soft' startup, in case of any large controller error present as the system starts.
Set parameter proc_pid_startup_rate_limit
to \(0\), or leave unconfigured to disable the startup rate limiter.