TestDiscreteCascadeServoControllerDrive Icon
Examples.TestDiscreteCascadeServoControllerDrive
Position control of a mass through a drive with an internal force controller.
The cascade servo controller is used without its force loop (with_force_loop = false) and without feedforward inputs, and its output is the force setpoint of the drive. The drive is modeled as a first-order lag of time constant 0.02 from the force setpoint to the force acting on the mass m = 1. The velocity-loop PI controller is initialized such that its first output is 1.5, and the force setpoint is limited asymmetrically to [-1.5, 2.5], i.e., to the per-unit range [-0.15, 0.25] of f_max = 10.
Usage
DiscreteComponents.Examples.TestDiscreteCascadeServoControllerDrive()
Behavior
Behavior of this component cannot be rendered because it includes path variables.
Source
"""
Position control of a mass through a drive with an internal force controller.
The cascade servo controller is used without its force loop (`with_force_loop = false`) and without feedforward inputs, and its output is the force setpoint of the drive. The drive is modeled as a first-order lag of time constant `0.02` from the force setpoint to the force acting on the mass `m = 1`. The velocity-loop PI controller is initialized such that its first output is `1.5`, and the force setpoint is limited asymmetrically to `[-1.5, 2.5]`, i.e., to the per-unit range `[-0.15, 0.25]` of `f_max = 10`.
"""
test component TestDiscreteCascadeServoControllerDrive
"Position reference"
ref_s = BlockComponents.Sources.Constant(k = 0.2) {
"Dyad": {"placement": {"diagram": {"x1": 120, "y1": 410, "x2": 200, "y2": 490}}}
}
controller = DiscreteComponents.DiscreteCascadeServoController(with_force_loop = false, with_v_ff = false, with_a_ff = false, initialization_vel = DiscreteComponents.InitialCondition.InitialOutput(y0 = 1.5), v_max = 0.5, f_max = 10, f_lim_max = 0.25, f_lim_min = -0.15) {
"Dyad": {"placement": {"diagram": {"x1": 300, "y1": 300, "x2": 600, "y2": 600}}}
}
clock = DiscreteComponents.PeriodicClock(dt = 0.005) {
"Dyad": {"placement": {"diagram": {"x1": 60, "y1": 560, "x2": 140, "y2": 640}}}
}
sampler_s = DiscreteComponents.Sampler() {
"Dyad": {
"placement": {"diagram": {"x1": 190, "y1": 680, "x2": 270, "y2": 760, "rot": 270}}
}
}
sampler_v = DiscreteComponents.Sampler() {
"Dyad": {
"placement": {"diagram": {"x1": 395, "y1": 680, "x2": 475, "y2": 760, "rot": 270}}
}
}
zoh = DiscreteComponents.ZeroOrderHold() {
"Dyad": {
"placement": {"diagram": {"x1": 760, "y1": 840, "x2": 840, "y2": 920, "rot": 180}}
}
}
"Drive with internal force controller"
drive = BlockComponents.Continuous.FirstOrder(T = 0.02) {
"Dyad": {
"placement": {"diagram": {"x1": 640, "y1": 840, "x2": 720, "y2": 920, "rot": 180}}
}
}
"Inverse of the mass"
inv_mass = BlockComponents.Math.Gain(k = 1) {
"Dyad": {
"placement": {"diagram": {"x1": 520, "y1": 840, "x2": 600, "y2": 920, "rot": 180}}
}
}
velocity = BlockComponents.Continuous.Integrator() {
"Dyad": {
"placement": {"diagram": {"x1": 400, "y1": 840, "x2": 480, "y2": 920, "rot": 180}}
}
}
position = BlockComponents.Continuous.Integrator() {
"Dyad": {
"placement": {"diagram": {"x1": 280, "y1": 840, "x2": 360, "y2": 920, "rot": 180}}
}
}
relations
initial drive.x = 0
connect(ref_s.y, controller.s_ref) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}]}}
connect(controller.u, zoh.u) {
"Dyad": {"edges": [{"S": 1, "M": [{"x": 880, "y": 450}, {"x": 880, "y": 880}], "E": 2}]}
}
connect(zoh.y, drive.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}]}}
connect(drive.y, inv_mass.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}]}}
connect(inv_mass.y, velocity.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}]}}
connect(velocity.y, position.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}]}}
connect(velocity.y, sampler_v.u) {
"Dyad": {
"edges": [
{
"S": 1,
"M": [{"x": 385, "y": 880}, {"x": 385, "y": 800}, {"x": 435, "y": 800}],
"E": 2
}
]
}
}
connect(position.y, sampler_s.u) {"Dyad": {"edges": [{"S": 1, "M": [{"x": 230, "y": 880}], "E": 2}]}}
connect(sampler_s.y, controller.s_meas, clock.y) {
"Dyad": {"edges": [{"S": 1, "M": [{"x": 230, "y": 640}, {"x": 345, "y": 640}], "E": 2}]}
}
connect(sampler_v.y, controller.v_meas) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}]}}
metadata {
"Dyad": {
"tests": {
"case1": {
"stop": 3,
"atol": {"position.y": 0.001},
"expect": {"final": {"position.y": 0.2}}
}
},
"doc": {"behavior": false}
}
}
end
Flattened Source
"""
Position control of a mass through a drive with an internal force controller.
The cascade servo controller is used without its force loop (`with_force_loop = false`) and without feedforward inputs, and its output is the force setpoint of the drive. The drive is modeled as a first-order lag of time constant `0.02` from the force setpoint to the force acting on the mass `m = 1`. The velocity-loop PI controller is initialized such that its first output is `1.5`, and the force setpoint is limited asymmetrically to `[-1.5, 2.5]`, i.e., to the per-unit range `[-0.15, 0.25]` of `f_max = 10`.
"""
test component TestDiscreteCascadeServoControllerDrive
"Position reference"
ref_s = BlockComponents.Sources.Constant(k = 0.2) {
"Dyad": {"placement": {"diagram": {"x1": 120, "y1": 410, "x2": 200, "y2": 490}}}
}
controller = DiscreteComponents.DiscreteCascadeServoController(with_force_loop = false, with_v_ff = false, with_a_ff = false, initialization_vel = DiscreteComponents.InitialCondition.InitialOutput(y0 = 1.5), v_max = 0.5, f_max = 10, f_lim_max = 0.25, f_lim_min = -0.15) {
"Dyad": {"placement": {"diagram": {"x1": 300, "y1": 300, "x2": 600, "y2": 600}}}
}
clock = DiscreteComponents.PeriodicClock(dt = 0.005) {
"Dyad": {"placement": {"diagram": {"x1": 60, "y1": 560, "x2": 140, "y2": 640}}}
}
sampler_s = DiscreteComponents.Sampler() {
"Dyad": {
"placement": {"diagram": {"x1": 190, "y1": 680, "x2": 270, "y2": 760, "rot": 270}}
}
}
sampler_v = DiscreteComponents.Sampler() {
"Dyad": {
"placement": {"diagram": {"x1": 395, "y1": 680, "x2": 475, "y2": 760, "rot": 270}}
}
}
zoh = DiscreteComponents.ZeroOrderHold() {
"Dyad": {
"placement": {"diagram": {"x1": 760, "y1": 840, "x2": 840, "y2": 920, "rot": 180}}
}
}
"Drive with internal force controller"
drive = BlockComponents.Continuous.FirstOrder(T = 0.02) {
"Dyad": {
"placement": {"diagram": {"x1": 640, "y1": 840, "x2": 720, "y2": 920, "rot": 180}}
}
}
"Inverse of the mass"
inv_mass = BlockComponents.Math.Gain(k = 1) {
"Dyad": {
"placement": {"diagram": {"x1": 520, "y1": 840, "x2": 600, "y2": 920, "rot": 180}}
}
}
velocity = BlockComponents.Continuous.Integrator() {
"Dyad": {
"placement": {"diagram": {"x1": 400, "y1": 840, "x2": 480, "y2": 920, "rot": 180}}
}
}
position = BlockComponents.Continuous.Integrator() {
"Dyad": {
"placement": {"diagram": {"x1": 280, "y1": 840, "x2": 360, "y2": 920, "rot": 180}}
}
}
relations
initial drive.x = 0
connect(ref_s.y, controller.s_ref) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}]}}
connect(controller.u, zoh.u) {
"Dyad": {"edges": [{"S": 1, "M": [{"x": 880, "y": 450}, {"x": 880, "y": 880}], "E": 2}]}
}
connect(zoh.y, drive.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}]}}
connect(drive.y, inv_mass.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}]}}
connect(inv_mass.y, velocity.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}]}}
connect(velocity.y, position.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}]}}
connect(velocity.y, sampler_v.u) {
"Dyad": {
"edges": [
{
"S": 1,
"M": [{"x": 385, "y": 880}, {"x": 385, "y": 800}, {"x": 435, "y": 800}],
"E": 2
}
]
}
}
connect(position.y, sampler_s.u) {"Dyad": {"edges": [{"S": 1, "M": [{"x": 230, "y": 880}], "E": 2}]}}
connect(sampler_s.y, controller.s_meas, clock.y) {
"Dyad": {"edges": [{"S": 1, "M": [{"x": 230, "y": 640}, {"x": 345, "y": 640}], "E": 2}]}
}
connect(sampler_v.y, controller.v_meas) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}]}}
metadata {
"Dyad": {
"tests": {
"case1": {
"stop": 3,
"atol": {"position.y": 0.001},
"expect": {"final": {"position.y": 0.2}}
}
},
"doc": {"behavior": false}
}
}
endTest Cases
Test Case case1
Related
- Examples
- Experiments
- Analyses
- Tests