Ni Daq Single Axis Scanner - ACBJayichLab/NV_ABJ GitHub Wiki
Importing
from NV_ABJ.hardware_interfaces.scanner.ni_daq_scanner.ni_daq_scanner import *
This is a national instruments controlling class that also includes class that are directly controlled by the DAQ These instruments include the SRS because it is triggered by the DAQ when a list is iterated, the NpPoint Z confocal piezo because the daq provides a voltage that it chases to set the z height, the attocube piezos because they rely on an input and output of the daq to be monitored and controlled, the fast steering mirror because it is controlled in xy position by the daq, and the photo diode that collects the green power
Initialization
from NV_ABJ.hardware_interfaces.scanner.ni_daq_scanner.ni_daq_scanner import NiDaqSingleAxisScanner
scanner = NiDaqSingleAxisScanner(1,“PXI1Slot3”,”ao0”)
- conversion_volts_per_meter:float = How many volts would it be to move the scanner one meter yes this is large but thats just for conversion to standard units
- device_name_output:str = Device name for the output e.g. "PXI1Slot3"
- channel_name_output:str = Name for the channel output e.g. "ao0"
If your scanner has feedback you can define the following values with keyword arguments
- device_name_input:str (Optional) = Device name that the voltage input is attached to e.g. "PXI1Slot3" default None
- channel_name_input:str (Optional) = Name for the channel input e.g. "ai0" default None
- position_limits_m:tuple (Optional) = (Lower limit on distance, Upper limit on distance) in meters. This is to stop over-volting or going past a arbitrary limit. default (None,None)
This is the settings for how the daq will wait for a voltage to be reached
- timeout_waiting_for_voltage_set_s:int (Optional) = default to 10 seconds
- stability_voltage_difference:float (Optional) = default to 0.004 V/sample set
- voltage_sample_rate:int (Optional) = default to 1000 samples
- samples_per_read:int (Optional) = default to 100 samples
Commands
Set Position
This function sets a position in meters as long as it’s within the limits defined. It then will set the daq to a converted voltage. The actual operation of this function will vary based on if you have included a voltage input or just a voltage output. If you have not included a voltage input the daq out put will set the value of the calculated voltage and assume it reaches what we need by calling voltage_out otherwise the command will try to wait for the stabilization of the scanner using wait_for_voltage
scanner.set_position_m(position)
- position:float = The ideal position for the scanner to reach
Get Position
This will return the position of the scanner as a float. If you do not have a feedback loop to the scanner then you will have the float returned of what had previously been set if you do have a voltage input it will read the voltage and convert it to meters
position_m = scanner.get_position_m()
- position_m:float = scanner position in meters
Position to Voltage
This function allows us to determine an appropriate voltage for driving the scanner. This is also where an error will occur if the limits of the scanner are exceeded
voltage_v = scanner. position_to_voltage(position)
- position:float = The input position we want to check in meters
- voltage_v:float = The output voltage for what the scanner should be set to
Raises
- ValueError(f"Can not enter a value smaller than lower position limit of {position_limits_m[0]}")
- ValueError(f"Can not enter a value larger than upper position limit of {position_limits_m[1]}")
Voltage Out
This function is how the class interacts with the daq for setting a voltage and is called when there is no scanner input
scanner.voltage_out(voltage)
- voltage:float = The voltage that will be output to the out port of the class
Wait for Voltage
This function is meant to wait for the stabilization of the voltage. It is called if the scanner has an input sensor attached to the daq.
voltage_reached, voltage_deviation = scanner.wait_for_voltage(voltage)
- voltage:float = The voltage that is trying to be applied to the out port of the class
- voltage_reached:float = The final voltage of the state
- voltage_devivation:float = the standard deviation of the voltage input Raises
- Exception("Failed to stabilize voltage output")
Read Voltage
This is the function that will read the voltage of the input port on the daq it is called by get_position_m and wait_for_voltage
voltage = scanner.read_voltage()
- voltage:float = The voltage at the input port