SimpleRelayControl Icon
Examples.SimpleRelayControl
Usage
DiscreteComponents.Examples.SimpleRelayControl()
Behavior
13-element Vector{Symbolics.Equation}:
connect(zeroorderhold.y(t), secondorder.u(t))
connect(secondorder.y(t), sampler.u(t))
connect(discretebinarycontroller.y(t), zeroorderhold.u(t))
connect(sampler.y(t), discretebinarycontroller.u_m(t), periodicclock.y(t))
connect(reference.y(t), discretebinarycontroller.u_s(t))
discretebinarycontroller₊s(t) ~ ifelse(Shift(t, -1)(discretebinarycontroller₊s(t)), discretebinarycontroller₊u_m(t) < (discretebinarycontroller₊b / 2 + discretebinarycontroller₊u_s(t)), discretebinarycontroller₊u_m(t) < (-(1//2)*discretebinarycontroller₊b + discretebinarycontroller₊u_s(t)))
discretebinarycontroller₊y(t) ~ ifelse(discretebinarycontroller₊s(t), discretebinarycontroller₊k, -discretebinarycontroller₊k)
Differential(t, 1)(secondorder₊x(t)) ~ secondorder₊xd(t)
Differential(t, 1)(secondorder₊xd(t)) ~ (-2secondorder₊d*secondorder₊xd(t) + (-secondorder₊x(t) + secondorder₊k*secondorder₊u(t))*secondorder₊w)*secondorder₊w
secondorder₊y(t) ~ secondorder₊x(t)
reference₊y(t) ~ reference₊k
zeroorderhold₊y(t) ~ ModelingToolkitBase.Hold()(zeroorderhold₊u(t))
sampler₊y(t) ~ Sample(InferredClock.InferredDiscrete(0))(sampler₊u(t))Source
test component SimpleRelayControl
discretebinarycontroller = DiscreteComponents.DiscreteBinaryController(k = 2, bool = false, b = 0.05) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 360, "y1": 340, "x2": 460, "y2": 440, "rot": 0}
},
"tags": []
}
}
secondorder = BlockComponents.Continuous.SecondOrder() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 720, "y1": 340, "x2": 820, "y2": 440, "rot": 0}
},
"tags": []
}
}
reference = BlockComponents.Sources.Constant(k = 1) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 140, "y1": 320, "x2": 240, "y2": 420, "rot": 0}
},
"tags": []
}
}
zeroorderhold = DiscreteComponents.ZeroOrderHold() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 550, "y1": 340, "x2": 650, "y2": 440, "rot": 0}
},
"tags": []
}
}
sampler = DiscreteComponents.Sampler() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 650, "y1": 520, "x2": 550, "y2": 620, "rot": 0}
},
"tags": []
}
}
periodicclock = DiscreteComponents.PeriodicClock(dt = 0.2) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 550, "y1": 670, "x2": 650, "y2": 770, "rot": 0}
},
"tags": []
}
}
relations
initial secondorder.x = 0.0
initial secondorder.xd = 0.0
connect(zeroorderhold.y, secondorder.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(secondorder.y, sampler.u) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 860, "y": 390}, {"x": 860, "y": 570}], "E": 2}],
"renderStyle": "standard"
}
}
connect(discretebinarycontroller.y, zeroorderhold.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(sampler.y, discretebinarycontroller.u_m, periodicclock.y) {
"Dyad": {
"edges": [
{"S": 1, "M": [], "E": -1},
{"S": -1, "M": [{"x": 290, "y": 570}, {"x": 290, "y": 409}], "E": 2},
{"S": 3, "M": [{"x": 470, "y": 720}], "E": -1}
],
"junctions": [{"x": 470, "y": 570}],
"renderStyle": "standard"
}
}
connect(reference.y, discretebinarycontroller.u_s) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
end
Flattened Source
test component SimpleRelayControl
discretebinarycontroller = DiscreteComponents.DiscreteBinaryController(k = 2, bool = false, b = 0.05) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 360, "y1": 340, "x2": 460, "y2": 440, "rot": 0}
},
"tags": []
}
}
secondorder = BlockComponents.Continuous.SecondOrder() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 720, "y1": 340, "x2": 820, "y2": 440, "rot": 0}
},
"tags": []
}
}
reference = BlockComponents.Sources.Constant(k = 1) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 140, "y1": 320, "x2": 240, "y2": 420, "rot": 0}
},
"tags": []
}
}
zeroorderhold = DiscreteComponents.ZeroOrderHold() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 550, "y1": 340, "x2": 650, "y2": 440, "rot": 0}
},
"tags": []
}
}
sampler = DiscreteComponents.Sampler() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 650, "y1": 520, "x2": 550, "y2": 620, "rot": 0}
},
"tags": []
}
}
periodicclock = DiscreteComponents.PeriodicClock(dt = 0.2) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 550, "y1": 670, "x2": 650, "y2": 770, "rot": 0}
},
"tags": []
}
}
relations
initial secondorder.x = 0.0
initial secondorder.xd = 0.0
connect(zeroorderhold.y, secondorder.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(secondorder.y, sampler.u) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 860, "y": 390}, {"x": 860, "y": 570}], "E": 2}],
"renderStyle": "standard"
}
}
connect(discretebinarycontroller.y, zeroorderhold.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(sampler.y, discretebinarycontroller.u_m, periodicclock.y) {
"Dyad": {
"edges": [
{"S": 1, "M": [], "E": -1},
{"S": -1, "M": [{"x": 290, "y": 570}, {"x": 290, "y": 409}], "E": 2},
{"S": 3, "M": [{"x": 470, "y": 720}], "E": -1}
],
"junctions": [{"x": 470, "y": 570}],
"renderStyle": "standard"
}
}
connect(reference.y, discretebinarycontroller.u_s) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
metadata {}
endTest Cases
No test cases defined.
Related
- Examples
- Experiments
- Analyses
- Tests