The fake Galil can now handle 'MG _LFH' and 'MG _LFR' to get limit switch states.

This commit is contained in:
Ferdi Franceschini
2014-06-10 19:21:51 +10:00
parent cb1652835a
commit 8da11e0ff2

View File

@ -28,6 +28,8 @@ class GalilMotor(object):
self.targetSteps = self.currentSteps self.targetSteps = self.currentSteps
self.configDone = False self.configDone = False
self.switches = 44 self.switches = 44
self.fwdlim = 1
self.revlim = 1
self.stopcode = 0 self.stopcode = 0
self.stopCallback = None self.stopCallback = None
self.moveCallback = None self.moveCallback = None
@ -144,6 +146,8 @@ class GalilMotor(object):
self.motorState = "STOPPED" self.motorState = "STOPPED"
self.stopcode = 1 self.stopcode = 1
self.switches = 44 # stopped, both limits clear self.switches = 44 # stopped, both limits clear
self.fwdlim = 1
self.revlim = 1
elif t >= (t1 + t2): elif t >= (t1 + t2):
# Ramp Down # Ramp Down
dt = t - (t1 + t2) dt = t - (t1 + t2)
@ -173,16 +177,22 @@ class GalilMotor(object):
self.motorState = "STOPPED" self.motorState = "STOPPED"
self.stopcode = 1 self.stopcode = 1
self.switches = 44 # stopped, both limits clear self.switches = 44 # stopped, both limits clear
self.fwdlim = 1
self.revlim = 1
elif self.targetSteps < self.motorStartSteps: elif self.targetSteps < self.motorStartSteps:
self.currentSteps = self.motorStartSteps - int(s) self.currentSteps = self.motorStartSteps - int(s)
if self.currentSteps <= self.targetSteps: if self.currentSteps <= self.targetSteps:
self.motorState = "STOPPED" self.motorState = "STOPPED"
self.stopcode = 1 self.stopcode = 1
self.switches = 44 # stopped, both limits clear self.switches = 44 # stopped, both limits clear
self.fwdlim = 1
self.revlim = 1
else: else:
self.motorState = "STOPPED" self.motorState = "STOPPED"
self.stopcode = 1 self.stopcode = 1
self.switches = 44 # stopped, both limits clear self.switches = 44 # stopped, both limits clear
self.fwdlim = 1
self.revlim = 1
currentPosition = self.getPosition() currentPosition = self.getPosition()
if not self.moveCallback == None: if not self.moveCallback == None:
self.moveCallback(self) self.moveCallback(self)
@ -191,12 +201,16 @@ class GalilMotor(object):
self.motorState = "STOPPED" self.motorState = "STOPPED"
self.stopcode = 2 # stopped by forward limit self.stopcode = 2 # stopped by forward limit
self.switches = 44 - 8 # stopped, reverse limit clear self.switches = 44 - 8 # stopped, reverse limit clear
self.fwdlim = 0
self.revlim = 1
pass pass
if self.targetSteps < self.motorStartSteps and currentPosition <= self.lowerLim: if self.targetSteps < self.motorStartSteps and currentPosition <= self.lowerLim:
# Reverse Limit # Reverse Limit
self.motorState = "STOPPED" self.motorState = "STOPPED"
self.stopcode = 3 # stopped by reverse limit self.stopcode = 3 # stopped by reverse limit
self.switches = 44 - 4 # stopped, forward limit clear self.switches = 44 - 4 # stopped, forward limit clear
self.fwdlim = 1
self.revlim = 0
pass pass
if self.motorState == "STOPPED": if self.motorState == "STOPPED":
print "Axis %s stopped at:" % self.axis, currentPosition print "Axis %s stopped at:" % self.axis, currentPosition
@ -242,6 +256,10 @@ class GalilMotor(object):
response = self.decel response = self.decel
elif arg == "TS": elif arg == "TS":
response = self.switches response = self.switches
elif arg == "LF":
response = self.fwdlim
elif arg == "LR":
response = self.revlim
elif arg == "SC": elif arg == "SC":
response = self.stopcode response = self.stopcode
elif arg == "MO": elif arg == "MO":
@ -283,6 +301,8 @@ class GalilMotor(object):
self.motorState = "STOPPED" self.motorState = "STOPPED"
self.stopcode = 4 self.stopcode = 4
self.switches = 44 self.switches = 44
self.fwdlim = 1
self.revlim = 1
return True return True
def doCommandBG(self, arg): def doCommandBG(self, arg):
@ -290,6 +310,8 @@ class GalilMotor(object):
self.motorState = "MOVING" self.motorState = "MOVING"
self.stopcode = 0 self.stopcode = 0
self.switches = 140 # moving, both limits clear self.switches = 140 # moving, both limits clear
self.fwdlim = 1
self.revlim = 1
self.motorStartTime = time.time() self.motorStartTime = time.time()
self.motorStartSteps = self.currentSteps self.motorStartSteps = self.currentSteps
return True return True