From 4c0eb4fdc2f6ada14bd98bdd510e59889945fd59 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Mon, 26 Mar 2012 14:00:36 -0400 Subject: [PATCH] Add Piezo.zero(). --- pypiezo/afm.py | 5 ++--- pypiezo/base.py | 13 +++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/pypiezo/afm.py b/pypiezo/afm.py index a7cb9d5..402ac18 100644 --- a/pypiezo/afm.py +++ b/pypiezo/afm.py @@ -81,9 +81,8 @@ class AFMPiezo (_base.Piezo): We need to know where we are before we can move somewhere smoothly. - >>> pos = _base.convert_volts_to_bits(p.config.select_config( - ... 'axes', 'z', get_attribute=_base.get_axis_name)['channel'], 0) - >>> p.jump('z', pos) + >>> zeros = p.zero(axis_names=['z']) + >>> pos = zeros[0] Usually `.move_to_pos_or_def` is used to approach the surface, but for testing we assume the z output channel is connected directly diff --git a/pypiezo/base.py b/pypiezo/base.py index 6f9eefc..25461c7 100644 --- a/pypiezo/base.py +++ b/pypiezo/base.py @@ -912,3 +912,16 @@ class Piezo (object): for i,name in enumerate(input_names): ret[name] = input_data[:,i] return ret + + def zero(self, axis_names=None, **kwargs): + zeros = [] + if axis_names is None: + axis_names = [axis.name for axis in self.axes] + for axis_name in axis_names: + axis = self.axis_by_name(axis_name) + config = self.config.select_config( + 'axes', axis_name, get_attribute=get_axis_name)['channel'] + zero = convert_volts_to_bits(config, 0) + zeros.append(zero) + self.jump(axis_name, zero) + return zeros -- 2.26.2