From: W. Trevor King Date: Mon, 26 Mar 2012 18:00:36 +0000 (-0400) Subject: Add Piezo.zero(). X-Git-Tag: 0.7~11 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=4c0eb4fdc2f6ada14bd98bdd510e59889945fd59;p=pypiezo.git Add Piezo.zero(). --- 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