|
| 1 | +from labscript import start, stop, add_time_marker, AnalogOut, DigitalOut |
| 2 | +from labscript_devices.DummyPseudoclock.labscript_devices import DummyPseudoclock |
| 3 | +from labscript_devices.DummyIntermediateDevice import DummyIntermediateDevice |
| 4 | + |
| 5 | +# Use a virtual, or 'dummy', device for the psuedoclock |
| 6 | +DummyPseudoclock(name='pseudoclock') |
| 7 | + |
| 8 | +# An output of this DummyPseudoclock is its 'clockline' attribute, which we use |
| 9 | +# to trigger children devices |
| 10 | +DummyIntermediateDevice(name='intermediate_device', parent_device=pseudoclock.clockline) |
| 11 | + |
| 12 | +# Create an AnalogOut child of the DummyIntermediateDevice |
| 13 | +AnalogOut(name='analog_out', parent_device=intermediate_device, connection='ao0') |
| 14 | + |
| 15 | +# Create a DigitalOut child of the DummyIntermediateDevice |
| 16 | +DigitalOut( |
| 17 | + name='digital_out', parent_device=intermediate_device, connection='port0/line0' |
| 18 | +) |
| 19 | + |
| 20 | +# Begin issuing labscript primitives |
| 21 | +# A timing variable t is used for convenience |
| 22 | +# start() elicits the commencement of the shot |
| 23 | +t = 0 |
| 24 | +add_time_marker(t, "Start", verbose=True) |
| 25 | +start() |
| 26 | + |
| 27 | +# Wait for 1 second with all devices in their default state |
| 28 | +t += 1 |
| 29 | + |
| 30 | +# Change the state of digital_out, and denote this using a time marker |
| 31 | +add_time_marker(t, "Toggle digital_out (high)", verbose=True) |
| 32 | +digital_out.go_high(t) |
| 33 | + |
| 34 | +# Wait for 0.5 seconds |
| 35 | +t += 0.5 |
| 36 | + |
| 37 | +# Ramp analog_out from 0.0 V to 1.0 V over 0.25 s with a 1 kS/s sample rate |
| 38 | +t += analog_out.ramp(t=t, initial=0.0, final=1.0, duration=0.25, samplerate=1e3) |
| 39 | + |
| 40 | +# Change the state of digital_out, and denote this using a time marker |
| 41 | +add_time_marker(t, "Toggle digital_out (low)", verbose=True) |
| 42 | +digital_out.go_low(t) |
| 43 | + |
| 44 | +# Wait for 0.5 seconds |
| 45 | +t += 0.5 |
| 46 | + |
| 47 | +# Stop the experiment shot with stop() |
| 48 | +stop(t) |
0 commit comments