### Setup WaitMonitor Source: https://context7.com/labscript-suite/labscript/llms.txt Configures wait monitoring to track experiment pauses and handle timeout triggers. ```python from labscript import WaitMonitor, start, stop, wait from labscript_devices.NI_DAQmx.labscript_devices import NI_PCIe_6363 NI_PCIe_6363(name='ni_card', parent_device=clockline, ...) # Configure wait monitoring WaitMonitor( name='wait_monitor', parent_device=ni_card, connection='port0/line0', # Output pulses for timing acquisition_device=ni_card, acquisition_connection='ctr0', # Counter to measure wait durations timeout_device=ni_card, timeout_connection='pfi1', # Trigger output if wait times out timeout_trigger_type='rising' ) start() t = 5 t += wait(label='external_trigger', t=t, timeout=10) stop(t=t+1) ``` -------------------------------- ### Initialize Experiment with start() Source: https://context7.com/labscript-suite/labscript/llms.txt Marks the end of the connection table and begins experiment logic. Returns the earliest time outputs can be commanded. ```python from labscript import start, stop from labscript_devices.PulseBlaster import PulseBlaster # Define connection table PulseBlaster(name='pulseblaster_0', board_number=0) # Start the experiment max_delay = start() # Returns time required for all pseudoclocks to start # Now you can add output instructions # max_delay contains the earliest time outputs can be commanded ``` -------------------------------- ### Configure static analog and digital outputs Source: https://context7.com/labscript-suite/labscript/llms.txt Static outputs are configured once before the experiment starts and cannot be changed during runtime. ```python from labscript import StaticAnalogOut from labscript_devices.NovaTechDDS9M import NovaTechDDS9M NovaTechDDS9M(name='novatech', parent_device=clockline, com_port='COM1') StaticAnalogOut(name='static_voltage', parent_device=novatech, connection='aux0') # Set static value (only once, before start()) static_voltage.constant(value=3.3) # No time argument start() # ... experiment runs with static_voltage fixed at 3.3V ... stop(t=5) ``` ```python from labscript import StaticDigitalOut StaticDigitalOut(name='static_switch', parent_device=device, connection='port0/line0') # Set static state (only once, before start()) static_switch.go_high() # No time argument # or static_switch.go_low() start() stop(t=5) ``` -------------------------------- ### Configure PseudoclockDevice and ClockLine Source: https://context7.com/labscript-suite/labscript/llms.txt Sets up a master timing device and defines clock lines for different timing domains. ```python from labscript import ClockLine, start, stop from labscript_devices.PulseBlaster import PulseBlaster from labscript_devices.NI_DAQmx.labscript_devices import NI_PCIe_6363 # Master pseudoclock device (no trigger_device = master) PulseBlaster(name='pulseblaster', board_number=0) # Create clock lines for different timing domains ClockLine( name='fast_clock', pseudoclock=pulseblaster.pseudoclock, connection='flag 0' ) ClockLine( name='slow_clock', pseudoclock=pulseblaster.pseudoclock, connection='flag 1', ramping_allowed=True # Enable analog ramping on this clock ) # Attach devices to clock lines NI_PCIe_6363( name='ni_card', parent_device=fast_clock, clock_terminal='PFI0', MAX_name='ni_pcie_6363_0' ) start() stop(t=5) ``` -------------------------------- ### Basic labscript Experiment Script Source: https://github.com/labscript-suite/labscript/blob/master/docs/source/introduction.md This script demonstrates the fundamental structure of a labscript experiment, including device connections and a simple sequence of digital output operations. Ensure labscript and necessary device modules are imported. ```python from labscript import * from labscript_devices.PulseBlaster import PulseBlaster # Connection Table PulseBlaster(name='pulseblaster_0', board_number=0) DigitalOut(name='my_digital_out', parent_device=pulseblaster_0.direct_outputs, connection='flag 2') #Experiment Logic start() my_digital_out.go_low(t=0) # start low at the start my_digital_out.go_high(t=1) # go high at 1s stop(2) # stop at 2s ``` -------------------------------- ### StaticAnalogOut Source: https://context7.com/labscript-suite/labscript/llms.txt Analog output that can only be set once before the experiment runs. ```APIDOC ## StaticAnalogOut ### Description Analog output that can only be set once before the experiment runs. ### Method StaticAnalogOut.constant ### Endpoint N/A (Configured during initialization) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **value** (float) - Required - The constant value to set for the analog output. ### Request Example ```python from labscript import StaticAnalogOut from labscript_devices.NovaTechDDS9M import NovaTechDDS9M NovaTechDDS9M(name='novatech', parent_device=clockline, com_port='COM1') StaticAnalogOut(name='static_voltage', parent_device=novatech, connection='aux0') static_voltage.constant(value=3.3) start() stop(t=5) ``` ### Response #### Success Response (200) None (This method configures the output, no direct response body is returned). #### Response Example None ``` -------------------------------- ### AnalogIn.acquire Source: https://context7.com/labscript-suite/labscript/llms.txt Commands acquisition of analog input data during the experiment. ```APIDOC ## AnalogIn.acquire ### Description Commands acquisition of analog input data during the experiment. ### Method AnalogIn.acquire ### Endpoint N/A (Configured during initialization) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **label** (str) - Required - A label for the acquired data. - **start_time** (float) - Required - The time at which to start acquisition. - **end_time** (float) - Required - The time at which to end acquisition. - **wait_label** (str, optional) - A label to wait for before starting acquisition. - **scale_factor** (float, optional) - A scaling factor to apply to the acquired data. - **units** (str, optional) - The units of the input signal. ### Request Example ```python from labscript import AnalogIn, start, stop from labscript_devices.NI_DAQmx.labscript_devices import NI_PCIe_6363 NI_PCIe_6363( name='ni_card', parent_device=clockline, acquisition_rate=100e3 ) AnalogIn( name='photodiode', parent_device=ni_card, connection='ai0', scale_factor=1.0, units='Volts' ) start() photodiode.acquire( label='fluorescence_signal', start_time=0, end_time=1 ) photodiode.acquire(label='background', start_time=2, end_time=2.5) photodiode.acquire(label='signal', start_time=3, end_time=4) stop(t=5) ``` ### Response #### Success Response (200) - **duration** (float) - The duration of the acquisition. #### Response Example ``` 1.0 ``` ``` -------------------------------- ### Apply Unit Conversion Classes Source: https://context7.com/labscript-suite/labscript/llms.txt Uses calibration classes to convert between physical units and hardware-specific values. ```python from labscript import AnalogOut, start, stop from labscript_utils.unitconversions import example1 AnalogOut( name='coil', parent_device=ni_card, connection='ao0', unit_conversion_class=example1, unit_conversion_parameters={'a': 5, 'b': 1, 'magnitudes': ['m', 'u']} ) start() # Program in different units coil.constant(t=0, value=1000, units='mGauss') # milliGauss coil.constant(t=1, value=5, units='A') # Amps coil.ramp(t=2, duration=1, initial=0, final=10, samplerate=1e4, units='Gauss') stop(t=4) ``` -------------------------------- ### Configure Secondary Pseudoclock Devices Source: https://context7.com/labscript-suite/labscript/llms.txt Establishes a triggering hierarchy where secondary pseudoclocks are triggered by a master device. ```python from labscript import start, stop from labscript_devices.PulseBlaster import PulseBlaster from labscript_devices.PineBlaster import PineBlaster from labscript_devices.NI_DAQmx.labscript_devices import NI_PCI_6733 # Master pseudoclock PulseBlaster(name='pulseblaster', board_number=0) # Secondary pseudoclock triggered by master PineBlaster( name='pineblaster', trigger_device=ni_card, trigger_connection='port0/line15', usbport='COM7' ) # Device on secondary pseudoclock NI_PCI_6733( name='ni_secondary', parent_device=pineblaster.clockline, clock_terminal='PFI0' ) # Set when secondary clock should start pineblaster.set_initial_trigger_time(t=0.5) start() # Output on secondary clock must wait for trigger delay # Use output.t0 to get the earliest allowed time analog_on_secondary.constant(t=analog_on_secondary.t0, value=5) stop(t=5) ``` -------------------------------- ### Acquire analog input data Source: https://context7.com/labscript-suite/labscript/llms.txt Commands data acquisition from analog input channels during an experiment. ```python from labscript import AnalogIn, start, stop from labscript_devices.NI_DAQmx.labscript_devices import NI_PCIe_6363 NI_PCIe_6363( name='ni_card', parent_device=clockline, acquisition_rate=100e3, # 100 kHz acquisition rate ... ) AnalogIn( name='photodiode', parent_device=ni_card, connection='ai0', scale_factor=1.0, units='Volts' ) start() # Acquire data from t=0 to t=1 second duration = photodiode.acquire( label='fluorescence_signal', start_time=0, end_time=1 ) # Multiple acquisitions with different labels photodiode.acquire(label='background', start_time=2, end_time=2.5) photodiode.acquire(label='signal', start_time=3, end_time=4) stop(t=5) ``` -------------------------------- ### Control Digital Outputs with DigitalOut Source: https://context7.com/labscript-suite/labscript/llms.txt Manages binary state changes for triggering and switching. Requires a parent device connection. ```python from labscript import DigitalOut, start, stop from labscript_devices.PulseBlaster import PulseBlaster PulseBlaster(name='pulseblaster_0', board_number=0) DigitalOut( name='trigger_out', parent_device=pulseblaster_0.direct_outputs, connection='flag 0' ) start() # Control digital output timing trigger_out.go_low(t=0) # Start low trigger_out.go_high(t=1) # Go high at 1 second trigger_out.go_low(t=1.5) # Go low at 1.5 seconds stop(t=2) ``` -------------------------------- ### Add Time Markers Source: https://context7.com/labscript-suite/labscript/llms.txt Adds visual markers to experiment timelines for use in runviewer and BLACS. ```python from labscript import add_time_marker, start, stop start() add_time_marker(t=0, label='MOT Loading', color='blue') add_time_marker(t=1, label='Compression', color='green') add_time_marker(t=2, label='Evaporation', color=(255, 128, 0)) # RGB tuple add_time_marker(t=5, label='Imaging', color='#ff0000', verbose=True) stop(t=6) ``` -------------------------------- ### Perform smooth sine ramp Source: https://context7.com/labscript-suite/labscript/llms.txt Performs a smooth ramp using a squared sine profile. ```python from labscript import AnalogOut, start, stop AnalogOut(name='trap_depth', parent_device=ni_card, connection='ao0') start() # Smooth ramp from 0 to 5V over 0.5 seconds trap_depth.sine_ramp( t=0, duration=0.5, initial=0, final=5, samplerate=10e3 ) stop(t=1) ``` -------------------------------- ### StaticDigitalOut Source: https://context7.com/labscript-suite/labscript/llms.txt Digital output that can only be set once before the experiment runs. ```APIDOC ## StaticDigitalOut ### Description Digital output that can only be set once before the experiment runs. ### Method StaticDigitalOut.go_high, StaticDigitalOut.go_low ### Endpoint N/A (Configured during initialization) ### Parameters None ### Request Example ```python from labscript import StaticDigitalOut StaticDigitalOut(name='static_switch', parent_device=device, connection='port0/line0') static_switch.go_high() # or static_switch.go_low() start() stop(t=5) ``` ### Response #### Success Response (200) None (These methods configure the output, no direct response body is returned). #### Response Example None ``` -------------------------------- ### AnalogOut.exp_ramp Source: https://context7.com/labscript-suite/labscript/llms.txt Performs an exponential ramp with rate determined by asymptotic value. ```APIDOC ## AnalogOut.exp_ramp(t, duration, initial, final, samplerate, zero=0, units=None, truncation=None, truncation_type='linear') ### Description Performs an exponential ramp with rate determined by asymptotic value. ### Method AnalogOut.exp_ramp ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **t** (float) - Required - The start time of the ramp. - **duration** (float) - Required - The duration of the ramp. - **initial** (float) - Required - The initial value of the ramp. - **final** (float) - Required - The final value of the ramp. - **samplerate** (float) - Required - The sampling rate for the ramp. - **zero** (float) - Optional - The asymptotic value (default: 0). - **units** (string) - Optional - The units of the values. - **truncation** (float) - Optional - The value at which to truncate the ramp. - **truncation_type** (string) - Optional - The type of truncation ('linear' or 'exponential', default: 'linear'). ### Request Example ```python evap_power.exp_ramp( t=0, duration=2, initial=10, final=1, zero=0, # Asymptotic value samplerate=10e3 ) ``` ### Response #### Success Response (200) None (This is a command, not a data retrieval endpoint) #### Response Example None ``` -------------------------------- ### AnalogOut.sine_ramp Source: https://context7.com/labscript-suite/labscript/llms.txt Performs a smooth ramp using a squared sine profile. ```APIDOC ## AnalogOut.sine_ramp(t, duration, initial, final, samplerate, units=None, truncation=1.0) ### Description Performs a smooth ramp using a squared sine profile: `f(t) = (final-initial)*(sin(pi*t/(2*duration)))^2 + initial` ### Method AnalogOut.sine_ramp ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **t** (float) - Required - The start time of the ramp. - **duration** (float) - Required - The duration of the ramp. - **initial** (float) - Required - The initial value of the ramp. - **final** (float) - Required - The final value of the ramp. - **samplerate** (float) - Required - The sampling rate for the ramp. - **units** (string) - Optional - The units of the values. - **truncation** (float) - Optional - Truncates the ramp to a fraction of its full duration (0.0 to 1.0). ### Request Example ```python trap_depth.sine_ramp( t=0, duration=0.5, initial=0, final=5, samplerate=10e3 ) ``` ### Response #### Success Response (200) None (This is a command, not a data retrieval endpoint) #### Response Example None ``` -------------------------------- ### Perform exponential ramp Source: https://context7.com/labscript-suite/labscript/llms.txt Performs an exponential ramp with the rate determined by an asymptotic value. ```python from labscript import AnalogOut, start, stop AnalogOut(name='evap_power', parent_device=ni_card, connection='ao0') start() # Exponential decay from 10 to 1 with asymptote at 0 evap_power.exp_ramp( t=0, duration=2, initial=10, final=1, zero=0, # Asymptotic value samplerate=10e3 ) # With linear truncation (stop when value reaches 2) evap_power.exp_ramp( t=3, duration=2, initial=10, final=1, zero=0, samplerate=10e3, truncation=2, truncation_type='linear' ) stop(t=6) ``` -------------------------------- ### AnalogOut.constant Source: https://context7.com/labscript-suite/labscript/llms.txt Sets an analog output to a constant value at a specified time. ```APIDOC ## AnalogOut.constant(t, value, units=None) ### Description Sets an analog output to a constant value at the specified time. ### Method AnalogOut.constant ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **t** (float) - Required - The time at which to set the constant value. - **value** (float) - Required - The constant value to set. - **units** (string) - Optional - The units of the value. ### Request Example ```python voltage_out.constant(t=0, value=0) ``` ### Response #### Success Response (200) None (This is a command, not a data retrieval endpoint) #### Response Example None ``` -------------------------------- ### Terminate Experiment with stop() Source: https://context7.com/labscript-suite/labscript/llms.txt Ends the experiment at time t and compiles instructions to an HDF5 file. Optional cycle time control is available for BLACS integration. ```python from labscript import start, stop start() # ... experiment logic ... # End the experiment at t=10 seconds stop(t=10) # With optional cycle time control for BLACS stop(t=10, target_cycle_time=15.0) # Request 15s between shot starts ``` -------------------------------- ### AnalogOut.exp_ramp_t Source: https://context7.com/labscript-suite/labscript/llms.txt Performs an exponential ramp with rate determined by time constant. ```APIDOC ## AnalogOut.exp_ramp_t(t, duration, initial, final, time_constant, samplerate, units=None, truncation=None, truncation_type='linear') ### Description Performs an exponential ramp with rate determined by time constant. ### Method AnalogOut.exp_ramp_t ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **t** (float) - Required - The start time of the ramp. - **duration** (float) - Required - The duration of the ramp. - **initial** (float) - Required - The initial value of the ramp. - **final** (float) - Required - The final value of the ramp. - **time_constant** (float) - Required - The time constant of the exponential decay. - **samplerate** (float) - Required - The sampling rate for the ramp. - **units** (string) - Optional - The units of the values. - **truncation** (float) - Optional - The value at which to truncate the ramp. - **truncation_type** (string) - Optional - The type of truncation ('linear' or 'exponential', default: 'linear'). ### Request Example ```python mot_power.exp_ramp_t( t=0, duration=2, initial=10, final=0.5, time_constant=0.5, # 500ms time constant samplerate=10e3 ) ``` ### Response #### Success Response (200) None (This is a command, not a data retrieval endpoint) #### Response Example None ``` -------------------------------- ### StaticDDS Source: https://context7.com/labscript-suite/labscript/llms.txt DDS output where frequency, amplitude, and phase are set once before experiment. ```APIDOC ## StaticDDS ### Description DDS output where frequency, amplitude, and phase are set once before experiment. ### Method StaticDDS.setfreq, StaticDDS.setamp, StaticDDS.setphase ### Endpoint N/A (Configured during initialization) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **value** - Required - The value to set for frequency, amplitude, or phase. ### Request Example ```python from labscript import StaticDDS, MHz, start, stop StaticDDS(name='lo_source', parent_device=novatech, connection='channel 2') lo_source.setfreq(value=10*MHz) lo_source.setamp(value=1.0) lo_source.setphase(value=0) start() stop(t=5) ``` ### Response #### Success Response (200) None (These methods configure the output, no direct response body is returned). #### Response Example None ``` -------------------------------- ### Perform exponential ramp with time constant Source: https://context7.com/labscript-suite/labscript/llms.txt Performs an exponential ramp with the rate determined by a specific time constant. ```python from labscript import AnalogOut, start, stop AnalogOut(name='mot_power', parent_device=ni_card, connection='ao1') start() # Exponential ramp with 500ms time constant mot_power.exp_ramp_t( t=0, duration=2, initial=10, final=0.5, time_constant=0.5, # 500ms time constant samplerate=10e3 ) stop(t=3) ``` -------------------------------- ### Manage Mechanical Shutters with Shutter Source: https://context7.com/labscript-suite/labscript/llms.txt Provides automatic delay compensation for mechanical shutters based on specified open and close timings. ```python from labscript import Shutter, start, stop from labscript_devices.NI_DAQmx.labscript_devices import NI_PCIe_6363 NI_PCIe_6363(name='ni_card', parent_device=clockline, ...) Shutter( name='laser_shutter', parent_device=ni_card, connection='port0/line0', delay=(0.003, 0.002), # (open_delay, close_delay) in seconds open_state=1 # Which digital state opens the shutter ) start() # Shutter automatically compensates for mechanical delays laser_shutter.close(t=0) # Start closed laser_shutter.open(t=1.0) # Open precisely at t=1.0s (command sent at t=0.997s) laser_shutter.close(t=2.0) # Close precisely at t=2.0s (command sent at t=1.998s) stop(t=3) ``` -------------------------------- ### Pause Experiment with wait() Source: https://context7.com/labscript-suite/labscript/llms.txt Commands pseudoclocks to pause until an external trigger is received or a timeout occurs. The returned delay must be added to the current time variable. ```python from labscript import start, stop, wait start() t = 0 # Wait for external trigger at t=5s, with 2 second timeout delay = wait(label='my_wait', t=5, timeout=2) t += delay # Update time variable with retriggering delay # Continue experiment after wait stop(t=10) ``` -------------------------------- ### AnalogOut.square_wave Source: https://context7.com/labscript-suite/labscript/llms.txt Generates a square wave output. ```APIDOC ## AnalogOut.square_wave(t, duration, amplitude, frequency, phase, offset, duty_cycle, samplerate, units=None, truncation=1.0) ### Description Generates a square wave output. ### Method AnalogOut.square_wave ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **t** (float) - Required - The start time of the square wave. - **duration** (float) - Required - The duration of the square wave. - **amplitude** (float) - Required - The peak-to-peak amplitude of the square wave. - **frequency** (float) - Required - The frequency of the square wave (Hz). - **phase** (float) - Required - The phase of the square wave (0 to 1, representing a fraction of a cycle). - **offset** (float) - Required - The DC offset of the square wave. - **duty_cycle** (float) - Required - The duty cycle of the square wave (0.0 to 1.0). - **samplerate** (float) - Required - The sampling rate for the square wave. - **units** (string) - Optional - The units of the values. - **truncation** (float) - Optional - Truncates the square wave to a fraction of its full duration (0.0 to 1.0). ### Request Example ```python chopper.square_wave( t=0, duration=0.1, amplitude=5, # Peak-to-peak amplitude frequency=1000, # 1 kHz phase=0, # Phase from 0 to 1 (not 2*pi) offset=2.5, # Center at 2.5V (output: 0V to 5V) duty_cycle=0.5, # 50% duty cycle samplerate=100e3 ) ``` ### Response #### Success Response (200) None (This is a command, not a data retrieval endpoint) #### Response Example None ``` -------------------------------- ### Perform piecewise acceleration ramp Source: https://context7.com/labscript-suite/labscript/llms.txt Performs a ramp where the second derivative follows a triangle wave for smooth acceleration. ```python from labscript import AnalogOut, start, stop AnalogOut(name='transport_pos', parent_device=ni_card, connection='ao0') start() # Smooth transport with piecewise acceleration transport_pos.piecewise_accel_ramp( t=0, duration=1, initial=0, final=10, samplerate=10e3 ) stop(t=2) ``` -------------------------------- ### Core Experiment Functions Source: https://context7.com/labscript-suite/labscript/llms.txt Essential functions to manage the lifecycle and timing of an experiment. ```APIDOC ## start() ### Description Indicates the end of the connection table and the start of experiment logic. Must be called before any output instructions. ### Method `start` ### Endpoint N/A (Python function) ### Parameters None ### Request Example ```python from labscript import start, stop from labscript_devices.PulseBlaster import PulseBlaster # Define connection table PulseBlaster(name='pulseblaster_0', board_number=0) # Start the experiment max_delay = start() # Returns time required for all pseudoclocks to start ``` ### Response #### Success Response (200) - **max_delay** (float) - Time required for all pseudoclocks to start. ``` ```APIDOC ## stop(t, target_cycle_time=None, cycle_time_delay_after_programming=False) ### Description Indicates the end of the experiment at time `t` and initiates compilation of hardware instructions to the HDF5 shot file. ### Method `stop` ### Endpoint N/A (Python function) ### Parameters - **t** (float) - Required - The time at which the experiment ends. - **target_cycle_time** (float) - Optional - The desired time between the start of consecutive shots. - **cycle_time_delay_after_programming** (bool) - Optional - If True, the cycle time delay is applied after programming. ### Request Example ```python from labscript import start, stop start() # ... experiment logic ... # End the experiment at t=10 seconds stop(t=10) # With optional cycle time control for BLACS stop(t=10, target_cycle_time=15.0) # Request 15s between shot starts ``` ### Response #### Success Response (200) None (compiles shot file). ``` ```APIDOC ## wait(label, t, timeout=5) ### Description Commands pseudoclocks to pause until resumed by an external trigger or timeout. ### Method `wait` ### Endpoint N/A (Python function) ### Parameters - **label** (str) - Required - A unique identifier for the wait condition. - **t** (float) - Required - The time at which the wait should occur. - **timeout** (float) - Optional - The maximum time to wait for the external trigger before timing out. Defaults to 5 seconds. ### Request Example ```python from labscript import start, stop, wait start() t = 0 # Wait for external trigger at t=5s, with 2 second timeout delay = wait(label='my_wait', t=5, timeout=2) t += delay # Update time variable with retriggering delay # Continue experiment after wait stop(t=10) ``` ### Response #### Success Response (200) - **delay** (float) - The actual delay introduced by the wait command, accounting for retriggering or timeout. ``` -------------------------------- ### AnalogOut.ramp Source: https://context7.com/labscript-suite/labscript/llms.txt Performs a linear ramp from an initial to a final value over a specified duration. ```APIDOC ## AnalogOut.ramp(t, duration, initial, final, samplerate, units=None, truncation=1.0) ### Description Performs a linear ramp from initial to final value: `f(t) = ((final - initial)/duration)*t + initial` ### Method AnalogOut.ramp ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **t** (float) - Required - The start time of the ramp. - **duration** (float) - Required - The duration of the ramp. - **initial** (float) - Required - The initial value of the ramp. - **final** (float) - Required - The final value of the ramp. - **samplerate** (float) - Required - The sampling rate for the ramp. - **units** (string) - Optional - The units of the values. - **truncation** (float) - Optional - Truncates the ramp to a fraction of its full duration (0.0 to 1.0). ### Request Example ```python ramp_duration = coil_current.ramp( t=0, duration=2, initial=0, final=5, samplerate=10e3 ) ``` ### Response #### Success Response (200) Returns the total duration of the ramp including any truncation. #### Response Example ```json 2.0 ``` ``` -------------------------------- ### Perform linear ramp Source: https://context7.com/labscript-suite/labscript/llms.txt Performs a linear ramp between initial and final values over a specified duration. ```python from labscript import AnalogOut, start, stop AnalogOut(name='coil_current', parent_device=ni_card, connection='ao1') start() # Linear ramp from 0 to 5V over 2 seconds at 10kHz sample rate ramp_duration = coil_current.ramp( t=0, duration=2, initial=0, final=5, samplerate=10e3 ) # Truncated ramp (only first 70% of the ramp) coil_current.ramp( t=3, duration=2, initial=5, final=0, samplerate=10e3, truncation=0.7 # Stop at 70% of the ramp ) stop(t=6) ``` -------------------------------- ### AnalogOut.customramp Source: https://context7.com/labscript-suite/labscript/llms.txt Defines a custom waveform using an arbitrary function for Analog Output. ```APIDOC ## AnalogOut.customramp(t, duration, function, *args, samplerate, units=None, truncation=1.0, **kwargs) ### Description Defines a custom waveform using an arbitrary function. ### Method AnalogOut.customramp ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **t** (float) - Required - The starting time for the waveform. - **duration** (float) - Required - The duration of the waveform. - **function** (callable) - Required - The arbitrary function defining the waveform. It should accept relative time and duration as its first two arguments. - **samplerate** (float) - Required - The sampling rate for the waveform. - **units** (str, optional) - The units of the output signal. - **truncation** (float, optional) - Value between 0 and 1 to truncate the waveform. - **args** - Positional arguments to pass to the custom function. - **kwargs** - Keyword arguments to pass to the custom function. ### Request Example ```python import numpy as np from labscript import AnalogOut, start, stop AnalogOut(name='custom_out', parent_device=ni_card, connection='ao0') def gaussian_pulse(t, duration, amplitude, center, sigma): return amplitude * np.exp(-((t - center)**2) / (2 * sigma**2)) start() custom_out.customramp( t=0, duration=1, function=gaussian_pulse, amplitude=5, center=0.5, sigma=0.1, samplerate=10e3 ) stop(t=2) ``` ### Response #### Success Response (200) None (This method configures the output, no direct response body is returned). #### Response Example None ``` -------------------------------- ### Set constant analog output Source: https://context7.com/labscript-suite/labscript/llms.txt Sets an analog output to a constant value at a specific time. ```python from labscript import AnalogOut, start, stop from labscript_devices.NI_DAQmx.labscript_devices import NI_PCIe_6363 NI_PCIe_6363(name='ni_card', parent_device=clockline, ...) AnalogOut( name='voltage_out', parent_device=ni_card, connection='ao0', limits=(-10, 10) # Optional voltage limits ) start() voltage_out.constant(t=0, value=0) # 0V at start voltage_out.constant(t=1, value=2.5) # 2.5V at 1 second voltage_out.constant(t=2, value=-1.0) # -1.0V at 2 seconds stop(t=3) ``` -------------------------------- ### Generate square wave Source: https://context7.com/labscript-suite/labscript/llms.txt Generates a square wave output with specified frequency and duty cycle. ```python from labscript import AnalogOut, start, stop AnalogOut(name='chopper', parent_device=ni_card, connection='ao0') start() # 1 kHz square wave, 5V peak-to-peak, 50% duty cycle chopper.square_wave( t=0, duration=0.1, amplitude=5, # Peak-to-peak amplitude frequency=1000, # 1 kHz phase=0, # Phase from 0 to 1 (not 2*pi) offset=2.5, # Center at 2.5V (output: 0V to 5V) duty_cycle=0.5, # 50% duty cycle samplerate=100e3 ) stop(t=1) ``` -------------------------------- ### Repeat Pulse Sequences with repeat_pulse_sequence() Source: https://context7.com/labscript-suite/labscript/llms.txt Generates repeating modulation patterns on a digital output for a defined duration and sample rate. ```python from labscript import DigitalOut, start, stop DigitalOut(name='modulator', parent_device=ni_card, connection='port0/line1') start() # Define pulse sequence as list of (time, state) tuples pulse_pattern = [ (0.0, 1), # High at start of period (0.001, 0), # Low after 1ms (0.003, 1), # High at 3ms (0.004, 0), # Low at 4ms ] # Repeat pattern from t=1s for 0.5s duration, 5ms period, 100kHz sample rate modulator.repeat_pulse_sequence( t=1, duration=0.5, pulse_sequence=pulse_pattern, period=0.005, samplerate=100e3 ) stop(t=2) ``` -------------------------------- ### AnalogOut.piecewise_accel_ramp Source: https://context7.com/labscript-suite/labscript/llms.txt Ramp where the second derivative follows a triangle wave, providing smooth acceleration. ```APIDOC ## AnalogOut.piecewise_accel_ramp(t, duration, initial, final, samplerate, units=None, truncation=1.0) ### Description Ramp where the second derivative follows a triangle wave, providing smooth acceleration. ### Method AnalogOut.piecewise_accel_ramp ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **t** (float) - Required - The start time of the ramp. - **duration** (float) - Required - The duration of the ramp. - **initial** (float) - Required - The initial value of the ramp. - **final** (float) - Required - The final value of the ramp. - **samplerate** (float) - Required - The sampling rate for the ramp. - **units** (string) - Optional - The units of the values. - **truncation** (float) - Optional - Truncates the ramp to a fraction of its full duration (0.0 to 1.0). ### Request Example ```python transport_pos.piecewise_accel_ramp( t=0, duration=1, initial=0, final=10, samplerate=10e3 ) ``` ### Response #### Success Response (200) None (This is a command, not a data retrieval endpoint) #### Response Example None ``` -------------------------------- ### AnalogOut.sine Source: https://context7.com/labscript-suite/labscript/llms.txt Outputs a sinusoidal waveform. ```APIDOC ## AnalogOut.sine(t, duration, amplitude, angfreq, phase, dc_offset, samplerate, units=None, truncation=1.0) ### Description Outputs a sinusoidal waveform: `f(t) = amplitude*sin(angfreq*t + phase) + dc_offset` ### Method AnalogOut.sine ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **t** (float) - Required - The start time of the sine wave. - **duration** (float) - Required - The duration of the sine wave. - **amplitude** (float) - Required - The amplitude of the sine wave. - **angfreq** (float) - Required - The angular frequency of the sine wave (radians per second). - **phase** (float) - Required - The phase of the sine wave (radians). - **dc_offset** (float) - Required - The DC offset of the sine wave. - **samplerate** (float) - Required - The sampling rate for the sine wave. - **units** (string) - Optional - The units of the values. - **truncation** (float) - Optional - Truncates the sine wave to a fraction of its full duration (0.0 to 1.0). ### Request Example ```python rf_amplitude.sine( t=0, duration=1, amplitude=2, angfreq=2*np.pi*10, # 10 Hz phase=0, dc_offset=2.5, samplerate=10e3 ) ``` ### Response #### Success Response (200) None (This is a command, not a data retrieval endpoint) #### Response Example None ``` -------------------------------- ### DDS API Source: https://context7.com/labscript-suite/labscript/llms.txt Controls RF frequency sources with independent frequency, amplitude, and phase channels. ```APIDOC ## DDS ### Description Controls RF frequency sources with independent frequency, amplitude, and phase channels. ### Method DDS.setfreq, DDS.setamp, DDS.setphase, DDS.frequency.ramp ### Endpoint N/A (Configured during initialization) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **t** (float) - Required - The time at which to set the parameter. - **value** - Required - The value to set for frequency, amplitude, or phase. - **duration** (float) - Required for ramp - The duration of the frequency ramp. - **initial** - Required for ramp - The initial frequency for the ramp. - **final** - Required for ramp - The final frequency for the ramp. - **samplerate** (float) - Required for ramp - The sampling rate for the ramp. ### Request Example ```python from labscript import DDS, MHz, start, stop from labscript_devices.NovaTechDDS9M import NovaTechDDS9M NovaTechDDS9M(name='novatech', parent_device=clockline, com_port='COM1') DDS( name='rf_source', parent_device=novatech, connection='channel 0', freq_limits=(0, 200*MHz), amp_limits=(0, 1) ) start() rf_source.setfreq(t=0, value=80*MHz) rf_source.setamp(t=0, value=0.5) rf_source.setphase(t=0, value=0) rf_source.setfreq(t=1, value=90*MHz) rf_source.frequency.ramp( t=2, duration=0.5, initial=90*MHz, final=100*MHz, samplerate=10e3 ) stop(t=3) ``` ### Response #### Success Response (200) None (These methods configure the output, no direct response body is returned). #### Response Example None ``` ```APIDOC ## DDS with digital gate ### Description DDS output with enable/disable control via digital gate. ### Method DDS.enable, DDS.disable ### Endpoint N/A (Configured during initialization) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **t** (float) - Required - The time at which to enable or disable the output. ### Request Example ```python from labscript import DDS, MHz, start, stop DDS( name='gated_rf', parent_device=novatech, connection='channel 0', digital_gate={ 'device': ni_card, 'connection': 'port0/line0' } ) start() gated_rf.setfreq(t=0, value=80*MHz) gated_rf.setamp(t=0, value=1.0) gated_rf.disable(t=0) # or gated_rf.enable(t=1) # or gated_rf.disable(t=2) stop(t=3) ``` ### Response #### Success Response (200) None (These methods configure the output, no direct response body is returned). #### Response Example None ``` ```APIDOC ## DDS.pulse ### Description Convenience method to output a complete RF pulse. ### Method DDS.pulse ### Endpoint N/A (Configured during initialization) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **t** (float) - Required - The starting time of the pulse. - **duration** (float) - Required - The duration of the RF pulse. - **amplitude** (float) - Required - The amplitude of the RF pulse. - **frequency** (float) - Required - The frequency of the RF pulse. - **phase** (float, optional) - The phase of the RF pulse. Defaults to None. - **print_summary** (bool, optional) - If True, prints pulse information during compilation. ### Request Example ```python from labscript import DDS, MHz, ms, start, stop DDS( name='rf_pulse', parent_device=novatech, connection='channel 0', digital_gate={'device': ni_card, 'connection': 'port0/line0'} ) start() rf_pulse.pulse( t=1, duration=1*ms, amplitude=0.8, frequency=80*MHz, phase=0, print_summary=True ) stop(t=3) ``` ### Response #### Success Response (200) None (This method configures the output, no direct response body is returned). #### Response Example None ```