Fix move_just_onto_surface() for limited axes.
authorW. Trevor King <wking@drexel.edu>
Fri, 16 Mar 2012 04:48:17 +0000 (00:48 -0400)
committerW. Trevor King <wking@drexel.edu>
Fri, 16 Mar 2012 04:48:20 +0000 (00:48 -0400)
If the channel is limited with AxesConfig['maximum'] less than the
channels actual maximum, the position passed in to
move_just_onto_surface() may be a floating point bit value
(e.g. 62258.25).  Because the maximum keeps the position from getting
to 62259, the approach phase goes on forever, getting stuck in
repeated jumps to 62258.  By truncating the positive position down to
a lower integer, we ensure that it is an attainable value.

pypiezo/afm.py

index 02c2063d0ff50227d944d2c595824ce3191600d9..5cf5569365f29cf3c7e239ee64c7820ef6826943 100644 (file)
@@ -191,6 +191,7 @@ class AFMPiezo (_base.Piezo):
             # default to the extreme value
             channel = self._deflection_channel(self)
             deflection = channel.get_maxdata()
+        position = int(position)  # round down to nearest integer
 
         if step == 0:
             raise ValueError('must have non-zero step size')