> For the complete documentation index, see [llms.txt](https://bakingtray.swcmicroscopy.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bakingtray.swcmicroscopy.com/getting-started/hardware-setup/motor-setup/verifying_stage_operation.md).

# Verifying stage motions

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.

## Preparation

* 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.

{% hint style="info" %}
Serial connections have lower latency than USB-serial. Use them where possible.
{% endhint %}

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

## 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 aren'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](/getting-started/hardware-setup/motor-setup/pi-stage-setup.md).

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](/getting-started/hardware-setup/motor-setup/calibrating_actuator_mm.md).

{% hint style="warning" %}
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.
{% endhint %}

### 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](https://github.com/SWC-Advanced-Microscopy/BakingTray/tree/master/code/components/motion). If your device is not currently supported, you can find information on writing a control class [here](/general/developers/motion-control-classes.md).

```
>> 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);
```

## Note!

You should ensure the stages can't produce out of bounds motions. This can be achieved using the BakingTray settings file, since maximum and minimum positions can be defined here. With PI stages it is also possible to define soft limits for the motions in PI MikroMove if you wish, but this is not necessary.

The mid-point of the Y stage motion (0 mm) should place the sample centered on the blade (although there is a BakingTray setting that allows this to be tweaked later, if you could not achieve this). The mid-point of the X stage motion (0 mm) should place the white frosted part of the slide under the objective.
