hardware_interfaces.interferometer_counter module

class InterferometerCounter(port: str, interferometer_stage: pi_control.PiStage, adc: Any, bin_config_path: Union[str, bytes, os.PathLike], name: str = 'Interferometer Counter')[source]

Bases: object

InterferometerCounter class is used to obtain the interferometer position for every laser shot.

By sending certain commands the interferometer counter is set to single sequence mode. The offset of the photodiodes is then calculated by moving the motor. Then, the direction of the stage is determined and the polarity of the photodiodes is set respectively. For this process it is necessary to calculate the counter values with the calculate_counter_values method.

Parameters
  • port (str) –

    COM port to which the counter is connected. Please check in the device manager of your operating system.

    • E.g. “COM7”

  • interferometer_stage (PiStage) – Object which contains the functionality of the interferometer stage. Is used for moving the stage etc.

  • adc (AnalogDigitalConverter) – Object that communicates with ADC to which MCT detector is connected.

  • bin_config_path (Path) – Path to configuration file where the calibration values for the calculation of the bins are stored. The values in this file are obtained by measuring the used R2R network

  • name (str, optional) – Name / Identifier to give to this controller. This is relevant for log statements, especially when there is more than one interferometer in the setup. Defaults to “Interferometer Counter”.

connection

Provides the serial connection and commands to the interferometer counter.

Type

SerialInterferometerCounter

name

Name / Identifier to give to this stage. This is relevant for log statements, especially when there is more than one stage in the setup. Defaults to “XYZ Stage”.

Type

str, optional

port

COM port to which the controller is connected. Please check in the device manager of your operating system.

Type

str

interferometer_stage

Connects and initializes the interferometer stage with the Pi_controll module. Provides the functionality in PiStage class.

Type

PiStage

bin_config_path

Path to configuration file. This is where the binlist and the reference values for the R2R network are stored

Type

Path

calculate_counter_values(data: Any) → Any[source]

Determines the interferometer position from the (counter) values that the ADC collected from the R2R-Network.

The counter electronics from Zurich outputs the position via USB (on command) and also on a 16 line parallel port for every laser trigger. The results in a 16 digit binary number that is then converted into 4 digit hexadecimal number. Which is output on a 4 line parallel port (Interferometer counter box BNC R2R 1-4, BNC R2R 5-8 etc.).

This data is recorded by the ADC. To obtain the actual counter values we need to decode the analog voltages that the ADC recorded. This is achieved by binning the data from all four channels accordingly using an array containing reference values and the function np.digitize.

These reference values have to be measured manually from the R2R Network by applying 5V to different R2R inputs and recording the corresponding output voltages. These values have to be written in a .csv file (see existing files). The resulting hexadecimal values for each line are then modified to match their poisition in the hexadecimal tetrade using the function np.left_shift. BNC R2R 1-4 is interpreted to be the channel containing the least significant digit (and so on).

Finally, we get the counter position by summation of all four hexadecimal numbers. We now need to divide by 2 because apparently the circuit counts the zero crossings for both photodiodes. (Technically it only makes to count on one photodiode, because the actual resolution is determined by the HeNe Wavelength.) Afterwards we floor the values to obtain integers. Note this is not mentioned in the datasheet and apparently is a empirically determined phenomenon copied from LabView (see dataprocessing where this method can also be found for an explanation to why this works).

References

H-Lab reference values for R2R-Network.csv
TimingScheme.pdf
Counter für Interferometer; Anleitung; Manual; Universität Zürich.pdf
Parameters

data (ndarray) –

Complete data set from adc (including pixel data, wobbler, R2R etc.) The indices/ rows containing the information of the R2R are selected automatically.

  • shape: 2D

  • E.g. (number of channels, samples to acquire)

Returns

array containing interferometer position in counts.

  • shape: (self.adc.samples_to_acquire)

Return type

ndarray

different_init()[source]
end()[source]
reset_counter()[source]

Reset counter by setting current interferometer position to the counter value 0.

start_counter()[source]

Sets the size of the counter table and is needed to start the counter in general.

Stop counter method not needed because we set counting mode to single sequence mode -> Stops on its own.

class SerialInterferometerCounter(port: str, name: str = 'serial connection to interferometer')[source]

Bases: object

Connecting to the interferometer counter and preamplifier electronics from Zürich with PySerial.

This class is contains methods for all serial commands provided in the manual.

Parameters
  • port (str) –

    COM port to which the controller is connected. Please check in the device manager of your operating system.

    • E.g. “COM7”

  • name (str, optional) – Name / Identifier to give to this controller. This is relevant for log statements, especially when there is more than one interferometer in the setup. Defaults to “serial connection to interferometer”.

port

COM port to which the controller is connected. Please check in the device manager of your operating system.

  • E.g. “COM7”

Type

str

name

Name / Identifier to give to this controller. This is relevant for log statements, especially when there is more than one interferometer in the setup. Defaults to “serial connection to interferometer”.

Type

str, optional

ser

Pyserial object which initiates the communication with the Counter.

Type

serial.Serial

References

Counter für Interferometer; Anleitung; Manual; Universität Zürich.pdf
TimingScheme.pdf
change_test_pattern(value: Optional[int] = None)[source]

Changing test pattern on parallel counter output for checking wiring -> do not provide any trigger signal while enabled

Data type: volatile

Parameters

value (int, optional) – 0 = ASCII, 1 = binary. Defaults to None. If None, a Get command is send instead of a Set command.

collect_data_trigger_calculation()[source]

Start collecting data for PD trigger level calcultion. “v.s. offset calculation” (handwritten in datasheet)

compilation_stamp(value: int)[source]

Compilation stamp

Data type: non-volatile

Parameters
  • value (int) – 21 (count of characters)

  • followed by string (->) –

counter_value(value: Optional[int] = None)[source]

Set the counter value Data type: volatile

Parameters

value (int, optional) – Value between 0 … 65535. Defaults to None. If None, a Get command is send instead of a Set command.

dac_flag(value: Optional[int] = None)[source]

DAC Flag, internal DAC provides trigger level for PD1/ PD2 -> reset of device on change is recommended

Data type: non-volatile

Parameters

value (int, optional) – 0 = disable. 1 = enable. Defaults to None. If None, a Get command is send instead of a Set command.

data_mode(value: Optional[int] = None)[source]

RS232 Data Mode -> disable can improve signal to noise ratio (S/N)

Data type: volatile

Parameters

value (int, optional) – 0 = disable. 1 = counter value stream 1 sec. 2 = counter on trigger (<1.5kHz). Defaults to None. If None, a Get command is send instead of a Set command.

end()[source]

Closes serial connection to the interferometer counter and preamplifier.

get_score_list_pd1(value: int)[source]

Score list PD1 used for trigger level calculation

Data type: volatile

Parameters

value (int) – 0 … 255 = count of values, followed by table

get_score_list_pd2(value: int)[source]

Score list PD2 used for trigger level calculation

Data type: volatile

Parameters

value (int) – 0 … 255 = count of values, followed by table

grabbing_mode_counter_table(value: Optional[int] = None)[source]

Grabbing mode for counter table -> if mode changed, use “size of counter table” command next

Data type: volatile

Parameters

value (int, optional) – 0 = grabbing single sequence 1 = continuous. Defaults to None. If None, a Get command is send instead of a Set command.

output_mode_counter_table(value: Optional[int] = None)[source]

Output mode for counter table (setting for “Read Counter Table” command) -> in binary mode, high byte first

Data type: non-volatile

Parameters

value (int, optional) – 0 = ASCII, 1 = binary. Defaults to None. If None, a Get command is send instead of a Set command.

parallel_counter_mode(value: Optional[int] = None)[source]

Parallel counter output port mode for counter value -> port inactive can improve S/N

Data type: non-volatile

Parameters

value (int, optional) – 0 = positive inactive (force low) 1 = port active. Defaults to None. If None, a Get command is send instead of a Set command.

read()[source]

Reads out all bytes from COM port until newline character appears.

read_counter_table(value: int)[source]

Read counter table. Memory block label, count of values, select output mode first. -> in binary mode, high byte first

Data type: volatile #todo not sure if whole functionality is covered

Parameters

value (int) –

1 … 2 ‘_’ 0 … 8192 -> followed by table

  • 1 … 2 = memory block label

  • 0 … 8192 = count of values

select_polarity_pd1(value: Optional[int] = None)[source]

Select polarity of PD1 signal. reset of counter -> refer to chapter of datasheet “Encoder Counting Modes”

Data type: non-volatile

Parameters

value (int, optional) – 0 = positive, not inverted 1 = negative, inverted. Defaults to None. If None, a Get command is send instead of a Set command.

select_polarity_pd2(value: Optional[int] = None)[source]

Select polarity of PD2 signal. reset of counter -> refer to chapter of datasheet “Encoder Counting Modes”

Data type: non-volatile

Parameters

value (int, optional) – 0 = positive, not inverted 1 = negative, inverted. Defaults to None. If None, a Get command is send instead of a Set command.

select_triggering_counter(value: Optional[int] = None)[source]

Select PD Signal for Triggering Counter. reset of counter -> refer to chapter in datasheet “Encoder counting modes”

Data type: non-volatile

Parameters

value (int, optional) – 0 = positive, not inverted 1 = negative, inverted. Defaults to None. If None, a Get command is send instead of a Set command.

set_nonvolatile_variables_to_default()[source]

Set all nonvolatile variable to default. reset of device ist recommended.

size_counter_table(value: Optional[int] = None)[source]

Size of counter table. Erase counter table and start collecting counter values.

Data type: volatile

Parameters

value (int, optional) – 0 … 8192. Defaults to None. If None, a Get command is send instead of a Set command.

status_counter_table(value: int)[source]

Status counter table. status, number of triggers left to complete counter table #todo not sure if whole functionality is covered

Parameters

value (int) –

0 … 3 ‘_’ 0 …8192

  • 0 … 3 = status

    • 0 = no block ready

    • 1 = block 1 ready for readout

    • 2 = block 2 ready for readout

    • 3 = block write overrun

  • 0 … 8192 = triggers left to complete

stop_collect_data_trigger_calculation()[source]

Stop collecting data, calculate new trigger level for PD1+2 using score lists, set new levels with DAC

trigger_level_pd1(value: Optional[int] = None)[source]

Trigger Level PD1 (“DAC flag” = enable) -> automatic adjustment by T0/T1 commands

Data type: volatile

Parameters

value (int, optional) – Value between 0 … 4095 (=3.3V). Set any value if set is not true. Defaults to None. If None, a Get command is send instead of a Set command.

trigger_level_pd2(value: Optional[int] = None)[source]

Trigger Level PD2 (“DAC flag” = enable) -> automatic adjustment by T0/T1 commands

Data type: volatile

Parameters

value (int, optional) – Value between 0 … 4095 (=3.3V). Defaults to None. If None, a Get command is send instead of a Set command.