Main Content

Relay

Switch output between two constants

  • Relay block

Libraries:
Simulink / Discontinuities
HDL Coder / Discontinuities

Description

The output for the Relay block switches between two specified values. When the relay is on, it remains on until the input drops below the value of the Switch off point parameter. When the relay is off, it remains off until the input exceeds the value of the Switch on point parameter. The block accepts one input and generates one output.

Note

When the initial input falls between the Switch off point and Switch on point values, the initial output is the value when the relay is off.

Ports

Input

expand all

The input signal that switches the relay on or off.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | Boolean | fixed point

Output

expand all

The output signal switches between two values determined by the parameters Output when on and Output when off.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | Boolean | fixed point

Parameters

expand all

When the input crosses this threshold, the relay switches on. The Switch on point value must be greater than or equal to the Switch off point. Specifying a Switch on point value greater than the Switch off point models hysteresis, whereas specifying equal values models a switch with a threshold at that value.

The Switch on point parameter is converted to the input data type offline using round-to-nearest and saturation methods.

Programmatic Use

Block Parameter: OnSwitchValue
Type: character vector
Values: scalar
Default: 'eps'

When the input crosses this threshold the relay switches off. The value of Switch off point must be less than or equal to Switch on point. The Switch off point parameter is converted to the input data type offline using round-to-nearest and saturation.

Programmatic Use

Block Parameter: OffSwitchValue
Type: character vector
Values: scalar
Default: 'eps'

The output value when the relay is on.

Programmatic Use

Block Parameter: OnOutputValue
Type: character vector
Values: scalar
Default: '1'

The output value when the relay is off.

Programmatic Use

Block Parameter: OffOutputValue
Type: character vector
Values: scalar
Default: '0'

Specify whether the block performs sample- or frame-based processing:

  • Columns as channels (frame based) — Treat each column of the input as a separate channel (frame-based processing).

    Note

    Frame-based processing requires a DSP System Toolbox™ license.

    For more information, see Sample- and Frame-Based Concepts (DSP System Toolbox).

  • Elements as channels (sample based) — Treat each element of the input as a separate channel (sample-based processing).

Use Input processing to specify whether the block performs sample- or frame-based processing. For more information about these two processing modes, see Sample- and Frame-Based Concepts (DSP System Toolbox).

Programmatic Use

Block Parameter: InputProcessing
Type: character vector
Values: 'Columns as channels (frame based)' | 'Elements as channels (sample based)'
Default: 'Elements as channels (sample based)'

Select to enable zero-crossing detection. For more information, see Zero-Crossing Detection.

Programmatic Use

Block Parameter: ZeroCross
Type: character vector | string
Values: 'off' | 'on'
Default: 'on'

Specify the time interval between samples. To inherit the sample time, set this parameter to -1. For more information, see Specify Sample Time.

Dependencies

This parameter is visible only if you set it to a value other than -1. To learn more, see Blocks for Which Sample Time Is Not Recommended.

Programmatic Use

Block Parameter: SampleTime
Type: string scalar or character vector
Default: "-1"

Lower value of the output range that Simulink® checks.

Simulink uses the minimum to perform:

Note

Output minimum does not saturate or clip the actual output signal. Use the Saturation block instead.

Programmatic Use

Block Parameter: OutMin
Type: character vector
Values: '[ ]'| scalar
Default: '[ ]'

Upper value of the output range that Simulink checks.

Simulink uses the maximum value to perform:

Note

Output maximum does not saturate or clip the actual output signal. Use the Saturation block instead.

Programmatic Use

Block Parameter: OutMax
Type: character vector
Values: '[ ]'| scalar
Default: '[ ]'

Specify the output data type. You can set it to:

  • A rule that inherits a data type, for example, Inherit: Inherit via back propagation

  • The name of a built-in data type, for example, single

  • The name of a data type object, for example, a Simulink.NumericType object

  • An expression that evaluates to a data type, for example, fixdt(1,16,0)

Click the Show data type assistant button to display the Data Type Assistant, which helps you set the Output data type parameter.

See Control Data Types of Signals for more information.

Programmatic Use

Block Parameter: OutDataTypeStr
Type: character vector
Values: 'Inherit: Same as input', 'Inherit: Inherit via back propagation', 'single', 'int8', 'uint8', int16, 'uint16', 'int32', 'uint32', 'int64', 'uint64', fixdt(1,16,0), fixdt(1,16,2^0,0), fixdt(1,16,2^0,0). '<data type expression>'
Default: 'Inherit: Same as input'

Select this parameter to prevent the fixed-point tools from overriding the data types you specify on this block. For more information, see Lock the Output Data Type Setting (Fixed-Point Designer).

Programmatic Use

Block Parameter: LockScale
Type: character vector
Values: 'off' | 'on'
Default: 'off'

Block Characteristics

Data Types

Boolean | double | fixed point | integer | single

Direct Feedthrough

yes

Multidimensional Signals

no

Variable-Size Signals

no

Zero-Crossing Detection

yes

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

PLC Code Generation
Generate Structured Text code using Simulink® PLC Coder™.

Fixed-Point Conversion
Design and simulate fixed-point systems using Fixed-Point Designer™.

Version History

Introduced before R2006a