pyStackRail etc . . .
Ubiquity of Python computer language is undeniably popular, it is almost everywhere, even little device like Arduino has a version of it running. So, it is a very good idea to have our StackRail system running in Python environment and that is what pyStackRail is!
To be able to run pyStackRail, a computing device capable of running Python 3.5.3 with Tkinter package. This includes Mac OS devices, Raspberry Pi's, etc. Here are instructions on how to install it on MacOS and Raspberry Pi
pyStackRail works with our USB StackRail controller via USB port, so the controller is required.
By Default, MacOS (up to High Sierra) comes with Python 2.7 installed. This is not enough because it does not support Tkinter. The minimum Python version required is 3.5.3. So we need to install Python 3.5.3 on a Mac. You can download Python 3.5.3 for Mac from
After installing it, please use the following command to check if it is successful:
It should show Python 3.5.3
Next is to install pip3. By default the pip3 is not up to date, so we need to install it. The best way is to curl a python script and install it with python. Run the following command:
curl https://bootstrap.pypa.io/get-pip.py o get-pip.py
After that, run the following command:
sudo python3 get-pip.py
Verify it with pip3 --version command
After pip3 is installed, run the following command to get pySerial package installed:
sudo pip3 install pyserial
The above command is very important.
Fortunately (deliberately by design) , Raspberry Pi's comes with Python 3.5.3 installed, as well as pySerial installed. So no need to install them.
After Python environment are setup, download pyStackRail tar file and issue the following command:
tar -xvr StackRail.gz
After this command, you will have a folder named StackRail and it has all files needed. To run pyStackRail, cd into newly created StackRail folder and issue the following command:
If error is reported, please make sure the following:
USB StackRail controller is plugged into the computing device (Mac or Raspberry Pi)
USB StackRail controller is powered up
For some reason, both Mac and Raspberry Pi do not recognize any USB serial dongle at first boot, so try to issue the command again
Starting up pyStackRail
If you run it without any parameters, pyStackRail will find the first StackRail USB controller and communicate with it.
All StackRail USB controller with firmware ID >= 2.4 have an ID associated with it. If you specify this ID when starting up pyStackRail, only the controller with this ID will be connected. If there is no USB controller with specified ID, error will be reported
You can set ID by issue the command Set like this:python3 pyStackRail Set=5, but only do this when there is only ONE USB controller is connected to the computing device
Setting up parameters for pyStackRail
pyStackRail does not have GUI to setup parameters such as pitch, microstepping, power, etc. However, these parameters are saved in a file named STACKRAIL.DAT, you can modify this file manually.
When ID is -1 (ID = -1), the setting will be applied to all USB controllers regardless its ID, but if there is another setting for a specific ID, those settings will override this one. These parameter are read sequentially, so ID=-1 settings MUST be the first one.
DoF is the default depth of field for optical system. This field is modifiable in GUI, so it is mainly for convenience.
Pitch is the pitch of screw used in micrometers, ie, 1000 = 1000um = 1mm
TnRev is number of steps per revolution for the motor, commonly 200 (for 1.8 degree motor) or 400 (for 0.9 degree motor)
MStep range from 0 to 7
0 = Full Step