Verifying hardware operation

Ensuring hardware is functioning correctly

At this point you should have an acquisition PC with MATLAB, ScanImage, and BakingTray installed in your MATLAB path. Your scanning acquisition hardware should be set up and running. You will now ensure that the hardware related to serial sectioning is functioning correctly and that BakingTray can talk to it.


  • Ensure your stages are plugged in, switched on, and the drivers are installed.

  • Ensure the laser is connected to the PC via a serial cable (ideally) or USB-serial.

Serial connections have lower latency than USB-serial. Use them where possible.

  • As you proceed with the steps below, make a note of which classes you used and the settings required.


BakingTray communicates with the laser in order to stop acquisition should it drop out of modelock. Available laser control classes are in the components/laser directory. Let us say you have a Chameleon laser and it is connected to your motherboard serial port, COM1. The following sample session confirms we can connect to the laser and demonstrates some features of the laser control class.

>> c=chameleon('COM1');

Setting up Chameleon laser communication on serial port COM1
Connected to Chameleon laser on serial port COM1

>> [~,status]=c.isReady
status =
    'Laser not powered on'
% So let's turn on the laser with the key switch...

% Test if laser shutter is open (0 means it's closed, 1 means it's open)
>> c.isShutterOpen
ans =
>> c.openShutter; % Let's open the shutter
>> c.isShutterOpen
ans =
% Yep, shutter is now open

% Let's read and then change the wavelength
>> c.readWavelength
ans =

>> c.setWavelength(940);
>> c.readWavelength
Failed to read wavelength from Chameleon. Likely laser is tuning.
ans =

% Wait 5 seconds...
>> c.readWavelength
ans =
% Nice

% Close communications with the laser
>> delete(c)
Disconnecting from Chameleon laser
Closing serial communications with Chameleon laser


Most vibratomes consist of a DC motor that turns a cam which produces lateral motion of an assembly that in turns holds the blade. The vibratome should be securely bolted in place. Attach the blade holder to the vibratome as you would for normal operation.

It is possible vibratome motor far harder than the manufacturer intended. Start at slow speeds and be sure you know how to cut power to the device if you need to.

You will now ensure you can set the vibratome to run at a specified speed and also stop the vibratome. The following sample session demonstrates this with the Faulhaber MCDC motor controller, with which we interface via a serial connection.

>> f=FaulhaberMCDC('COM2');
Setting up Faulhaber MCDC3006 DC motor controller.
Motor max speed: 60 revs per second.

%Let's start a gentle vibration
>> f.startVibrate(5); % You should now see a modest vibration of the blade
>> f.stopVibrate;  % And we stop it

You should consider the sample speed setting, which is the input argument to startVibrate, to be in arbitrary units. The goal now is to identify a reasonable speed setting for slicing the sample.

% Try a range of speeds and stop once it becomes more noisy
>> f.startVibrate(10); % quiet
>> f.startVibrate(11); % quiet
>> f.startVibrate(12); % still quiet
>> f.startVibrate(13); % Getting loud: vibrations are clearly audible
>> f.startVibrate(10); % <--- Back off a few steps. Make a note of this setting.
>> f.stopVibrate;

% Terminate the session
>> delete(f)
Closing connection to Faulhaber MCDC motor controller

If you run the vibratome too fast you will wear our the axel or the bearings and may need to replace the whole unit after a year or two. Make a note of the vibrate speed chosen above. You will later use this to slice samples and only modify if it if you notice cutting problems.

The Leica VT1000 works well with a Faulhaber MCDC3006. The motor has a red and black lead that goes to the motor + and - connections on the ccontroller. The encoder has four connections. The red cable goes to sensor Ucc on the controller. Black to sensor ground. The brown cable is channel B and white is channel A.

Note that BakingTray can also run devices such as the Leica VT1200 (the unit used by Economo et al) by gating its operation with a TTL pulse via the JaneliaLeicaContoller class.

The X/Y/Z Stages

The X/Y sample stages translate the sample during a tile scan and drive the sample into the blade during cutting. The Z stage (Z-jack) moves the sample up and down for cutting. Ensure that the stages and hardware isn't in a configuration where unintended motions could result in damage. Use motion control software supplied by the manufacturer to confirm the stages move as expected: that you can make large and small motions, change speed, etc.

If you are using PI stages, see the detailed instructions for setting them up.

Most devices, such as those sold by Aerotech, PI, or ThorLabs, will allow you to issue motion commands in mm. However, you may have a motor controller that is not calibrated and works on motor "ticks" that will move the device by a small fixed distance. The Z-jack on the TissueCyte 1000 is one such device. If this is the case, follow the actuator calibration steps.

The stage driving the Z-jack must move down to the lower limit switch when homing. BakingTray expects the home position to be z=0 mm.

Ensuring BakingTray can move the stage

Now you will ensure that BakingTray is able to interact with the stage. Close the manufacturer's control software before proceeding. The following example will connect to a PI stage via a PI C891 controller. If you have a different device you can find the name of the class which controls it here. If your device is not currently supported, you can find information on writing a control class here.

>> STAGE = genericPIstage;
>> STAGE.axisName='someName'; %Does not matter for this toy example
>> PIC891 = C891(STAGE); %Create  control class
>> controllerID.interface='usb'; %We will connect via USB...
>> controllerID.ID= '116010269'; %Using the serial number of the C891

Now we are ready to communicate with the device and connect to it:

>> PIC891.connect(controllerID)
Loading PI_MATLAB_Driver_GCS2 ...
PI_MATLAB_Driver_GCS2 loaded successfully.
Attempting to connect to C-891 with serial number 116010269

If you saw no errors, you can now do stuff like move the stage:

>> PIC891.absoluteMove(0);
>> PIC891.absoluteMove(10);
>> PIC891.relativeMove(-3);

Last updated