Main Content

Comparator

Compare two analog inputs on peripheral and provide results

Since R2023b

  • Comparator Block

Libraries:
Embedded Coder Support Package for STMicroelectronics STM32 Processors / STM32G4xx Based Boards
Embedded Coder Support Package for STMicroelectronics STM32 Processors / STM32H7xx Based Boards (Single-core)
Embedded Coder Support Package for STMicroelectronics STM32 Processors / STM32L4xx Based Boards
Embedded Coder Support Package for STMicroelectronics STM32 Processors / STM32L5xx Based Boards
Embedded Coder Support Package for STMicroelectronics STM32 Processors / STM32U5xx Based Boards

Description

The Comparator block compares two analog inputs on the peripheral and provides the logical value of the result.

Ports

Input

expand all

The port Enable allows user to enable the comparator module during run time.

Dependencies

To enable this port, select the Run time module enable parameter.

Data Types: uint8 | uint16

Output

expand all

The block outputs the result of the comparator.

  • 0 - +ve pin input is greater than -ve pin input

  • 1 - +ve pin input is less than -ve pin input

Data Types: Boolean

The block outputs comparator execution status.

  • 0 - Valid result

  • 1 - Invalid result

Dependencies

To enable this port, select the Run time module enable and Output status parameters.

Data Types: Boolean

Parameters

expand all

Select a comparator module for comparison of analog inputs.

Select to Run time module enable to enable the comparator during run time. Selecting this parameter, configures the enable input port.

When you select this parameter, the block configures Status output port. The Status port outputs the status of the comparator.

Dependencies

To enable this parameter, select the Run time module enable parameter.

Specify how often (in seconds) the block reads the pin value. Enter a value greater than zero. When you specify this parameter as -1, Simulink determines the best sample time for the block based on the block context within the model.

Version History

Introduced in R2023b