From b436bf46238703b246318fbfd19b11943b908d2a Mon Sep 17 00:00:00 2001 From: Raffaele Sommese Date: Mon, 4 Aug 2025 13:18:10 +0200 Subject: [PATCH 1/2] Fix motion mode on star adventurer, add helper function for T1 preset and get status --- synscan/motors.py | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/synscan/motors.py b/synscan/motors.py index 44134ae..23cac50 100644 --- a/synscan/motors.py +++ b/synscan/motors.py @@ -148,7 +148,7 @@ def get_values(self,parameterDict,initDone=True): if initDone: self._send_cmd('F',axis) # Initialize return params - + def get_parameters(self): ''' Get main motor parameters. @@ -264,23 +264,36 @@ def axis_set_motion_mode(self,axis,Tracking,CW=True,fastSpeed=False): if not Tracking: if fastSpeed: speedBit=0 + lowBit = "0" else: speedBit=1 + lowBit = "2" else: if fastSpeed: speedBit=1 + lowBit = "3" else: speedBit=0 + lowBit = "1" if Tracking: value=16 else: value=0 - value=value+speedBit*32+CW + if(CW): + highBit = "0" + else: + highBit = "1" + + + #value=value+speedBit*32+CW + value = int(f"0x{lowBit}{highBit}", 16) #Send as two HEX digits logging.info(f'AXIS{axis}: Setting Motion Mode: {value} HEX:{value:02X}') response=self._send_cmd('G',axis,value,ndigits=2) # SetMotionMode return response - + def set_T1_preset(self,axis,value): + return self._set_T1_preset(axis,value) + def _set_T1_preset(self,axis,value): '''Set step period for tracking speed''' if not self.params[axis]['countsPerRevolution']: @@ -294,7 +307,7 @@ def axis_get_posCounts(self,axis): #Position values are offseting by 0x800000 response=self._send_cmd('j',axis)-0x800000 # GetAxisPosition return response - + def axis_set_goto_targetCounts(self,axis,targetCounts): '''GoTo Target value in StepsCounts. Motors has to be stopped''' if not self.params[axis]['countsPerRevolution']: @@ -360,7 +373,7 @@ def axis_goto(self,axis,targetDegrees): if self.params[axis]['countsPerRevolution']: self.axis_stop_motion(axis) actualPos=self.axis_get_pos(axis) - self.axis_set_motion_mode(axis,False,(targetDegrees Date: Mon, 29 Dec 2025 10:24:34 +0100 Subject: [PATCH 2/2] new serial connect --- synscan/comm.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/synscan/comm.py b/synscan/comm.py index ba28538..c64d37c 100644 --- a/synscan/comm.py +++ b/synscan/comm.py @@ -55,15 +55,16 @@ class commSerial: def __init__(self,serial_dev): import serial ''' Init the serial port ''' - self.serial = serial.Serial(serial_dev, 9600, timeout=.02) + self.serial = serial.Serial(serial_dev, 115200, timeout=.5) self.lock = threading.Lock() self.commOK=False def cmd(self,cmd,timeout_in_seconds=2): '''Low level send command function ''' with self.lock: + self.serial.reset_input_buffer() self.serial.write(cmd) - response = self.serial.readline() + response = self.serial.read_until(b'\r') while response and response[0] not in b'!=': # Strip echo of command response = response[1:]