GenericFilter¶
This block is a configurable filter, which supports several filter types, such as low-pass, high-pass, lag or lead, notch or a custom configured type in either continuous-time or discrete-time.
This filter solves some of the limitations of generic Simulink filter blocks:
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 filter is implemented in discrete-time as a generic filter. The discrete-time transfer function of the filter is:
The filter configuration and implementation are shown below.
The filter is discretized assuming a fixed sample rate. Therefore, only fixed-step solvers are allowed. When attempting to start a Simulink® simulation with a variable-step solver, an error is displayed.
The input port Reset
can be used to clear the states in the filter.
Hint
When connected to the (inverted) CloseLoopRequest
signal of the command queue, the Reset
input can be used to ensure that the output of the filter is zero when disabling the control loop.
Parameters and Dialog Box¶
- Filter type
Popup box for selecting the possible filter types, defined in the table below on the right.
- 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.
|
- Parameter[0-4]
The parameters are used to configure the generic filter. The meaning of each parameter differs per filter type and is explained in the table below.
Filter type |
0 |
1 |
2 |
3 |
4 |
---|---|---|---|---|---|
Pass-through |
N/A |
N/A |
N/A |
N/A |
N/A |
1st order low pass |
gain (a) |
Frequency [Hz] (f) |
N/A |
N/A |
N/A |
2nd order low pass |
gain (a) |
Frequency [Hz] (f) |
Damping (b) |
N/A |
N/A |
1st order high pass |
gain (a) |
Frequency [Hz] (f) |
N/A |
N/A |
N/A |
2nd order high pass |
gain (a) |
Frequency [Hz] (f) |
Damping (b) |
N/A |
N/A |
1st order lag or lead |
gain (a) |
Pole frequency [Hz] (f2) |
N/A |
Zero frequency [Hz] (f1) |
N/A |
2nd order notch |
gain (a) |
Pole frequency [Hz] (f2) |
Pole damping (b2) |
Zero frequency [Hz] (f1) |
Zero damping (b1) |
2nd order generic Z |
B0 |
B1 |
B2 |
A1 |
A2 |
2nd order generic S |
B0 |
B1 |
B2 |
A1 |
A2 |
Note
Some combinations of parameters yield invalid filter configurations. For example, the FirstOrderLowPass filter with a cut-off frequency of zero leads to a division by zero. Such filter configurations are not allowed. Invalid parameters are handled as follows:
When starting simulation: An error is displayed and the simulation is not started.
During simulation: A warning is displayed in the Diagnostic Viewer and in the Command Window. The simulation is proceeded with the last valid set of parameters.
Data Type Support¶
- Input ports
- The input port
Input
accepts only signals of typesingle
.The input portReset
accepts only signals of typeboolean
. - 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
GenericFilter1
in Subsystemmodelname/SubsystemFoo/SubsystemBar
becomesSubsystemFoo_SubsystemBar_GenericFilter1
.- Signals
The following signals are generated in PMP:
¶ Signal Name
Access
Data Type
Description
Type
RW
Float
Selected filter type.
Parameter0
RW
Float
Continuous-time generic filter parameter 0.
Parameter1
RW
Float
Continuous-time generic filter parameter 1.
Parameter2
RW
Float
Continuous-time generic filter parameter 2.
Parameter3
RW
Float
Continuous-time generic filter parameter 3.
Parameter4
RW
Float
Continuous-time generic filter parameter 4.
ParameterB0
R
Float
Discrete-time generic filter parameter B0.
ParameterB1
R
Float
Discrete-time generic filter parameter B1.
ParameterB2
R
Float
Discrete-time generic filter parameter B2.
ParameterA1
R
Float
Discrete-time generic filter parameter A0.
ParameterA2
R
Float
Discrete-time generic filter parameter A1.