> For the complete documentation index, see [llms.txt](https://www.opal-rt.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.opal-rt.com/docs/smart-power-simulation-software-sps/blocks-functions-tools/control-and-measurements/filters/first-order-filter.md).

# First Order Filter

## Description

<figure><img src="https://799605156-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdlNg8IbOdahCpFCyzxSN%2Fuploads%2Fgit-blob-88bfaf20c4034f3cf2d14f8a34e855429a6ecc8d%2Ffirst_ordre_filter_block.png?alt=media" alt=""><figcaption></figcaption></figure>

The **First Order Filter** block, located in the **OPAL-RT SPS Software/Control/Filters** library, implements one of the following transfer functions based on the **Filter type** selected in the block parameters window.

Low-pass filter:

$$
H(s)=\frac{1}{1+Ts}
$$

High-pass filter:

$$
H(s)=\frac{Ts}{1+Ts}
$$

where $$s$$ is the Laplace operator and T the time constant

## Characteristics

The key characteristics of the First-Order Filter block are:

* The input accepts a vectorized input of N signals and implements N filters. This feature is particularly useful for designing controllers in three-phase systems (*N* = 3).
* You can initialize filter states for specified DC and AC inputs.
* The block enables you to compute and plot filter response.

<table data-header-hidden><thead><tr><th width="250.44439697265625"></th><th></th></tr></thead><tbody><tr><td>Direct Feedthrough</td><td>Yes</td></tr><tr><td>Sample Time</td><td>Specified in the <strong>Sample Time</strong> parameter Continuous if <strong>Sample Time</strong> = 0</td></tr><tr><td>Scalar Expansion</td><td>Yes, of the parameters</td></tr><tr><td>States</td><td>One state per filter</td></tr><tr><td>Dimensionalized</td><td>Yes</td></tr></tbody></table>

## Ports

### Input

<table data-header-hidden><thead><tr><th width="250.22235107421875"></th><th></th></tr></thead><tbody><tr><td><strong>Port_1</strong> — Filter input<br>Scalar | vector</td><td>First-order filter input signal, specified as a scalar or a vector.</td></tr></tbody></table>

### Output

<table data-header-hidden><thead><tr><th width="250.22216796875"></th><th></th></tr></thead><tbody><tr><td><strong>Port_1</strong> — Filter output<br>Scalar | vector</td><td>First-order filter output signal, returned as a scalar or vector.</td></tr></tbody></table>

## Parameters

<table data-header-hidden><thead><tr><th width="249.9998779296875"></th><th></th></tr></thead><tbody><tr><td><strong>Filter type</strong> — Low-pass or high-pass filter<br>Lowpass (default) | Highpass</td><td>Determine the type of first-order filter. Set to Lowpass to implement a low-pass filter, set to Highpass to implement a high-pass filter.</td></tr><tr><td><strong>Time constant (s)</strong> — Filter time constant<br>10e-3 (default) | positive scalar</td><td>First-order filter time constant, specified in seconds.</td></tr><tr><td><strong>Sample time</strong> — Sample time of block<br>0 (default) | nonnegative scalar</td><td>Sample time of block, specified in seconds. Set to 0 to implement a continuous block.</td></tr><tr><td><strong>Initialize filter states</strong> — AC and DC initial input<br>on (default) | off</td><td>When selected, the filter states are initialized according to the <strong>AC initial input: [ Mag, Phase (degrees), Freq (Hz) ]</strong> and <strong>DC initial input</strong> parameters.</td></tr><tr><td><strong>AC initial input: [ Mag, Phase (degrees), Freq (Hz) ]</strong> — Magnitude of initial AC component<br>[0, 0, 60] (default) | three-element vector | <em>N</em>-by-3 matrix</td><td><p>Specify the magnitude of the initial AC component of the input signal, its phase, in degrees, and its frequency, in hertz.</p><p>When the input is vectorized (<em>N</em> signals), specify an <em>N</em>-by-3 matrix, where each row of the matrix corresponds to a particular input. Phase can be any value.</p><p>Mag and Freq must be positive.</p><p><strong>Dependencies</strong> To enable this parameter, select <strong>Initialize filter states</strong>.</p></td></tr><tr><td><strong>DC initial input</strong> — Initial DC component of input signal<br>0 (default) | scalar | 1-by-<em>N</em> vector</td><td><p>Specify the value of the initial DC component of the input signal. When the input signal is vectorized, specify a 1-by-<em>N</em> vector, where each value corresponds to a particular input.</p><p><strong>Dependencies</strong> To enable this parameter, select <strong>Initialize filter states</strong>.</p></td></tr><tr><td><strong>Plot filter response</strong> — Plot filter response and Bode diagram<br>off (default) | on</td><td>When selected, the filter step response and its Bode diagram (magnitude and phase of transfer function as a function of frequency) are plotted in a figure.</td></tr><tr><td><strong>Frequency range (Hz): [Start, End, Inc.]</strong> — Frequency range to plot filter Bode diagram<br>[0, 200, 1] (default) | three-element vector of nonnegative scalars</td><td><p>The frequency range used for plotting the filter Bode diagram. Specify a vector containing the starting frequency, the end frequency, and the incremental frequency, in hertz.</p><p><strong>Dependencies</strong> To enable this parameter, select <strong>Plot filter response</strong>.</p></td></tr></tbody></table>

## Examples

#### Use First-Order Filter Block with Lowpass and Highpass Filters

The power\_FirstOrderFilter example shows various uses of the First-Order Filter block using two **Filter type** parameter settings (Lowpass and Highpass).

The model sample time is parameterized with variable Ts (default value Ts = 50e-6). To simulate continuous filters, specify Ts = 0 at the MATLAB® command prompt before you start.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://www.opal-rt.com/docs/smart-power-simulation-software-sps/blocks-functions-tools/control-and-measurements/filters/first-order-filter.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
