Use stepper.single_step instead of stepper.step_relative in AFM methods.
authorW. Trevor King <wking@drexel.edu>
Fri, 2 Mar 2012 21:22:08 +0000 (16:22 -0500)
committerW. Trevor King <wking@drexel.edu>
Fri, 2 Mar 2012 21:22:08 +0000 (16:22 -0500)
This avoids problems with steppers in full-step mode always rounding
the asked-for half step back to the current position.  The drawback to
the new approach is that we loose backlash protection when moving away
from the surface, but the surface fitting condition ...?

pyafm/afm.py

index fe3da229ec2c0af17df61667c0470a9ad250b1bc..fdacc81a38931aa39f9267608fafd195c22359a6 100644 (file)
@@ -68,7 +68,7 @@ class AFM (object):
 
         Uses `.piezo.get_surface_position()` to pinpoint the position
         of the surface.  Adjusts the stepper position as required via
 
         Uses `.piezo.get_surface_position()` to pinpoint the position
         of the surface.  Adjusts the stepper position as required via
-        `.stepper.step_relative()` to get within
+        `.stepper.single_step()` to get within
         `2*.stepper.step_size` meters of the surface.  Then adjusts
         the piezo to place the cantilever `depth` meters onto the
         surface.  Negative `depth`\s place the tip off the surface
         `2*.stepper.step_size` meters of the surface.  Then adjusts
         the piezo to place the cantilever `depth` meters onto the
         surface.  Negative `depth`\s place the tip off the surface
@@ -115,7 +115,7 @@ class AFM (object):
         _LOG.debug('fine tune the stepper position')
         while pos_m < -stepper_tolerance:  # step back if we need to
             _LOG.debug('step back')
         _LOG.debug('fine tune the stepper position')
         while pos_m < -stepper_tolerance:  # step back if we need to
             _LOG.debug('step back')
-            self.stepper.step_relative(-1, backlash_safe=True)
+            self.stepper.single_step(-1)
             try:
                 pos = self.piezo.get_surface_position(
                     axis_name=self.axis_name, max_deflection=target_def,
             try:
                 pos = self.piezo.get_surface_position(
                     axis_name=self.axis_name, max_deflection=target_def,
@@ -128,7 +128,7 @@ class AFM (object):
                       % (self.stepper.position, pos, pos_m))
         while pos_m > stepper_tolerance:  # step forward if we need to
             _LOG.debug('step forward')
                       % (self.stepper.position, pos, pos_m))
         while pos_m > stepper_tolerance:  # step forward if we need to
             _LOG.debug('step forward')
-            self.stepper.step_relative(1)
+            self.stepper.single_step(1)
             try:
                 pos = self.piezo.get_surface_position(
                     axis_name=self.axis_name, max_deflection=target_def,
             try:
                 pos = self.piezo.get_surface_position(
                     axis_name=self.axis_name, max_deflection=target_def,