Cookbook · example 3
Calibrate with a setpoint sweep
Step a setting through a list of values, let each settle, measure a signal several times, and get a table and a CSV. The same steps calibrate a laser's power against drive current, a stage's position against its command, or an oven's real temperature against its setpoint.
You need: the setup from the cookbook front page. We sweep the simulated thermocycler's setpoint and measure its block temperature. About five minutes.
Ask for the sweep
Sweep the thermocycler from 30 to 60 degrees in steps of 10. Let each point settle for 5 seconds, take 3 readings at each, and give me the table.
The agent shows the plan
It finds the
setpoint-sweeprecipe and rehearses it:Plan for setpoint-sweep (values=[30,40,50,60], settle_s=5, samples=3, restore=22) 1 thermocycler-01 set target_temperature = 30 ok 2 thermocycler-01 read block_temperature (×3) 3 thermocycler-01 set target_temperature = 40 ok ... 9 thermocycler-01 set target_temperature = 22 ok (restore) Verdict: ok; no human confirmation needed. Run it?Try asking for a top value of 120. The plan stops at that step with REFUSED: target_temperature=120 above max 105. The limit is in the instrument's package; the agent cannot change it.
Say go and wait
Go ahead.
Four points at five seconds each: about half a minute on the simulator.
Read the table
setpoint measured sd 30 30.00 0.00 40 40.00 0.00 50 50.00 0.00 60 60.00 0.00The simulator is exact; a real instrument's measured column is where the calibration lives. The agent also tells you the block is back at 22 °C.
Use the CSV
Fit a straight line to the sweep and tell me the offset and slope.
The agent reads
sweep.csvfrom the run folder and does the arithmetic. The file stays at~/.openmhp/runs/<run-id>/sweep.csv.
Doing it on a real instrument
- Name the device, the setting and the signal: "sweep the laser driver's current from 100 to 500 mA in steps of 50 and measure the power meter". The measured signal can come from a different device than the one being stepped.
- Give a realistic settle time. Long sweeps run in the background; ask for the table when they are done.
- For two-dimensional sweeps, copy the recipe into
~/.openmhp/recipes/and add a second loop.