Xeryon Matlab

Controlling our stages in Matlab is very easy thanks to our Matlab library. This library handles all of the communication between the computer and the controller. It also provides simple functions to control different stages. The library is compact and easy to use.

In this guide we will explain the basic functions of the library. All the code used in this guide is available with the library and can be downloaded here: https://xeryon.com/downloads/

A quick note before starting: Matlab here makes use of our python library, so you will have to install Python together with the package “pyserial”. But don’t worry, it’s very easy to use.

Setup

Initialisation

The first step is to initialize the system and import the library:

library = py.importlib.import_module('Xeryon'); % Import Library
controller = library.Xeryon("COM16", 115200); % Setup serial communication (COM-port, baudrate)
axisX = controller.addAxis(library.Stage.XLS_312, "X");  % Add correct stage
To add more stages, just add a new line:
axisY = controller.addAxis(library.Stage.XRTU_109, "Y");  % Add correct stage

If you type “library.Stage.” you can use autocomplete to see which stages are available to choose from.

You can also change the working units of the library, default it’s set to mm.

axisX.setUnits(library.Units.mm)

System Startup

The second step is to start the system. This command initiates the communication between the computer and the controller and configures the correct settings.

controller.start()

Find index

The last step of the setup is finding the index for each axis which is an obligatory step. Finding the index makes sure that the encoder knows at which position it is located. Without finding the index, the stage won’t know it’s absolute position.

axisX.findIndex()

Basic Control

It is really easy to control the system. If you want to move an axis to a specific position (= the desired position ‘DPOS’) just type the following and the stage will start moving:

axisX.setDPOS(5)

But what does “position 10” mean? All the positions and speeds in this library are expressed in the “current selected units”. By default, these units are in mm. So setDPOS(10) moves the stage to position “10 mm from the index point”.

But what does “position 10” mean? All the positions and speeds in this library are expressed in the “current selected units”. By default, these units are in mm. So setDPOS(10) moves the stage to position “10 mm from the index point”.

Changing the units is very easy, just type:

axisX.setUnits(library.Units.mu)

This changes the units to micrometers. Notice that the units are specific for each axis.
By running the following command, the stage will position itself to -5 micrometer.

axisX.setDPOS(-5)
The controller sends feedback back to the computer. It can, for example, send the encoder position “EPOS”. The library reads incoming data and converts it into the current units. This all happens in the background. To read this data, just type:
axisX.getDPOS()
axisX.getEPOS()
The library also provides the function: step( value ). The name explains itself, it steps a certain amount of units. This function also just works with the current units, so in this case it will be micrometers. By running the code below, the stage will first do a step of 5 mu and followed by a step of -10 mu.
axisX.step(5)
axisX.step(-10)

Speed control

Controlling the speed is very easy:

axisX.setSpeed(10)
This command will set the speed for this stage to 10 mu/s. Notice that the given value is always expressed in the current units. If you want to change the current units to mm and set the speed of the stage to 10 mm/s, use the following command:
axisX.setUnits(library.Units.mm)
axisX.setSpeed(10)

Scanning

Scanning is continuously moving with a fixed speed. You can start scanning by entering the line below. “-1” stands for the negative encoder direction.

axisX.startScan(-1)

It’s also possible to scan for a certain amount of seconds. In the command below, the stage will scan for 3 seconds in the negative direction.

axisX.startScan(-1,3)

Controller feedback

The controller gives a lot of feedback. All this data is processed in the background, and always accessible. For example, the controller always sends a status (“STAT”) back. The definition of these status bits are explained in our “Connection manual”.

All the status bits are simple Boolean functions in our library:

axisX.isForceZero()
axisX.isMotorOn()
axisX.isClosedLoop()
axisX.isEncoderAtIndex()
axisX.isEncoderValid()
axisX.isSearchingIndex()
axisX.isPositionReached()
axisX.isEncoderError()
axisX.isScanning()
axisX.isAtLeftEnd()
axisX.isAtRightEnd()
axisX.isErrorLimit()
axisX.isSearchingOptimalFrequency()
A big advantage of using Matlab is the easy with which you can capture and process data. We’ve build in a “logging” function, which stores all data that’s received in a list.
axisX.startLogging()
axisX.endLogging()

The function endLogging() returns all the collected data.

Stopping

To close the program, run the controller.stop() command. This will reset the stage to it’s home position and shut down the communication.

An overview of the most used functions:

Class Xeryon:

start()
Start the communication, read the settings file and send the settings to the controller.
stop()
Move all the stages to their home position and close the communication.
reset()
Move all the stages to their home position and resend the settings.
getAllAxis()
Return al list containing all the axis objects.

Class Axis:

findIndex()
Find the index of the stage..
setDPOS( value )
Set the desired position to a specific value.
getDPOS()
Return the current DPOS in the current units.
getEPOS()
Return the current EPOS in the current units.
setUnits()
Specify the units this stage now works in.
getUnit()
Return the units the axis is currently working in.
step( value )
Step a certain amount of units.
startLogging()
Start logging (capturing) data.
endLogging()
End logging (capturing) data and return the captured data.
setSetting(tag, value)
Set a specific setting. Tag’s and values can be found in the controller datasheet.
startScan( direction )
Move continuously with a constant speed in a specified direction (-1 or 1)
startScan( dir. , time )
Move a specific amount of seconds with a constant speed in a specified direction (-1 or 1).
stopScan()
Stop scanning.
setSpeed( value )
Set speed in current units.