Implement a turn counter for wrap-around rotary encoders
This commit is contained in:
@@ -32,6 +32,7 @@ class GalilMotor(object):
|
||||
self.stopCallback = None
|
||||
self.moveCallback = None
|
||||
self.trace = False
|
||||
self.rotary_bits = 0
|
||||
|
||||
def doTrace(self, arg):
|
||||
print "Trace %s: %s" % (self.axis, arg),
|
||||
@@ -80,6 +81,9 @@ class GalilMotor(object):
|
||||
elif lh == "NAM":
|
||||
self.name = rh[1:-1]
|
||||
self.configDone = True
|
||||
elif lh == "ROT":
|
||||
self.rotary_bits = int(rh)
|
||||
self.configDone = True
|
||||
else:
|
||||
print "Unrecognized config item \"%s\" in \"%s\"" % (lh, arg)
|
||||
if self.configDone and not configDoneAlready:
|
||||
@@ -228,6 +232,8 @@ class GalilMotor(object):
|
||||
response = self.getPosition()
|
||||
elif arg == "TP":
|
||||
response = self.getEncoder()
|
||||
if self.rotary_bits > 0:
|
||||
response = response & ((1 << self.rotary_bits) - 1)
|
||||
elif arg == "SP":
|
||||
response = self.speed
|
||||
elif arg == "AC":
|
||||
|
||||
Reference in New Issue
Block a user