Control bump_speed instead of bump sample frequency.
[calibcant.git] / calibcant / calibrate.py
old mode 100644 (file)
new mode 100755 (executable)
index 2cfff35..f78520f
@@ -1,4 +1,27 @@
 #!/usr/bin/python
+#
+# calibcant - tools for thermally calibrating AFM cantilevers
+#
+# Copyright (C) 2007,2008, William Trevor King
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+#
+# The author may be contacted at <wking@drexel.edu> on the Internet, or
+# write to Trevor King, Drexel University, Physics Dept., 3141 Chestnut St.,
+# Philadelphia PA 19104, USA.
 
 """
 Aquire and analyze cantilever calibration data.
@@ -96,17 +119,19 @@ import analyze
 # bump family
 
 @splittableKwargsFunction()
-def bump_aquire(zpiezo, push_depth=200, npoints=1024, freq=100e3) :
+def bump_aquire(zpiezo, push_depth=200, npoints=1024, push_speed=1000) :
     """
     Ramps closer push_depth and returns to the original position.
     Inputs:
      zpiezo     an opened zpiezo.zpiezo instance
      push_depth distance to approach, in nm
      npoints    number points during the approach and during the retreat
-     freq       rate at which data is aquired
+     push_speed piezo speed during approach and retreat, in nm/s
     Returns the aquired ramp data dictionary, with data in DAC/ADC bits.
     """
     # generate the bump output
+    nm_per_step = float(push_depth) / npoints
+    freq = push_speed / nm_per_step # freq is sample frequency in Hz
     start_pos = zpiezo.curPos()
     pos_dist = zpiezo.pos_nm2out(push_depth) - zpiezo.pos_nm2out(0)
     close_pos = start_pos + pos_dist
@@ -115,7 +140,7 @@ def bump_aquire(zpiezo, push_depth=200, npoints=1024, freq=100e3) :
     out = numpy.concatenate((appr, retr))
     # run the bump, and measure deflection
     if config.TEXT_VERBOSE :
-        print "Bump %g nm" % push_depth
+        print "Bump %g nm at %g nm/s" % (push_depth, push_speed)
     data = zpiezo.ramp(out, freq)
     return data