Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
ptblab
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Daniele Nicolodi
ptblab
Commits
e7b0ad55
Commit
e7b0ad55
authored
1 year ago
by
Daniele Nicolodi
Browse files
Options
Downloads
Patches
Plain Diff
si5servo: Implement anti-windup compensation
parent
344d4881
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ptblab/control.py
+47
-0
47 additions, 0 deletions
ptblab/control.py
si5servo.py
+10
-2
10 additions, 2 deletions
si5servo.py
with
57 additions
and
2 deletions
ptblab/control.py
+
47
−
0
View file @
e7b0ad55
...
@@ -35,3 +35,50 @@ class PI2:
...
@@ -35,3 +35,50 @@ class PI2:
self
.
acc1
+=
error
*
self
.
i1
self
.
acc1
+=
error
*
self
.
i1
self
.
acc2
+=
self
.
acc1
*
self
.
i2
self
.
acc2
+=
self
.
acc1
*
self
.
i2
return
self
.
p
*
(
error
+
self
.
acc1
+
self
.
acc2
)
+
self
.
o
return
self
.
p
*
(
error
+
self
.
acc1
+
self
.
acc2
)
+
self
.
o
def
clamp
(
v
,
vmin
,
vmax
):
if
v
<
vmin
:
return
vmin
if
v
>
vmax
:
return
vmax
return
v
class
AntiWindupPI
:
"""
A PI control loop with anti-windup compensation.
Implement the back-calculation and tracking technique described in
K.J. Astrom, Control System Design, 2002, section 6.5, page 226.
https://www.cds.caltech.edu/~murray/courses/cds101/fa02/caltech/astrom-ch6.pdf
"""
def
__init__
(
self
,
setpoint
,
vmin
,
vmax
,
p
=
0.0
,
i
=
0.0
,
o
=
0.0
):
self
.
setpoint
=
setpoint
self
.
p
=
p
self
.
i
=
i
self
.
o
=
o
self
.
vmin
=
vmin
self
.
vmax
=
vmax
self
.
acc
=
0.0
@property
def
params
(
self
):
return
self
.
p
,
self
.
i
,
self
.
o
def
update
(
self
,
value
):
# Simple PI controller.
error
=
value
-
self
.
setpoint
self
.
acc
+=
error
*
self
.
i
v
=
self
.
p
*
(
error
+
self
.
acc
)
+
self
.
o
# Actuator model.
u
=
clamp
(
v
,
self
.
vmin
,
self
.
vmax
)
# Apply anti-windup compensation. There is no derivative gain
# and minimum measurement noise, thus it should be safe to Use
# unity tracking gain.
self
.
acc
+=
(
u
-
v
)
/
self
.
p
return
u
This diff is collapsed.
Click to expand it.
si5servo.py
+
10
−
2
View file @
e7b0ad55
...
@@ -65,10 +65,18 @@ def main(setpoint, params, frequency, amplitude, source, datadir, dataname):
...
@@ -65,10 +65,18 @@ def main(setpoint, params, frequency, amplitude, source, datadir, dataname):
# Get output device.
# Get output device.
output
=
rpc
.
Client
(
cryo124k
.
ADDRESS
,
cryo124k
.
TIMEOUT
)
output
=
rpc
.
Client
(
cryo124k
.
ADDRESS
,
cryo124k
.
TIMEOUT
)
# Con
figure control loop
.
# Con
trol loop parameters
.
args
=
{
name
:
float
(
value
)
for
name
,
value
in
(
param
.
split
(
'
=
'
)
for
param
in
params
)}
args
=
{
name
:
float
(
value
)
for
name
,
value
in
(
param
.
split
(
'
=
'
)
for
param
in
params
)}
args
.
setdefault
(
'
o
'
,
output
.
attr
(
'
output
'
))
args
.
setdefault
(
'
o
'
,
output
.
attr
(
'
output
'
))
servo
=
control
.
PI2
(
setpoint
=
setpoint
,
**
args
)
# PI control loop with anti-windup. With the cryofan speed set to
# zero, there is no He circulation and the gas in the He circuit
# warms up to a temperature above the system temperature. When the
# He starts circulating again, the system temperature increases
# quickly instead of decreasing. To avoid this effect, always keep
# a minimum He flow by setting the minimum cryofan control voltage
# to 0.1 V.
servo
=
control
.
AntiWindupPI
(
setpoint
=
setpoint
,
vmin
=
0.1
,
vmax
=
10.0
,
**
args
)
# Log loop parameters.
# Log loop parameters.
data
=
datalogger
.
open_data_file
(
datadir
,
dataname
,
None
)
data
=
datalogger
.
open_data_file
(
datadir
,
dataname
,
None
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment