Relay Icon
Discontinuous.Relay
Relay block with hysteresis (Schmitt trigger).
Switches output between two values based on input crossing upper and lower thresholds:
- When u >= switchonthreshold: y = outputwhenon
- When u <= switchoffthreshold: y = outputwhenoff
- Between thresholds: y maintains previous state (hysteresis)
Hysteresis prevents chattering when input signal has noise near the switching point.
Arguments: switch_on_threshold - Input level at which relay switches on switch_off_threshold - Input level at which relay switches off (must be < switchonthreshold) output_when_on - Output value when relay is on output_when_off - Output value when relay is off
Usage
PrimitiveComponents.Discontinuous.Relay(switch_on_threshold=1.0, switch_off_threshold=-1.0, output_when_on=1.0, output_when_off=0.0)
Parameters:
| Name | Description | Units | Default value |
|---|---|---|---|
switch_on_threshold | Threshold for switching output on | – | 1 |
switch_off_threshold | Threshold for switching output off | – | -1 |
output_when_on | Output value when relay is on | – | 1 |
output_when_off | Output value when relay is off | – | 0 |
Connectors
u- This connector represents a real signal as an input to a component (RealInput)y- This connector represents a real signal as an output from a component (RealOutput)
Behavior
\[ \begin{align} y\left( t \right) &= ifelse\left( u\left( t \right) \geq \mathtt{switch\_on\_threshold}, \mathtt{output\_when\_on}, ifelse\left( u\left( t \right) \leq \mathtt{switch\_off\_threshold}, \mathtt{output\_when\_off}, ifelse\left( u\left( t \right) > 0, \mathtt{output\_when\_on}, \mathtt{output\_when\_off} \right) \right) \right) \end{align} \]
Source
"""
Relay block with hysteresis (Schmitt trigger).
Switches output between two values based on input crossing upper and lower thresholds:
- When u >= switch_on_threshold: y = output_when_on
- When u <= switch_off_threshold: y = output_when_off
- Between thresholds: y maintains previous state (hysteresis)
Hysteresis prevents chattering when input signal has noise near the switching point.
Arguments:
`switch_on_threshold` - Input level at which relay switches on
`switch_off_threshold` - Input level at which relay switches off (must be < switch_on_threshold)
`output_when_on` - Output value when relay is on
`output_when_off` - Output value when relay is off
"""
component Relay
"Input signal port"
u = RealInput() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 0, "y1": 450, "x2": 100, "y2": 550, "rot": 0}
}
}
}
"Output signal port"
y = RealOutput() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 900, "y1": 450, "x2": 1000, "y2": 550, "rot": 0}
}
}
}
"Threshold for switching output on"
parameter switch_on_threshold::Real = 1.0
"Threshold for switching output off"
parameter switch_off_threshold::Real = -1.0
"Output value when relay is on"
parameter output_when_on::Real = 1.0
"Output value when relay is off"
parameter output_when_off::Real = 0.0
relations
y = ifelse(u >= switch_on_threshold, output_when_on, ifelse(u <= switch_off_threshold, output_when_off, ifelse(u > 0, output_when_on, output_when_off)))
metadata {"Dyad": {"icons": {"default": "dyad://PrimitiveComponents/Relay.svg"}}}
end
Flattened Source
"""
Relay block with hysteresis (Schmitt trigger).
Switches output between two values based on input crossing upper and lower thresholds:
- When u >= switch_on_threshold: y = output_when_on
- When u <= switch_off_threshold: y = output_when_off
- Between thresholds: y maintains previous state (hysteresis)
Hysteresis prevents chattering when input signal has noise near the switching point.
Arguments:
`switch_on_threshold` - Input level at which relay switches on
`switch_off_threshold` - Input level at which relay switches off (must be < switch_on_threshold)
`output_when_on` - Output value when relay is on
`output_when_off` - Output value when relay is off
"""
component Relay
"Input signal port"
u = RealInput() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 0, "y1": 450, "x2": 100, "y2": 550, "rot": 0}
}
}
}
"Output signal port"
y = RealOutput() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 900, "y1": 450, "x2": 1000, "y2": 550, "rot": 0}
}
}
}
"Threshold for switching output on"
parameter switch_on_threshold::Real = 1.0
"Threshold for switching output off"
parameter switch_off_threshold::Real = -1.0
"Output value when relay is on"
parameter output_when_on::Real = 1.0
"Output value when relay is off"
parameter output_when_off::Real = 0.0
relations
y = ifelse(u >= switch_on_threshold, output_when_on, ifelse(u <= switch_off_threshold, output_when_off, ifelse(u > 0, output_when_on, output_when_off)))
metadata {"Dyad": {"icons": {"default": "dyad://PrimitiveComponents/Relay.svg"}}}
endTest Cases
No test cases defined.
Related
- Examples
- Experiments
- Analyses
- Tests