scan: Add stepper_tweaks (--no-stepper-tweaks) to UnfoldScanner.run()
authorW. Trevor King <wking@tremily.us>
Thu, 7 Feb 2013 06:13:42 +0000 (01:13 -0500)
committerW. Trevor King <wking@tremily.us>
Thu, 7 Feb 2013 06:18:55 +0000 (01:18 -0500)
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
unfold_protein/scan.py

index 951ad336683084b41779a2602297cd1a622b2698..142aea09192f8e96b19d2a7be3a313859718183c 100755 (executable)
--- 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()
index e511dfd48f42dc7c8a5c0b17664cec0b8efaec3f..40fe80f759bfe24660434e617e43f8a8b3e65519 100644 (file)
@@ -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()