PIDLowPass

pidlp mask

PIDLowPass mask

This block implements a PID filter with a second-order low pass.

By using the PMP filter blocks, some of the limitations of standard Simulink blocks can be avoided:

  • When using continuous-time Simulink blocks, the generated code discretizes the continuous-time parameters in each cycle. This is computationally demanding and will increase the input-output delay of the control network. Such an increase in delay may be problematic in performance-critical applications.

  • When using discrete-time Simulink blocks, the configuration of the filter becomes more difficult. Firstly, control engineers are generally more familiar with continuous-time formulations. Secondly, the discrete-time filter parameters depend on the sample time of the system. When the sample time changes, the response of the filter changes as well.

Implementation

The PIDLowPass block is implemented as shown below.

PIDLowPass implementation

PIDLowPass implementation

The integrator is discretized using Tustin’s method and implemented as shown below.

PIDLowPass integrator implementation

PIDLowPass integrator implementation

The second order low pass filter is implemented as shown below.

Biquad implementation

PIDLowPass biquad implementation

Note that, by default, the low pass filter is not applied to the integrator output. By setting the Enable integrator low-pass check box, the low pass filter is also applied to the integrator. Note that this setting uses a computation load optimization. It produces an exact result when the integrator clip and integrator threshold are not active, but may produce small inaccuracies otherwise.

The input port Reset is used to clear the states in the filter.

The input port IntegratorReset only clears the state of the integrator. E.g., resetting the integrator when the tracking error is zero to prevent overshoot due to accumulated integrator action.

Whenever the integrator saturation becomes active, the IntegratorSaturated output will become true. Otherwise, it will be false.

Parameters and Dialog Box

Discretization method

Popup box selecting the discretization method to convert from continuous-time parameters to discrete-time parameters.

Show discrete-time parameters in diagnostics view

When checked, the discrete-time parameters of the PIDLowPass block are printed to the diagnostics view. This option does not effect the generated code.

PIDLowPass dialog

PIDLowPass dialog

ProportionalGain

Sets the proportional gain.

DifferentiatorFrequency

Sets the differentiator bandwidth frequency in [Hz].

LowPassFrequency

Sets the bandwidth frequency of the second-order low pass filter in [Hz].

LowPassDamping

Sets the damping factor of the second-order low pass filter.

IntegratorFrequency

Sets the integrator bandwidth frequency in [Hz].

IntegratorLowerClip & UpperClip

Parameters setting the lower and upper bounds of the integrator saturation.

The saturation limits are ignored when
IntegratorLowerClipIntegratorUpperClip.
IntegratorThreshold

Sets the value of the integrator input threshold.

Enable integrator low-pass

When checked, a LowPass filter is added to the integrator path. The LowPass filter has the same parameters as the LowPass filter in the PdLowPass path. To keep the calculation load minimal, the implementation merges both Lowpass filters into one Lowpass filter. This optimization is only exact when the IntegratorThreshold is zero and the IntegratorSaturated output is false.

Hint

The IntegratorFrequency is used similar to integral gain in a standard PID controller: a higher IntegratorFrequency results in more integral action. The DiffferentiatorFrequency works opposite: a lower DifferentiatorFrequency corresponds to a higher differential gain in a standard PID controller.

Note

Normally, the discrete-time gain can only be set to zero by configuring DifferentiatorFrequency as Inf. Since PMP signals are rounded to the maximum floating point value, this is not possible in the generated model. Therefore, an exception is added to the discretization such that the discrete-time implementation is set to zero when DifferentiatorFrequency is zero.

Data Type Support

Input ports
The input port Input accepts only signals of type single.
The input port Reset accepts only signals of type boolean.
The input port IntegratorReset accepts only signals of type boolean.
The input port IntegratorLock accepts only signals of type boolean.
Dialog parameters

All dialog parameters must be of type single.

Note

Entering double values will give a warning that precision loss may occur.

Code generation

Filter name

The filter name is inherited from Simulink. To ensure that all filters have a unique name in PMP, the filter name is prefixed with the name of its parent Subsystems. For example, the name of filter PIDLP in Subsystem modelname/SubsystemFoo/SubsystemBar becomes SubsystemFoo_SubsystemBar_PIDLP.

Signals

The following signals are generated in PMP:

PIDLowPass-signals

Signal Name

Access

Data type

Description

ProportionalGain

RW

Float

Proportional gain.

DifferentiatorFrequency

RW

Float

Differentiator bandwidth.

LowPassFrequency

RW

Float

Low pass filter bandwidth.

LowPassDamping

RW

Float

Low pass filter damping.

IntegratorFrequency

RW

Float

Integrator bandwidth.

IntegratorThreshold

RW

Float

Minimum value for the integrator input to be added to the integrator, if the input value is lower than the threshold the input is not propagated.

IntegratorLowerClip

RW

Float

Integrator anti wind-up lower saturation.

IntegratorUpperClip

RW

Float

Integrator anti wind-up upper saturation.

PdLowPassB0

R

Float

Discrete-time second-order PD-lowpass parameter B0.

PdLowPassB1

R

Float

Discrete-time second-order PD-lowpass parameter B1.

PdLowPassB2

R

Float

Discrete-time second-order PD-lowpass parameter B2.

PdLowPassA1

R

Float

Discrete-time second-order PD-lowpass parameter A1.

PdLowPassA2

R

Float

Discrete-time second-order PD-lowpass parameter A2.

IntegratorB0

R

Float

Discrete-time integrator parameter B0.

IntegratorB1

R

Float

Discrete-time integrator parameter B1.

IntegratorOutput

R

Float

Integrator output.