@@ -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
0 commit comments