Update cdsFilt authored by Ezekiel Dohmen's avatar Ezekiel Dohmen
# Overview # Overview
All three simulink blocks use the same underlying logic in the RCG, they differ in how much control they expose to connected model logic. All three simulink blocks use the same underlying logic in the RCG, they differ in how much control they expose to connected model logic.
Generally speaking the `cdsFilt*` blocks take a floating point value as input then processes that input according to the blocks configuration. The block is configured at run-time through associated EPICS channels, often controlled through medm screens. Configuration can be complex with a number of options that can be combined to achieve the desired output. These blocks contain 10 infinite impulse response (IIR) filters, but the filter coefficients can be enabled/disabled so it may only be a pass through under some configurations. Generally speaking the `cdsFilt*` blocks take a floating point value as input then processes that input according to the blocks configuration. The block is configured at run-time through associated EPICS channels, often controlled through medm screens. Configuration can be complex with a number of options that can be combined to achieve the desired output. These blocks contain 10 infinite impulse response (IIR) filters, but the filter coefficients can be enabled/disabled so it may only be a pass through under some configurations.
### Writable EPICS Configuration ### Writable EPICS Configuration
| Channel Suffix | Function | Separate Enable/Disable Bit | | Channel Suffix | Function | Separate Enable/Disable Bit |
| ----------- | ------------------------------------------- | ---- | | ----------- | ------------------------------------------- | ---- |
| `_OFFSET` | An offset that will be added to the sum of the input and excitation in the module.. | Yes | | `_OFFSET` | An offset that will be added to the sum of the input and excitation in the module.. | Yes |
| `_GAIN` | A value that will be multiplied but the output of the 10 filters in the module. | No | | `_GAIN` | A value that will be multiplied but the output of the 10 filters in the module. | No |
| `_TRAMP` | The time (in seconds) that the module will ramp its output over. TODO: on a new config? | No | | `_TRAMP` | The time (in seconds) that the module will ramp its output over. TODO: on a new config? | No |
| `_LIMIT` | An upper value that output of the module will be limited to. | Yes | | `_LIMIT` | An upper value that output of the module will be limited to. | Yes |
| `_SW1` | Momentary filter switch selections, lower 16 bits. [bitmap](cdsFilter*-Switch-(SW)-Settings) | No | | `_SW1` | Momentary filter switch selections, lower 16 bits. [bitmap](cdsFilter*-Switch-(SW)-Settings) | No |
| `_SW2` | Momentary filter switch selections, upper 16 bits. [bitmap](cdsFilter*-Switch-(SW)-Settings) | No | | `_SW2` | Momentary filter switch selections, upper 16 bits. [bitmap](cdsFilter*-Switch-(SW)-Settings) | No |
| `_RSET` | Momentary channel used to clear filter histories or (re)load coefficients. [bit 0 -> load coef, bit 1 -> reset history](https://git.ligo.org/cds/software/advligorts/-/blob/master/src/include/fm10Gen_types.h#L48) | No | | `_RSET` | Momentary channel used to clear filter histories or (re)load coefficients. [bit 0 -> load coef, bit 1 -> reset history](https://git.ligo.org/cds/software/advligorts/-/blob/master/src/include/fm10Gen_types.h#L48) | No |
### Read Only EPICS Configuration ### Read Only EPICS Configuration
| Channel Suffix | Function | Sample Rate | | Channel Suffix | Function | Sample Rate |
| ----------- | ------------------------------------------- | ---- | | ----------- | ------------------------------------------- | ---- |
| `_INMON` | The latest value inputted to the module. | 16 Hz | | `_INMON` | The latest value inputted to the module. | 16 Hz |
| `_EXCMON` | The latest value from the excitation input to the filter. | 16 Hz | | `_EXCMON` | The latest value from the excitation input to the filter. | 16 Hz |
| `_OUTMON` | The latest value of the filter, after all processing. (OUT on medm) | 16 Hz | | `_OUTMON` | The latest value of the filter, after all processing. (OUT on medm) | 16 Hz |
| `_OUT16` | The latest value of the filter, after all processing and filtered/decimated to 16 Hz. TODO: Add filter description (OUT on medm) | 16 Hz | | `_OUT16` | The latest value of the filter, after all processing and filtered/decimated to 16 Hz. TODO: Add filter description (OUT on medm) | 16 Hz |
| `_OUTPUT` | The latest value of the filter, after all processing, taking into account filter output setting. `_OUTMON` will always have the calculated output, this channel will be 0 if the module's output is configured to be off. | 16 Hz | | `_OUTPUT` | The latest value of the filter, after all processing, taking into account filter output setting. `_OUTMON` will always have the calculated output, this channel will be 0 if the module's output is configured to be off. | 16 Hz |
| `_SW1R` | Filter switch selections readback, lower 16 bits. [bitmap](cdsFilter*-Switch-(SW)-Settings) | 16 Hz | | `_SW1R` | Filter switch selections readback, lower 16 bits. [bitmap](cdsFilter*-Switch-(SW)-Settings) | 16 Hz |
| `_SW2R` | Filter switch selections readback, upper 16 bits. [bitmap](cdsFilter*-Switch-(SW)-Settings) | 16 Hz | | `_SW2R` | Filter switch selections readback, upper 16 bits. [bitmap](cdsFilter*-Switch-(SW)-Settings) | 16 Hz |
| `_SW1S` | The momentary _SW1/2 channels are not good for SDF management, because their state is not sticky. These _SW1/2***S*** versions are sticky and can also be used to command state changes for filter modules. This has the same bitmap as the [_SW1/2](cdsFilter*-Switch-(SW)-Settings) versions. | 16 Hz | | `_SW1S` | The momentary _SW1/2 channels are not good for SDF management, because their state is not sticky. These _SW1/2***S*** versions are sticky and can also be used to command state changes for filter modules. This has the same bitmap as the [_SW1/2](cdsFilter*-Switch-(SW)-Settings) versions. | 16 Hz |
| `_SW2S` | See function above. | 16 Hz | | `_SW2S` | See function above. | 16 Hz |
| `_Name00` - `_Name09` | The names of the individual filters, set when coefficients are loaded from the filter file. | 16 Hz | | `_Name00` - `_Name09` | The names of the individual filters, set when coefficients are loaded from the filter file. | 16 Hz |
### DAQ Capable Fast Channels ### DAQ Capable Fast Channels
DAQ channels are generated for each filter module, but need to be added to the DAQ channel list to be recorded by the DAQ. DAQ channels are generated for each filter module, but need to be added to the DAQ channel list to be recorded by the DAQ.
You do this by adding the name of the channel (without the '_DQ' suffix) to a DAQ Channel block. More info about the DAQ Channels block here(TODO). You do this by adding the name of the channel (without the '_DQ' suffix) to a DAQ Channel block. More info about the DAQ Channels block here(TODO).
> ![image](uploads/261973e8325cf35f9e6b3c70230ae936/image.png) > ![image](uploads/261973e8325cf35f9e6b3c70230ae936/image.png)
| Channel Suffix | Function | Sample Rate | | Channel Suffix | Function | Sample Rate |
| ----------- | ------------------------------------------- | ---- | | ----------- | ------------------------------------------- | ---- |
| `_EXC_DQ` | The latest value from the excitation input to the filter. (EXC on medm) | Full Model Rate, unless decimated in DAQ channel list | | `_EXC_DQ` | The latest value from the excitation input to the filter. (EXC on medm) | Full Model Rate, unless decimated in DAQ channel list |
| `_IN1_DQ` | The latest value inputted to the module. (IN1 on medm) | Full Model Rate, unless decimated in DAQ channel list | | `_IN1_DQ` | The latest value inputted to the module. (IN1 on medm) | Full Model Rate, unless decimated in DAQ channel list |
| `_IN2_DQ` | The latest value from the excitation input summed with the input to the filter. (IN2 on medm) | Full Model Rate, unless decimated in DAQ channel list | | `_IN2_DQ` | The latest value from the excitation input summed with the input to the filter. (IN2 on medm) | Full Model Rate, unless decimated in DAQ channel list |
| `_OUT_DQ` | The latest value of the filter, after all processing. (OUT on medm) | Full Model Rate, unless decimated in DAQ channel list | | `_OUT_DQ` | The latest value of the filter, after all processing. (OUT on medm) | Full Model Rate, unless decimated in DAQ channel list |
## cdsFilt ### DAQ Slow Channel
> ![image](uploads/ee62f8c4c1e67cc7f1a5afa094489300/image.png) The `_SWSTAT` channel is an attempt to consolidate relevant information for storage in a DAQ data channel.
![image](uploads/01bcbbc15c30557dc1b554983ffb599e/image.png)
The `cdsFilt` part has all the above mentioned EPICS channels. Each model cycle, the input to the filter module is read, processed by the module with its current configuration and the result is passed out from the model's output port.
## cdsFilt
### `medm` Overview > ![image](uploads/ee62f8c4c1e67cc7f1a5afa094489300/image.png)
The RCG generates a medm screen for each filter module in the model. Below is an example of one such screen.
The `cdsFilt` part has all the above mentioned EPICS channels. Each model cycle, the input to the filter module is read, processed by the module with its current configuration and the result is passed out from the model's output port.
> ![image](uploads/e502edb6cde71f2fa748038a583c6945/image.png)
### `medm` Overview
The screens generated for all three types filter modules are very similar, so we will only go over one here. In this screenshot the filter's input, FM1, output are enabled. The gain is also set to one. You can click on the grey boxes to command actions, like turning on filters, clearing history and enabling/disabling the output. If a specific control is under local control (marked with a yellow "LC") you won't be able to change it from the medm (more on that below). The RCG generates a medm screen for each filter module in the model. Below is an example of one such screen.
## cdsFiltCtrl > ![image](uploads/e502edb6cde71f2fa748038a583c6945/image.png)
> ![image](uploads/b3f22055273c4c6d873234badacd8c51/image.png)
The screens generated for all three types filter modules are very similar, so we will only go over one here. In this screenshot the filter's input, FM1, output are enabled. The gain is also set to one. You can click on the grey boxes to command actions, like turning on filters, clearing history and enabling/disabling the output. If a specific control is under local control (marked with a yellow "LC") you won't be able to change it from the medm (more on that below).
The `cdsFiltCtrl` block adds two additional inputs and 1 additional output.
| Port Name | Function | ## cdsFiltCtrl
| --------- | -------- | > ![image](uploads/b3f22055273c4c6d873234badacd8c51/image.png)
| In1 | Input sample, same as `cdsFilt`. |
| Cin | Control input. A bitfield containing controls bits for the filter provided by the realtime logic, instead of EPICS channels like in the `cdsFilt` case. | The `cdsFiltCtrl` block adds two additional inputs and 1 additional output.
| Mask | Local control (LC) bitfield mask. This specifies the control bits that are controlled by the models realtime logic, instead of EPICS channels like in the `cdsFilt` case.| | Port Name | Function |
| Val | The output sample, same as `cdsFilt`. | | --------- | -------- |
| Ctrl | The current commanded control state of the filter module. This includes the state from the EPICS channels overridden by any control bits provided to Cin and masked by the Mask input. | | In1 | Input sample, same as `cdsFilt`. |
| Cin | Control input. A bitfield containing controls bits for the filter provided by the realtime logic, instead of EPICS channels like in the `cdsFilt` case. |
#### Cin/Mask Explanation | Mask | Local control (LC) bitfield mask. This specifies the control bits that are controlled by the models realtime logic, instead of EPICS channels like in the `cdsFilt` case.|
When valid bits are set in the Mask input, the filter module will use the corresponding bits from the Cin input instead of the normal `_SW1` and `_SW2` EPICS channels. This allows the realtime model to control a subset of the filters control flags. When these options are controlled in this manner, we call it being under "local control". The medm screens will draw a yellow "LC" by elements displayed on the filter screen that are being masked (corresponding bits high in Mask input). | Val | The output sample, same as `cdsFilt`. |
| Ctrl | The current commanded control state of the filter module. This includes the state from the EPICS channels overridden by any control bits provided to Cin and masked by the Mask input. |
> ![image](uploads/c7fa73a8681b970d828415cd15c7eca7/image.png)
#### Cin/Mask Explanation
The FMX bits tell the individual filters to enable, and the output, offset and enable bits control if those options should be enabled/disabled. When valid bits are set in the Mask input, the filter module will use the corresponding bits from the Cin input instead of the normal `_SW1` and `_SW2` EPICS channels. This allows the realtime model to control a subset of the filters control flags. When these options are controlled in this manner, we call it being under "local control". The medm screens will draw a yellow "LC" by elements displayed on the filter screen that are being masked (corresponding bits high in Mask input).
#### Additional EPICS channel > ![image](uploads/c7fa73a8681b970d828415cd15c7eca7/image.png)
The `_MASK` channel is made available with `cdsFiltCtrl` and `cdsFiltCtrl2` parts. This is a read only channel that records the value of the Mask input port.
The FMX bits tell the individual filters to enable, and the output, offset and enable bits control if those options should be enabled/disabled.
## cdsFiltCtrl2
> ![image](uploads/57810c0ef713546b85e35fb780a6290c/image.png) #### Additional EPICS channel
The `_MASK` channel is made available with `cdsFiltCtrl` and `cdsFiltCtrl2` parts. This is a read only channel that records the value of the Mask input port.
The `cdsFiltCtrl2` is the same as the `cdsFiltCtrl` part, except for some renamed inputs, additional inputs, outputs and control bits. This part only exposes more of the filter module for realtime control.
## cdsFiltCtrl2
| Port Name | Function | > ![image](uploads/57810c0ef713546b85e35fb780a6290c/image.png)
| --------- | -------- |
| Input | Input sample, same as `cdsFilt`. | The `cdsFiltCtrl2` is the same as the `cdsFiltCtrl` part, except for some renamed inputs, additional inputs, outputs and control bits. This part only exposes more of the filter module for realtime control.
| CtrlIn | Control input. A bitfield containing controls bits for the filter provided by the realtime logic, instead of EPICS channels like in the `cdsFilt` case. |
| Mask | Local control (LC) bitfield mask. This specifies the control bits that are controlled by the model's realtime logic, instead of EPICS channels like in the `cdsFilt` case.| | Port Name | Function |
| OffsetIn | An offset value that should be used when masked and enabled with Mask/CtrlIn. | | --------- | -------- |
| GainIn | A Gain value that should be used when masked and enabled with Mask/CtrlIn. | | Input | Input sample, same as `cdsFilt`. |
| RampIN | A TRAMP value that should be used when masked and enabled with Mask/CtrlIn | | CtrlIn | Control input. A bitfield containing controls bits for the filter provided by the realtime logic, instead of EPICS channels like in the `cdsFilt` case. |
| Output | The output sample, same as `cdsFilt`. | | Mask | Local control (LC) bitfield mask. This specifies the control bits that are controlled by the model's realtime logic, instead of EPICS channels like in the `cdsFilt` case.|
| CtrlOut | The current commanded control state of the filter module. This includes the state from the EPICS channels overridden by any control bits provided to Cin and masked by the Mask input. | | OffsetIn | An offset value that should be used when masked and enabled with Mask/CtrlIn. |
| OffsetOut | The offset currently being used by the filter module. This will be the OffsetIn if that option is masked by the Mask input and the EPICS channel `_OFFSET` if not. | | GainIn | A Gain value that should be used when masked and enabled with Mask/CtrlIn. |
| GainOut | The Gain currently being used by the filter module. This will be the GainIn if that option is masked by the Mask input and the EPICS channel `_GAIN` if not. | | RampIN | A TRAMP value that should be used when masked and enabled with Mask/CtrlIn |
| RampOut | The offset currently being used by the filter module. This will be the RampIn if that option is masked by the Mask input and the EPICS channel `_TRAMP` if not. | | Output | The output sample, same as `cdsFilt`. |
| CtrlOut | The current commanded control state of the filter module. This includes the state from the EPICS channels overridden by any control bits provided to Cin and masked by the Mask input. |
#### CtrlIn and Mask Explanation | OffsetOut | The offset currently being used by the filter module. This will be the OffsetIn if that option is masked by the Mask input and the EPICS channel `_OFFSET` if not. |
> ![image](uploads/3df96fb0fcb57b6f8f7a5b24d0117e92/image.png) | GainOut | The Gain currently being used by the filter module. This will be the GainIn if that option is masked by the Mask input and the EPICS channel `_GAIN` if not. |
| RampOut | The offset currently being used by the filter module. This will be the RampIn if that option is masked by the Mask input and the EPICS channel `_TRAMP` if not. |
This is the same bit order as the `cdsFiltCtrl`, however there are now three additional most significant bits that mask/control if the module should use the offset, gain and ramp provided by the realtime model instead of the EPICS inputs.
#### CtrlIn and Mask Explanation
> ![image](uploads/3df96fb0fcb57b6f8f7a5b24d0117e92/image.png)
This is the same bit order as the `cdsFiltCtrl`, however there are now three additional most significant bits that mask/control if the module should use the offset, gain and ramp provided by the realtime model instead of the EPICS inputs.