Skip to content

Commit e493c14

Browse files
Axis from config
1 parent 43ea873 commit e493c14

File tree

2 files changed

+52
-20
lines changed

2 files changed

+52
-20
lines changed

src/navigate/model/devices/APIs/asi/asi_tiger_controller.py

Lines changed: 50 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,7 +1078,7 @@ def SAM(self, axis: str, mode: int):
10781078
self.send_command(f"3 SAM {axis}={mode}")
10791079
self.read_response()
10801080

1081-
def setup_control_loop(self,delays,camera_delay,rfvc_delay,sweep_time : float, analog_outputs): # delay (ms), sweep_time (ms)
1081+
def setup_control_loop(self,delays,camera_delay,rfvc_delay,sweep_time : float, analog_outputs : dict): # delay (ms), sweep_time (ms)
10821082
# def setup_control_loop(self, analog_outputs: dict):
10831083
"""
10841084
Sets up the control loop
@@ -1089,13 +1089,22 @@ def setup_control_loop(self,delays,camera_delay,rfvc_delay,sweep_time : float, a
10891089
10901090
"""
10911091
# channels = analog_outputs.keys()
1092+
TTLs = {'A': 42, 'B': 44, 'C': 46}
10921093
# if channels:
10931094
start_delay = int(delays[0]*4) #- int(round(period))
10941095
if len(delays) > 1:
10951096
galvo2_delay = int((delays[0] - delays[1])*4)
1097+
galvo1_axis = analog_outputs["galvo 1"]
1098+
galvo2_axis = analog_outputs["galvo 2"]
1099+
elif len(delays) == 1:
1100+
galvo1_axis = analog_outputs["galvo 1"]
1101+
galvo2_delay = 0
10961102
else:
10971103
galvo2_delay = 0
1098-
1104+
rfvc_axis = analog_outputs["remote_focus"]
1105+
1106+
1107+
10991108
sweep_time = int(sweep_time*4) - 2
11001109

11011110
if rfvc_delay > camera_delay + 2:
@@ -1185,37 +1194,60 @@ def setup_control_loop(self,delays,camera_delay,rfvc_delay,sweep_time : float, a
11851194
'ccb x = 11',
11861195
'ccb y = 192',
11871196
#Sets TTL2 to output from the RFVC cell in this case , For I am the LORD
1188-
'6 m e = 43',
1197+
f'6 m e = {TTLs[rfvc_axis]+1}',
11891198
'6 cca y = 1',
11901199
f'6 cca z = {rfvc_output}',
11911200
#Sets TTL1 to output the same thing as TTL0, For I am the LORD
1192-
'6 m e = 42',
1201+
f'6 m e = {TTLs[rfvc_axis]}',
11931202
'6 cca y = 1',
1194-
'6 cca z = 43',
1203+
f'6 cca z = {TTLs[rfvc_axis]+1}',
1204+
#Sets PLC output 3 to cell 6
1205+
'6 m e = 33',
1206+
f'6 cca z = {camera_output}',
1207+
]
1208+
# if galvos exist
1209+
galvo_commands = []
1210+
if len(delays) > 0:
1211+
galvo_commands = [
11951212
#Sets TTL4 to output for the first Galvo, For I am the LORD
1196-
'6 m e = 45',
1213+
f'6 m e = {TTLs[galvo1_axis]+1}',
11971214
'6 cca y = 1',
11981215
'6 cca z = 2',
11991216
#Sets TTL3 to output the same thing as TTL2
1200-
'6 m e = 44',
1217+
f'6 m e = {TTLs[galvo1_axis]}',
12011218
'cca y = 1',
1202-
'cca z = 45',
1203-
#Sets TTL6 to output for the second Galvo
1204-
'6 m e = 47',
1219+
f'cca z = {TTLs[galvo1_axis]+1}',
1220+
]
1221+
1222+
if len(delays) > 1:
1223+
galvo_commands = [
1224+
#Sets TTL4 to output for the first Galvo, For I am the LORD
1225+
f'6 m e = {TTLs[galvo1_axis]+1}',
1226+
'6 cca y = 1',
1227+
'6 cca z = 2',
1228+
#Sets TTL3 to output the same thing as TTL2
1229+
f'6 m e = {TTLs[galvo1_axis]}',
12051230
'cca y = 1',
1206-
'cca z = 10',
1207-
#Sets TTL5 to output the same thing as TTL4
1208-
'6 m e = 46',
1231+
f'cca z = {TTLs[galvo1_axis]+1}',
1232+
#Sets TTL4 to output for the first Galvo, For I am the LORD
1233+
f'6 m e = {TTLs[galvo2_axis]+1}',
1234+
'6 cca y = 1',
1235+
'6 cca z = 2',
1236+
#Sets TTL3 to output the same thing as TTL2
1237+
f'6 m e = {TTLs[galvo2_axis]}',
12091238
'cca y = 1',
1210-
'cca z = 47',
1211-
#Sets PLC output 3 to cell 6
1212-
'6 m e = 33',
1213-
f'6 cca z = {camera_output}',
1214-
]
1239+
f'cca z = {TTLs[galvo2_axis]+1}',
1240+
]
1241+
print(galvo_commands)
1242+
1243+
12151244
for command in commands:
12161245
# Send data
12171246
self.send_command(f'{command}\r')
12181247
self.read_response()
1248+
for command in galvo_commands:
1249+
self.send_command(f'{command}\r')
1250+
self.read_response()
12191251

12201252
def tweak_control_loop(self, delays, sweep_time):
12211253

src/navigate/model/devices/daq/asi.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def __init__(self, microscope_name, device_connection, configuration: Dict[str,
112112
# update analog outputs with galvo numbers and associated axes
113113
i=0
114114
for g in self.galvos:
115-
self.analog_outputs.update({f"galvo {i}":g['hardware']['axis']})
115+
self.analog_outputs[f"galvo {i}"] = g['hardware']['axis']
116116
i += 1
117117

118118
# retreive galvo phases from config
@@ -122,7 +122,7 @@ def __init__(self, microscope_name, device_connection, configuration: Dict[str,
122122
print(self.phases)
123123
# update analog outputs with rfvc and associated axis
124124
remote_focus_channel = self.configuration["configuration"]["microscopes"][self.microscope_name]["remote_focus"]["hardware"]["axis"]
125-
self.analog_outputs.update({"remote_focus":remote_focus_channel})
125+
self.analog_outputs["remote_focus"] = remote_focus_channel
126126
# sets up initial PLC configuration with default delay (ms), sweep time (ms), and analog outputs dict
127127
self.daq.setup_control_loop([200], 0, 0, 120, self.analog_outputs)
128128

0 commit comments

Comments
 (0)