SimpleDiscreteIntegrator Icon
Examples.Integrator.SimpleDiscreteIntegrator
Usage
DiscreteComponents.Examples.Integrator.SimpleDiscreteIntegrator()
Parameters:
| Name | Description | Units | Default value |
|---|---|---|---|
dt | – | 0.1 |
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)
Variables
| Name | Description | Units |
|---|---|---|
reset_value | – |
Behavior
11-element Vector{Symbolics.Equation}:
reset_value(t) ~ NaN
connect(y(t), unitdelay.u(t))
connect(unitdelay.y(t), add.u1(t))
connect(add.y(t), y(t))
connect(u(t), product.u1(t))
connect(sampletimeblock.y(t), product.u2(t))
connect(product.y(t), add.u2(t))
unitdelay₊y(t) ~ Shift(t, -1)(unitdelay₊u(t))
add₊y(t) ~ add₊k1*add₊u1(t) + add₊k2*add₊u2(t)
sampletimeblock₊y(t) ~ ModelingToolkitBase.SampleTime(ModelingToolkitBase.ShiftIndex(InferredClock.Inferred(Base.UUID("0f192b99-25a5-49e1-83b0-4bc1efeba531")), 0), nothing)()
product₊y(t) ~ product₊u1(t)*product₊u2(t)Source
component SimpleDiscreteIntegrator@[input clk]
u = RealInput@[clk]() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": -50, "y1": 450, "x2": 50, "y2": 550, "rot": 0}
},
"tags": []
}
}
y = RealOutput@[clk]() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 960, "y1": 450, "x2": 1060, "y2": 550, "rot": 0}
},
"tags": []
}
}
unitdelay = DiscreteComponents.UnitDelay() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 900, "y1": 290, "x2": 800, "y2": 390, "rot": 0}
},
"tags": []
}
}
add = BlockComponents.Math.Add() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 790, "y1": 450, "x2": 890, "y2": 550, "rot": 0}
},
"tags": []
}
}
sampletimeblock = DiscreteComponents.SampleTimeSource() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 430, "y1": 610, "x2": 530, "y2": 710, "rot": 0}
},
"tags": []
}
}
product = BlockComponents.Math.Product() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 590, "y1": 490, "x2": 690, "y2": 590, "rot": 0}
},
"tags": []
}
}
structural parameter dt::Real = 0.1
variable reset_value::Real = NaN
relations
"""
y@(clk) = ifelse(reset > 0.0, sample(reset_value, clk), y@(clk-1) + u(clk) * dt)
reset_value@(clk) = ifelse(
isnan_wrapper(sample(reset_value, clk)@(clk-1)),
ic@(clk),
reset_value@(clk-1)
)
"""
initial u@(clk-1) = 0.0
initial reset_value@(clk-1) = 0.0
initial y@(clk-1) = 0.0
connect(unitdelay.u, y) {
"Dyad": {
"renderStyle": "standard",
"edges": [{"S": 1, "M": [{"x": 1010, "y": 340}], "E": 2}]
}
}
connect(unitdelay.y, add.u1) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 640, "y": 340}, {"x": 640, "y": 470}], "E": 2}],
"renderStyle": "standard"
}
}
connect(add.y, y) {"Dyad": {"renderStyle": "standard", "edges": [{"S": 1, "E": 2, "M": []}]}}
connect(u, product.u1) {
"Dyad": {
"renderStyle": "standard",
"edges": [{"S": 1, "M": [{"x": 0, "y": 510}], "E": 2}]
}
}
connect(product.u2, sampletimeblock.y) {
"Dyad": {
"renderStyle": "standard",
"edges": [{"S": 1, "M": [{"x": 558, "y": 570}, {"x": 558, "y": 660}], "E": 2}]
}
}
connect(product.y, add.u2) {
"Dyad": {
"renderStyle": "standard",
"edges": [{"S": 1, "M": [{"x": 740, "y": 540}, {"x": 740, "y": 530}], "E": 2}]
}
}
end
Flattened Source
component SimpleDiscreteIntegrator
u = RealInput@[clk]() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": -50, "y1": 450, "x2": 50, "y2": 550, "rot": 0}
},
"tags": []
}
}
y = RealOutput@[clk]() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 960, "y1": 450, "x2": 1060, "y2": 550, "rot": 0}
},
"tags": []
}
}
unitdelay = DiscreteComponents.UnitDelay() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 900, "y1": 290, "x2": 800, "y2": 390, "rot": 0}
},
"tags": []
}
}
add = BlockComponents.Math.Add() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 790, "y1": 450, "x2": 890, "y2": 550, "rot": 0}
},
"tags": []
}
}
sampletimeblock = DiscreteComponents.SampleTimeSource() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 430, "y1": 610, "x2": 530, "y2": 710, "rot": 0}
},
"tags": []
}
}
product = BlockComponents.Math.Product() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 590, "y1": 490, "x2": 690, "y2": 590, "rot": 0}
},
"tags": []
}
}
structural parameter dt::Real = 0.1
variable reset_value::Real = NaN
relations
"""
y@(clk) = ifelse(reset > 0.0, sample(reset_value, clk), y@(clk-1) + u(clk) * dt)
reset_value@(clk) = ifelse(
isnan_wrapper(sample(reset_value, clk)@(clk-1)),
ic@(clk),
reset_value@(clk-1)
)
"""
initial u@(clk-1) = 0.0
initial reset_value@(clk-1) = 0.0
initial y@(clk-1) = 0.0
connect(unitdelay.u, y) {
"Dyad": {
"renderStyle": "standard",
"edges": [{"S": 1, "M": [{"x": 1010, "y": 340}], "E": 2}]
}
}
connect(unitdelay.y, add.u1) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 640, "y": 340}, {"x": 640, "y": 470}], "E": 2}],
"renderStyle": "standard"
}
}
connect(add.y, y) {"Dyad": {"renderStyle": "standard", "edges": [{"S": 1, "E": 2, "M": []}]}}
connect(u, product.u1) {
"Dyad": {
"renderStyle": "standard",
"edges": [{"S": 1, "M": [{"x": 0, "y": 510}], "E": 2}]
}
}
connect(product.u2, sampletimeblock.y) {
"Dyad": {
"renderStyle": "standard",
"edges": [{"S": 1, "M": [{"x": 558, "y": 570}, {"x": 558, "y": 660}], "E": 2}]
}
}
connect(product.y, add.u2) {
"Dyad": {
"renderStyle": "standard",
"edges": [{"S": 1, "M": [{"x": 740, "y": 540}, {"x": 740, "y": 530}], "E": 2}]
}
}
metadata {}
endTest Cases
No test cases defined.
Related
- Examples
- Experiments
- Analyses
- Tests