> 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/logic/bistable.md).

# Bistable

## Description

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

The **Bistable** block, located in the **OPAL-RT SPS Software/Control** library, implements prioritized S-R flip-flop (bistable multivibrator)

The Bistable block implements the following logic:

* When S input is true and R input is false, the flip-flop goes to the Set state. This is the first stable state, where Q is true.
* When R is true and S is false, the flip-flop goes to the reset state. This is the second stable state, where Q is false.
* When both S and R are true, the flip-flop goes to the prioritized state defined by the **Select priority** parameter.
* When both S and R are false, the flip-flop stays in its previous state.

## Parameters

<table data-header-hidden><thead><tr><th width="250.44439697265625"></th><th></th></tr></thead><tbody><tr><td><strong>Select priority</strong></td><td>Specify the prioritized state of Q. Choices are Set (default) or Reset.</td></tr><tr><td><strong>Initial condition (state of Q)</strong></td><td>Specify the initial value of the output Q. Default is 0.</td></tr><tr><td><strong>Sample time (-1 for inherited)</strong></td><td>Specify the sample time of the block, in seconds. Set to 0 to implement a continuous block. Default is 0.</td></tr></tbody></table>

### Inputs and Outputs

<table data-header-hidden><thead><tr><th width="249.666748046875"></th><th></th></tr></thead><tbody><tr><td><strong>S, [S]</strong></td><td><p>The Set input. Must be Boolean.</p><p>When the <strong>Select priority</strong> parameter value is Set, the input is named [S].</p></td></tr><tr><td><strong>R, [R]</strong></td><td><p>The Reset input. Must be Boolean.</p><p>When the <strong>Select priority</strong> parameter value is Reset, the input is named [R].</p></td></tr><tr><td><strong>Q</strong></td><td><p>Bistable output.</p><p>The signal is Boolean.</p></td></tr><tr><td><strong>!Q</strong></td><td><p>Bistable complement output.</p><p>The signal is Boolean.</p></td></tr></tbody></table>

## Characteristics

<table data-header-hidden><thead><tr><th width="250"></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</td></tr><tr><td>Scalar Expansion</td><td>Yes, of parameters</td></tr><tr><td>Dimensionalized</td><td>Yes</td></tr><tr><td>Zero-Crossing Detection</td><td>No</td></tr></tbody></table>

## Examples

The power\_Logic example shows the operation of the Bistable block.

The model sample time is parameterized with the variable Ts (default value Ts = 50e-3).

To simulate a continuous Bistable block, specify Ts = 0 in the MATLAB® Command Window.


---

# 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/logic/bistable.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.
