> 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/lead-lag-filter.md).

# Lead Lag Filter

## Description

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

The **Lead Lag Filter** block, located in the **OPAL-RT SPS Software/Control/Filters** library, the Lead-Lag Filter block implements the following transfer function:

$$
H(s)=\frac{1+T\_1s}{1+T\_2s}
$$

where $$s$$ is the Laplace operator and T<sub>1</sub>, T<sub>2</sub> the time constant

This type of filter is used mainly for implementing lead-lag compensation in control systems. The key characteristics of the Lead-Lag Filter block are:

* Input accepts a vectorized input of N signals, thus implementing N filters. This feature is particularly useful for designing controllers in three-phase systems (N=3).
* The same block is used for continuous or discrete model. Changing the sample time Ts from 0 to a positive value automatically discretizes the filter, and vice versa.
* Filter states can be initialized for specified DC inputs and outputs.

## Characteristics

<table data-header-hidden><thead><tr><th width="249.77777099609375"></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.11114501953125"></th><th></th></tr></thead><tbody><tr><td><strong>In1</strong> — Input signal<br>Scalar | vector</td><td>Input signal the block applies the transfer function to.</td></tr></tbody></table>

### Output

<table data-header-hidden><thead><tr><th width="249.77764892578125"></th><th></th></tr></thead><tbody><tr><td><strong>Out1</strong> — Output signal<br>Scalar | vector</td><td>Output after the block has applied the transfer function.</td></tr></tbody></table>

## Parameters

<table data-header-hidden><thead><tr><th width="249.77783203125"></th><th></th></tr></thead><tbody><tr><td><strong>Time constant T1 (s)</strong> — T<sub>1</sub> filter time constant<br>5e-3 (default) | positive scalar</td><td>Specify the filter time constant(s) T<sub>1</sub> in seconds.</td></tr><tr><td><strong>Time constant T2 (s)</strong> — T<sub>2</sub> filter time constant<br>20e-3 (default) | positive scalar</td><td>Specify the filter time constant(s) T<sub>2</sub> in seconds.</td></tr><tr><td><strong>DC initial input and output</strong> — Input and output signal initial DC value<br>0 (default) | scalar | vector</td><td>Specify the DC initial value of input and output signals. If the input signal is vectorized, specify a 1-by-N vector, where each value corresponds to a particular input.</td></tr><tr><td><strong>Sample time</strong> — Block sample time<br>0 (default) | positive scalar</td><td>Specify the sample time of the block, in seconds.</td></tr></tbody></table>

## Examples

The power\_LeadLagFilter example shows two uses of a vectorized Lead-Lag Filter.

The model sample time is parameterized with variable Ts (default value Ts = 50e-6). To simulate continuous filters, specify Ts = 0 in the MATLAB® Command Window before simulating the model.


---

# 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/lead-lag-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.
