Relay
Switch output between two constants
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.
Examples
Use Fixed-Step Zero-Crossing Detection for Faster Simulations
Use fixed-step zero-crossing detection to improve simulation performance.
Ports
Input
Port_1 — Input signal
scalar
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
Port_1 — Output signal
scalar
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
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.
Programmatic Use
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.
Programmatic Use
Block Parameter:
OffSwitchValue |
Type: character vector |
Values: scalar |
Default:
'eps' |
Output when on — Output value when the relay is on
1
(default) | scalar
The output value when the relay is on.
Programmatic Use
Block Parameter:
OnOutputValue |
Type: character vector |
Values: scalar |
Default:
'1' |
Output when off — Output value when the relay is off
0
(default) | scalar
The output value when the relay is off.
Programmatic Use
Block Parameter:
OffOutputValue |
Type: character vector |
Values: scalar |
Default:
'0' |
Input processing — Specify sample- or frame-based processing
Elements 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. 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)' |
Enable zero-crossing detection — Enable zero-crossing detection
on
(default) | off
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' |
Sample time (-1 for inherited) — Interval between samples
-1
(default) | scalar | vector
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
To set the block parameter value programmatically, use
the set_param
function.
Parameter: | SampleTime |
Values: | "-1" (default) | scalar or vector in quotes |
Output minimum — Minimum output value for range checking
[]
(default) | scalar
Lower value of the output range that the software checks.
The software 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).
Tips
Output minimum does not saturate or clip the actual output signal. Use the Saturation block instead.
Programmatic Use
To set the block parameter value programmatically, use
the set_param
function.
Parameter: | OutMin |
Values: | '[]' (default) | scalar in quotes |
Output maximum — Maximum output value for range checking
[]
(default) | scalar
Upper value of the output range that the software checks.
The software 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).
Tips
Output maximum does not saturate or clip the actual output signal. Use the Saturation block instead.
Programmatic Use
To set the block parameter value programmatically, use
the set_param
function.
Parameter: | OutMax |
Values: | '[]' (default) | scalar in quotes |
Output data type — Data type of output signal
Inherit: 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
objectAn 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: All ports same
datatype' | 'Inherit: Inherit via back
propagation' | 'double' |
'single' | 'int8' |
'uint8' | int16 |
'uint16' | 'int32' |
'uint32' | 'int64' |
'uint64' | 'boolean' |
fixdt(1,16) |
fixdt(1,16,0) |
fixdt(1,16,2^0,0) | 'Enum: <class
name>' | '<data type
expression>' |
Default: 'Inherit: All ports same
datatype' |
Lock data type settings against changes by the fixed-point tools — Prevent fixed-point tools from overriding data types
off
(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).
Programmatic Use
Block Parameter: LockScale |
Type: character vector |
Values: 'off' | 'on' |
Default: 'off' |
Block Characteristics
Data Types |
|
Direct Feedthrough |
|
Multidimensional Signals |
|
Variable-Size Signals |
|
Zero-Crossing Detection |
|
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.
HDL Code Generation
Generate VHDL, Verilog and SystemVerilog code for FPGA and ASIC designs using HDL Coder™.
HDL Coder™ provides additional configuration options that affect HDL implementation and synthesized logic.
This block has one 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
|
The block does not support floating-point data types for HDL code generation.
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
See Also
Comando MATLAB
Hai fatto clic su un collegamento che corrisponde a questo comando MATLAB:
Esegui il comando inserendolo nella finestra di comando MATLAB. I browser web non supportano i comandi MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)