Skip to content
Open
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
5 changes: 3 additions & 2 deletions synscan/comm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:]
Expand Down
28 changes: 22 additions & 6 deletions synscan/motors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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']:
Expand All @@ -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']:
Expand Down Expand Up @@ -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<actualPos),True)
self.axis_set_motion_mode(axis,False,(targetDegrees<actualPos),False)
self.axis_set_goto_target(axis,targetDegrees)
self.axis_start_motion(axis)

Expand Down Expand Up @@ -495,7 +508,10 @@ def track(self,alpha,beta):
self.axis_track(1,alpha)
if self.params[2]['countsPerRevolution']:
self.axis_track(2,beta)


def get_status(self, axis):
return self._decode_status(self.get_values({'Status':'f'})[1]['Status'])

def update_current_values(self,logaxis=2):
'''Update current status and values
logaxis can be 1,2,3 or None. 1 for only log current values of axis 1...
Expand Down