Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 132 additions & 12 deletions src/navigate/model/devices/APIs/asi/asi_tiger_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,9 @@ def set_feedback_alignment(self, axis: str, aa: float) -> None:
decreased by 1 or 2 as described at the page on tuning stages to minimize
move time.

Desirable values for the autozero command are between 90 and 164. We attempt
to autozero it 3x.

Parameters
----------
axis : str
Expand All @@ -273,8 +276,39 @@ def set_feedback_alignment(self, axis: str, aa: float) -> None:
"""
self.send_command(f"AA {axis}={aa}\r")
self.read_response()
self.send_command(f"AZ {axis}\r")
self.read_response()

for i in range(3):
self.send_command(f"AZ {axis}\r")

def get_feedback_alignment(self, axis: str) -> float:
"""Get the stage feedback alignment.

Returns the current value of the feedback alignment for the
specified axis. The value is in the range of 0 to 1000, where 0 is the lowest
drive strength and 1000 is the highest drive strength.

Currently only set to handle one axis at a time.

Multi-axis command example:
Output command: AA X? Y? Z? T? V? W?
Response: :A X=88 Y=91 Z=91 T=85 V=91 W=88
Single-axis command example:
Output command: AA X?
Response: :A X=88

Parameters
----------
axis : str
Stage axis

Returns
-------
float
Feedback alignment value
"""
self.send_command(f"AA {axis}?\r")
response = self.read_response()
return float(response.split("=")[1])

def set_backlash(self, axis: str, val: float) -> None:
"""Enable/disable stage backlash correction.
Expand Down Expand Up @@ -302,6 +336,33 @@ def set_backlash(self, axis: str, val: float) -> None:
self.send_command(f"B {axis}={val:.7f}\r")
self.read_response()

def get_backlash(self, axis: str) -> float:
"""Get the stage backlash correction value.

Currently only set to handle one axis at a time.

Multi-axis command example:
Output command: B X? Y? Z? T? V?
Response: :X=0.000000 Y=0.000000 Z=0.000000 T=0.000000 V=0.000000 A

Single-axis command example:
Output command: B X?
Response: :X=0.000000 A

Parameters
----------
axis : str
Stage axis

Returns
-------
float
Distance of anti-backlash motion [mm]
"""
self.send_command(f"B {axis}?\r")
response = self.read_response()
return float(response.split("=")[1].split()[0])

def set_finishing_accuracy(self, axis: str, ac: float) -> None:
"""Set the stage finishing accuracy.

Expand All @@ -324,6 +385,32 @@ def set_finishing_accuracy(self, axis: str, ac: float) -> None:
self.send_command(f"PC {axis}={ac:.7f}\r")
self.read_response()

def get_finishing_accuracy(self, axis: str) -> float:
"""Get the stage finishing accuracy.

Currently only set to handle one axis at a time.

Multi-axis command example:
Output command: PC X? Y? Z? T? V? W?
Response: :A X=88 Y=91 Z=91 T=85 V=91 W=88
Single-axis command example:
Output command: PC X?
Response: :A X=88

Parameters
----------
axis : str
Stage axis

Returns
-------
float
Position error [mm]
"""
self.send_command(f"PC {axis}?\r")
response = self.read_response()
return float(response.split("=")[1])

def set_error(self, axis: str, ac: float) -> None:
"""Set the stage drift error

Expand All @@ -345,6 +432,34 @@ def set_error(self, axis: str, ac: float) -> None:
self.send_command(f"E {axis}={ac:.7f}\r")
self.read_response()

def get_error(self, axis: str) -> float:
"""Get the current stage error

Get the current Drift Error setting. Currently only set to handle
one axis at a time.

Multi-axis command example:
Output command: E X? Y? Z? T? V?
Response: :X=0.000780 Y=0.000780 Z=0.000780 T=0.100000 V=0.000780 A
Single-axis command example:
Output command: E X?
Response: :X=0.000780 A


Parameters
----------
axis : str
Stage axis

Returns
-------
float
Position error [mm]
"""
self.send_command(f"E {axis}?\r")
response = self.read_response()
return float(response.split("=")[1].split()[0])

##### END TODO #####

def disconnect_from_serial(self) -> None:
Expand Down Expand Up @@ -1012,34 +1127,39 @@ def logic_card_off(self, axis: str):
self.send_command(f"6 CCA Z=0\r")
self.read_response()

def logic_cell_on(self, axis : str):
def logic_cell_on(self, axis: str):
"""Turn on internal logic cell

Parameters
----------
axis : str
The axis of the internal logic cell
"""
self.send_command(f'6 M E = {axis}\r')
self.send_command(f"6 M E = {axis}\r")
self.read_response()
self.send_command(f'6 CCA Z=1\r')
self.send_command(f"6 CCA Z=1\r")
self.read_response()

def logic_cell_off(self, axis :str):
def logic_cell_off(self, axis: str):
"""Turn off internal logic cell

Parameters
----------
axis : str
The axis of the internal logic cell
"""
self.send_command(f'6 M E = {axis}\r')
self.send_command(f"6 M E = {axis}\r")
self.read_response()
self.send_command(f'6 CCA Z=0\r')
self.send_command(f"6 CCA Z=0\r")
self.read_response()

def single_axis_waveform(
self, axis: str, waveform: int = 0, amplitude: int = 1000, offset: int = 500, period: int = 10
self,
axis: str,
waveform: int = 0,
amplitude: int = 1000,
offset: int = 500,
period: int = 10,
) -> None:
"""Programs the analog waveforms using SAA, SAO, SAP, and SAF
Default waveform is a sawtooth waveform with an amplitude of 1V, an offset of 0.5V and period of 10 ms
Expand All @@ -1059,10 +1179,10 @@ def single_axis_waveform(
"""
print(f"Period (ms): {period}")
# takes amplitude and offset from navigate and modifies them to how the TG-1000 takes them
if (waveform % 128 == 3):
offset = .5*(offset+amplitude)
if waveform % 128 == 3:
offset = 0.5 * (offset + amplitude)

amplitude = amplitude*2
amplitude = amplitude * 2

print("***", waveform, amplitude, axis, offset, period)
# TODO: 3 is the address of the GALVO DAC. May need to make this configurable.
Expand Down
Loading
Loading