def home(self): ''' Puts the motor to backward limit position, so that the position markers make sense ''' ### global Home_Counter Home_Counter += 1 ### self.moving = True self.logger.debug('Homing...', extra=self.ext) # save that change with < MGMSG_MOT_SET_EEPROMPARAMS > self.ser.write(hexString('B9 04 04 00 D0 01')) self.ser.write(hexString('01 00')) # chanel id self.ser.write( hexString('FE 04')) # the specific message we want to save # call < MGMSG_MOT_SET_TSTACTUATORTYPE > first # to specify that we are using the ZFS 13mm actuator => 0x41 # FE, 04, 41, 00, 50, 01 self.ser.write(hexString('FE 04 41 00 50 01')) # home motor on the correct limit switch # < MGMSG_MOT_REQ_HOMEPARAMS > self.ser.write(hexString('41 04 01 00 50 01')) home_response = self.ser.read(20) if home_response[0:2] != hexString('42 04'): self.logger.error( 'problem reading data from controller while homing', extra=self.ext) exit() # < MGMSG_MOT_SET_HOMEPARAMS > self.ser.write(hexString('40 04 0E 00 D0 01')) # header self.ser.write(hexString('01 00')) # chan-ident self.ser.write(int2hexStr(1, 2)) # Home Dir self.ser.write(int2hexStr(1, 2)) # Limit Switch self.ser.write(home_response[12:16]) # Home Velocity self.ser.write(home_response[16:20]) # Offset Distance # MGMSG_MOT_MOVE_HOME self.ser.write(hexString('43 04 01 00 50 01')) self.ser.reset_input_buffer() response = self.ser.read(6) if response != hexString('44 04 01 00 01 50'): # MGMSG_MOT_MOVE_HOMED self.logger.error('problem homing', extra=self.ext) exit() self.logger.info('homed successfully.', extra=self.ext) self.moving = False
def home(self): ''' Puts the motor to backward limit position, so that the position markers make sense ''' # NOTE: Might need to call < MGMSG_MOT_SET_TSTACTUATORTYPE > first self.moving = True # MGMSG_MOT_MOVE_HOME self.ser.write(hexString('43 04 01 00 50 01')) self.ser.reset_input_buffer() response = self.ser.read(6) if response != hexString('44 04 01 00 01 50'): # MGMSG_MOT_MOVE_HOMED self.logger.error('problem homing', extra=self.ext) exit() self.logger.info('homed successfully.', extra=self.ext) self.moving = False
def get_info(self): ''' Get information back form the controller Used for debugging purposes ''' # MGMSG_HW_REQ_INFO self.ser.write(hexString('05 00 00 00 50 01')) response = self.ser.read(90) print response
def _set_backlash(self, backlash_distance): ''' Set the backlash correction distance for backwards motor movement backlash_distance (int): in encoder steps ''' # change backlash value self.ser.write(hexString('3A 04 06 00 D0 01')) # header self.ser.write(hexString('01 00')) # chanel id self.ser.write(int2hexStr(backlash_distance, 4)) # backlash dist # request backlash data self.ser.write(hexString('3B 04 01 00 50 01')) # confirm backlash distance value res = self.ser.read(12) back_dist_r = unpack('<l', res[8:12])[0] if back_dist_r != backlash_distance: self.logger.error('Problem setting backlash distance [{}]'.format( backlash_distance), extra=self.ext)