Skip to content

Commit 81138be

Browse files
committed
completion, readback detail
1 parent 98fd763 commit 81138be

1 file changed

Lines changed: 66 additions & 1 deletion

File tree

scan/commands/set.py

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class Set(Command):
2727
Example:
2828
>>> cmd = Set('position', 10.5)
2929
30-
Note usage of timeout:
30+
*Note usage of timeout:*
3131
When the command awaits completion, the timeout is applied to the completion check,
3232
i.e. we await the completion callback for `timeout` seconds.
3333
If another readback check is performed after the completion,
@@ -38,6 +38,71 @@ class Set(Command):
3838
the timeout is applied to the readback check.
3939
So in case a readback comparison is requested,
4040
we wait for up to `timeout` seconds for the readback to be within tolerance.
41+
42+
*Note use of completion:*
43+
EPICS Channel Access does not communicate if completion ('put-callback') is actually
44+
supported. When writing to a PV that does not support completion, the call is returned
45+
right away, just as it would for a PV that supports completion and happens to complete
46+
quickly.
47+
Similarly, a PV that supports completion will only tell us when it's 'done',
48+
no matter if it completed successfully, or if it eventually gave up and completed
49+
without actually reaching the desired setpoint.
50+
51+
**Use case 1: Neither completion nor readback**
52+
53+
The `Set` command simply writes to the device.
54+
55+
This would be suitable for a write-and-forget PV.
56+
For example, a PV that turns a power supply on or off, and
57+
the device reacts quasi immediately.
58+
59+
**Use case 2: No completion, but readback**
60+
61+
The `Set` command writes to the device, and uses the `timeout`
62+
to wait for the readback to match the written value.
63+
64+
This can be sufficient for simple, well behaved devices,
65+
but can be problematic for a device where the readback will
66+
take time to settle. Examples include PID-controlled devices
67+
with overshoot and settling time, or motors with backlash compensation
68+
and retries where the readback might early on be close to the setpoint,
69+
but it has not settled, so we consider it 'done' when in fact the
70+
device is actively changing its value.
71+
72+
**Use case 3: Enable completion but no readback**
73+
74+
The `Set` command writes to the device, then uses the `timeout`
75+
to wait for the completion confirmation.
76+
77+
This can be used with PVs that support completion and are dependable.
78+
We cannot distinguish between a completion that is successful,
79+
versus completion as a result of the device giving up.
80+
81+
If this mode is by accident used with a PV that doesn't actually
82+
support completion, the IOC will immediately confirm the completion,
83+
behaving just like case 1.
84+
85+
**Use case 4: Enable completion and readback**
86+
87+
This is the ideal case, which is for example supported by the 'motor' record
88+
or EPICS databases for Lakeshore controllers.
89+
The `Set` command writes to the device, waits for the completion (based on timeout),
90+
and then compares the written value against the `readback` PV to check
91+
if we completed successfully, or if the device completed without being able to
92+
actually reach the setpoint.
93+
94+
Note that this must *only be used with devices that actually support completion*.
95+
When applied to a plain PV that does not support completion,
96+
we will immediately receive the completion confirmation,
97+
then check the readback, which is very likely not matching the setpoint, yet,
98+
and fail.
99+
So while this is best for PVs that support completion, it is worst for PVs
100+
that don't.
101+
102+
Unfortunately there is no way in EPICS to determine the 'correct' settings
103+
for a PV without knowing how it is implemented on the IOC, so the
104+
choice of completion, readback and timeout needs to be configured by somebody
105+
who knows the PV's behavior.
41106
"""
42107

43108
def __init__(self, device, value, completion=False, readback=False, tolerance=0.0, timeout=0.0, errhandler=None):

0 commit comments

Comments
 (0)