From 34c56ef4d2c1e14110f744937149ea6147029513 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 7 Feb 2013 01:13:42 -0500 Subject: [PATCH] scan: Add stepper_tweaks (--no-stepper-tweaks) to UnfoldScanner.run() This is useful if you're not around to monitor a long run. If the laser is disrupted (e.g. via a bubble in the fluid cell), the photodiode voltage can flatlign, even if you aren't off the surface. A confused UnfoldScanner with *think* it's off the surface, and charge blindly in, crushing the cantilever into itsy bits ;). Laser disruption detection is a great reason to measure the total photodiode voltage. Unfortunately, that signal is not carried on the cable between the MultiMode and the NanoScope. I tried jumping it out of the MultiMode by hand, but after a few weeks like that, the board died. I'm not sure it was related, but I think it's safer to just disable stepper tweaks when you're not around to monitor the signal. --- unfold.py | 7 ++++++- unfold_protein/scan.py | 14 ++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/unfold.py b/unfold.py index 951ad33..142aea0 100755 --- a/unfold.py +++ b/unfold.py @@ -40,6 +40,11 @@ if __name__ == '__main__': parser.add_argument( '-s', '--song', help='Path to a song to play when the experiment is complete') + parser.add_argument( + '-S', '--no-stepper-tweaks', dest='stepper_tweaks', + action='store_const', const=False, default=True, + help=("Don't move the stepper except for the initial approach " + "and final retraction")) args = parser.parse_args() @@ -61,7 +66,7 @@ if __name__ == '__main__': afm.piezo.zero() unfolder = Unfolder(config=unfold_config, afm=afm) scanner = UnfoldScanner(config=scan_config, unfolder=unfolder) - scanner.run() + scanner.run(stepper_tweaks=args.stepper_tweaks) finally: afm.move_away_from_surface() afm.piezo.zero() diff --git a/unfold_protein/scan.py b/unfold_protein/scan.py index e511dfd..40fe80f 100644 --- a/unfold_protein/scan.py +++ b/unfold_protein/scan.py @@ -31,7 +31,7 @@ class UnfoldScanner (object): self.unfolder = unfolder self._state = {'x direction': 1} - def run(self): + def run(self, stepper_tweaks=True): self._stop = False _signal.signal(_signal.SIGTERM, self._handle_stop_signal) self.unfolder.afm.move_away_from_surface() @@ -46,10 +46,16 @@ class UnfoldScanner (object): try: self.unfolder.run() except _ExceptionTooFar: - self.stepper_approach() + if stepper_tweaks: + self.stepper_approach() + else: + raise except _ExceptionTooClose: - self.afm.move_far_from_surface() - self.stepper_approach() + if stepper_tweaks: + self.afm.move_away_from_surface() + self.stepper_approach() + else: + raise else: self.position_scan_step() -- 2.26.2