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.
MacOS
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:
python3 --version
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.
Raspberry Pi's
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.
Installing pyStackRail
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:
python3 StackRail.pyc
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
Running pyStackRail
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
1 = Half Step
2 = 1/4th Step
3 = 1/8th Step
4 = 1/16th Step
5 = 1/32nd Step
6 = 1/64th Step
7 = 1/128th Step
Wait is the amount of time to wait before taking a picture in milliseconds. So 1000 means 1000ms = 1 second
Hold is the amount of time to hold before moving, again in milliseconds
Snap is amount of time camera shutter is held down, again in milliseconds
FullP is the running power for the motor. Here is a formula for the settings: Current = (FullP + 1) / 16. For example, if FullP = 15, current is (15+1)/16 = 1.0A
IdleP is the idling power for the motor. Same formula as FullP