Switch output between two constants
Simulink / Discontinuities
HDL Coder / Discontinuities
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.
Port_1
— Input signalThe input signal that switches the relay on or off.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| Boolean
| fixed point
Port_1
— Output signalThe 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
Switch on point
— Input value which switches the relay on'eps'
(default) | scalar
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.
Block Parameter:
OnSwitchValue |
Type: character vector |
Values: scalar |
Default:
'eps' |
Switch off point
— Input value which switches the relay off'eps'
(default) | scalar
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.
Block Parameter:
OffSwitchValue |
Type: character vector |
Values: scalar |
Default:
'eps' |
Output when on
— Output value when the relay is on1
(default) | scalar
The output value when the relay is on.
Block Parameter:
OnOutputValue |
Type: character vector |
Values: scalar |
Default:
'1' |
Output when off
— Output value when the relay is off0
(default) | scalar
The output value when the relay is off.
Block Parameter:
OffOutputValue |
Type: character vector |
Values: scalar |
Default:
'0' |
Input processing
— Specify sample- or frame-based processingElements as channels (sample based)
(default) | Columns as channels (frame based)
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 u | Input Processing Mode | Block Works? |
---|---|---|
Sample based | Sample based | Yes |
Frame based | No, produces an error | |
Sample based | Frame based | Yes |
Frame based | Yes |
For more information about these two processing modes, see Sample- and Frame-Based Concepts (DSP System Toolbox).
Block Parameter:
InputProcessing |
Type: character vector |
Values: 'Columns as channels
(frame based)' | 'Elements as channels (sample
based)' |
Default: 'Elements as channels
(sample based)' |
Enable zero-crossing detection
— Enable zero-crossing detectionon
(default) | BooleanSelect to enable zero-crossing detection. For more information, see Zero-Crossing Detection.
Block Parameter:
ZeroCross |
Type: character vector, string |
Values: 'off' |
'on' |
Default: 'on' |
Sample time
— Specify sample time as a value other than -1
-1
(default) | scalar | vectorSpecify the sample time as a value other than -1. For more information, see Specify Sample Time.
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.
Block Parameter:
SampleTime |
Type: character vector |
Values: scalar or vector |
Default:
'-1' |
Output minimum
— Minimum output value for range checking[]
(default) | scalarLower value of the output range that Simulink® checks.
Simulink uses the minimum to perform:
Parameter range checking (see Specify Minimum and Maximum Values for Block Parameters) for some blocks.
Simulation range checking (see Specify Signal Ranges and Enable Simulation Range Checking).
Automatic scaling of fixed-point data types.
Optimization of the code that you generate from the model. This optimization can remove algorithmic code and affect the results of some simulation modes such as SIL or external mode. For more information, see Optimize using the specified minimum and maximum values (Embedded Coder).
Note
Output minimum does not saturate or clip the actual output signal. Use the Saturation block instead.
Block Parameter:
OutMin |
Type: character vector |
Values: '[ ]' |
scalar |
Default: '[ ]' |
Output maximum
— Maximum output value for range checking[]
(default) | scalarUpper value of the output range that Simulink checks.
Simulink uses the maximum value to perform:
Parameter range checking (see Specify Minimum and Maximum Values for Block Parameters) for some blocks.
Simulation range checking (see Specify Signal Ranges and Enable Simulation Range Checking).
Automatic scaling of fixed-point data types.
Optimization of the code that you generate from the model. This optimization can remove algorithmic code and affect the results of some simulation modes such as SIL or external mode. For more information, see Optimize using the specified minimum and maximum values (Embedded Coder).
Note
Output maximum does not saturate or clip the actual output signal. Use the Saturation block instead.
Block Parameter:
OutMax |
Type: character vector |
Values: '[ ]' |
scalar |
Default: '[ ]' |
Output data type
— Data type of output signalInherit: All ports same
datatype
(default) | Inherit: Inherit via back propagation
| double
| single
| int8
| int32
| uint32
| int64
| uint64
| fixdt(1,16,2^0,0)
| <data type expression>
| ...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 Signal Data Types for more information.
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' |
Lock data type settings against changes by the fixed-point tools
— Prevent fixed-point tools from overriding data typesoff
(default) | on
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).
Block Parameter: LockScale |
Type: character vector |
Values: 'off' | 'on' |
Default: 'off' |
Data Types |
|
Direct Feedthrough |
|
Multidimensional Signals |
|
Variable-Size Signals |
|
Zero-Crossing Detection |
|
HDL Coder™ provides additional configuration options that affect HDL implementation and synthesized logic.
This block has a single, default HDL architecture.
ConstrainedOutputPipeline | Number of registers to place at
the outputs by moving existing delays within your design. Distributed
pipelining does not redistribute these registers. The default is
|
InputPipeline | Number of input pipeline stages
to insert in the generated code. Distributed pipelining and constrained
output pipelining can move these registers. The default is
|
OutputPipeline | Number of output pipeline stages
to insert in the generated code. Distributed pipelining and constrained
output pipelining can move these registers. The default is
|