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.

  1. 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.
  2. The agent shows the plan

    It finds the setpoint-sweep recipe 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.

  3. Say go and wait

    Go ahead.

    Four points at five seconds each: about half a minute on the simulator.

  4. 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.00

    The 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.

  5. Use the CSV

    Fit a straight line to the sweep and tell me the offset and slope.

    The agent reads sweep.csv from the run folder and does the arithmetic. The file stays at ~/.openmhp/runs/<run-id>/sweep.csv.

Doing it on a real instrument

  1. 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.
  2. Give a realistic settle time. Long sweeps run in the background; ask for the table when they are done.
  3. For two-dimensional sweeps, copy the recipe into ~/.openmhp/recipes/ and add a second loop.