Commit 66ba3334 authored by Matias Guijarro's avatar Matias Guijarro
Browse files

axis: introduce steps_position_precision to motor controllers, and use it to...

axis: introduce steps_position_precision to motor controllers, and use it to determine delta in _get_motion
parent 54e0e626
......@@ -1329,13 +1329,10 @@ class Axis:
def _get_motion(self, user_target_pos):
dial_target_pos = self.user2dial(user_target_pos)
delta = dial_target_pos - self.dial
if abs(delta) < 1e-6:
delta = 0.0
# check software limits
target_pos = dial_target_pos * self.steps_per_unit
delta *= self.steps_per_unit
delta = target_pos - self.dial * self.steps_per_unit
if abs(delta) < self.controller.steps_position_precision(self):
delta = 0.0
backlash = self.backlash / self.sign * self.steps_per_unit
backlash_str = " (with %f backlash)" % self.backlash if backlash else ""
low_limit_msg = "%s: move to `%f'%s would exceed low limit (%f)"
......@@ -1344,13 +1341,14 @@ class Axis:
low_limit = self.user2dial(user_low_limit) * self.steps_per_unit
high_limit = self.user2dial(user_high_limit) * self.steps_per_unit
# check software limits
if high_limit < low_limit:
high_limit, low_limit = low_limit, high_limit
user_high_limit, user_low_limit = user_low_limit, user_high_limit
high_limit_msg, low_limit_msg = low_limit_msg, high_limit_msg
if backlash:
if abs(delta) > 1e-6 and math.copysign(delta, backlash) != delta:
if abs(delta) > 0 and math.copysign(delta, backlash) != delta:
# move and backlash are not in the same direction;
# apply backlash correction, the move will happen
# in 2 steps
......
......@@ -114,6 +114,16 @@ class Controller:
def config(self):
return self.__config
def steps_position_precision(self, axis):
"""
Return a float value representing the precision of the position in steps
* 1e-6 is the default value: it means the motor can deal with floating point
steps up to 6 digits
* 1 means the motor controller can only deal with an integer number of steps
"""
return 1e-6
def check_limits(self, *axis_positions):
"""
check limits for list of axis and positions
......
......@@ -115,6 +115,9 @@ class Icepap(Controller):
if hasattr(axis, "_init_hardware"):
axis._init_hardware()
def steps_position_precision(self, axis):
return 1
# Axis power management
def set_on(self, axis):
"""
......
......@@ -73,6 +73,10 @@ class Mockup(Controller):
self.axis_settings.add("init_count", int)
self.axis_settings.add("hw_position", float)
def steps_position_precision(self, axis):
"""Mockup is really a stepper motor controller"""
return 1
def read_hw_position(self, axis):
return axis.settings.get("hw_position")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment