Skip to content

Code organization

Rob Campbell edited this page Jul 4, 2017 · 5 revisions

An understanding of the classes that handle motion of the stage, PIFOC, and vibrotome are only necessary for users who wish to modify the code.

The system uses five linear motion devices:

  • x and y stages for tile scanning and cutting.
  • a linear actuator for vertical motion of the x and y stages before cutting.
  • a PIFOC for rapid imaging of multiple optical sections in one physical section.
  • an coarse objective z-stage for positioning the imaging plane at the cutting plane

The design principle of Baking Tray is that each hardware item is associated with an abstract class. Hardware are grouped in reasonable ways using classes. e.g.

  • Each physical device that provides linear motion is represented by an abstract linearstage class.
  • Each physical control device for each actuator or stage is represented by an abstract linearcontroller. One more linearstages can be attached to each linearcontroller.
  • The BT class brings together the above and also controls ScanImage.

Baking tray will not incorporate more detailed aspects of the process, such as generation of the tile scan pattern, error detection, etc.

You must set up your concrete classes so that the following conventions are maintained: a) The linear actuator that handles the stage jack is at zero when fully lowered. Upwards locations correspon to posititive numbers. b) The X and Y stages are zero when at the mid-point of their travel ranges. c) -x is left and +x is right. d) -y is towards you and +y is away from you.

An abstract linearstage class declares the methods and properties used to control an abstract linear motion device. The linearstage class can not be instantiated. Methods are defined in concrete classes (which can be instantiated) that inherit linearstage. Whilst it is not necessary for MATLAB classes to be designed this way, the linearstage class serves as a useful starting point for users wishing to write new concrete classes to control custom hardware. To aid this, linearstage contains extensive comments describing the assumed behavior of each abstract method it declares.

The linearstage is mainly in charge of defining the physical properties of the motion. e.g.

  • The ID of the stage
  • Stores the current position
  • The position units
  • The acceleration
  • Target speed
  • Range of motion (hard and soft limits)

Each linearstage is controlled by a linearcontroller abstract class with which it is associated. This enables users mix and match controller and stage pairs. It also allows a single controller to handle more than one stage in cases where this is possible.

The linearcontroller creates a consistent interface between the controller API (e.g. the manufacturer-specific motion commands) and Baking Tray. Thus the linearcontroller has methods that do the following:

  • goToRelativePosition
  • goToAbsolutePosition
  • goToZero
  • referenceStage (if needed)

Of course the linearcontroller must perform these actions on some physical device. It performs these actions on one or more linearstage stage objects with which it is associated. The linearcontroller contains an attachedStage property. To this we attach one stage object. Say a single physical controller handles both the X an Y stages. We would attach it twice: BT.xAxis and BT.yAxis. Each will have a different stage. The author of the linearcontroller for this stage type is responsible for having the controller read which stage it's attacned to and send the correct command out.

Clone this wiki locally