This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Relay

Switch output between two constants

  • Library:
  • Simulink / 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 | uint8 | uint16 | uint32 | 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 | uint8 | uint16 | uint32 | Boolean | fixed point | enumerated

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. The block accepts frame-based signals for the input u. All other input signals must be sample-based.

Input Signal uInput Processing ModeBlock Works?
Sample basedSample basedYes
Frame basedNo, produces an error
Sample basedFrame basedYes
Frame basedYes
Sample basedInheritedYes
Frame basedYes

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 sample time as a value other than -1. For more information, see Specify Sample Time.

Dependencies

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

Programmatic Use

Block Parameter: SampleTime
Type: character vector
Values: scalar
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)

  • An enumerated data type, for example, Enum:BasicColors

    In this case, Output when on and Output when off must be of the same enumerated type.

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

See Control Signal Data Types 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', 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

double | single | Boolean | base integer | fixed point

Direct Feedthrough

No

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
Convert floating-point algorithms to fixed point using Fixed-Point Designer™.

Introduced before R2006a