Getting Started with The SlushEngine: Software Installation & Hardware Setup

If you need to use stepper motors in some kind of way for a project, this guide will cover how you can get started with the SlushEngine. By the end of this guide, you will be able to move 4 stepper motors at once. You will also learn how to use the position control features of the SlushEngine.


What you will need

  1. A SlushEngine: any model will do, the code is the same. Buy One.
  2. A Raspberry Pi (B, 2, 3, 0) and an SD card with Raspbian: most other Raspberry Pi OSs will work
  3. A power supply: A wall adapter, car battery, computer power supply, any thing that supplies voltage between 9v and 36v
  4. A Stepper motor: Almost all Bipolar stepper motors will work with the SlushEngine

Getting the Raspberry Pi running

The first thing we need to do before we make any motors move is install some software packages on the Raspberry Pi that will allow it to communicate with the SlushEngine. These packages are easy to install and we test them regularly with the OS(Raspbian, Trusty, etc...) on the Raspberry Pi webpage to ensure they are up to date and working. There are many different ways to connect to your Raspberry Pi. You can use VNC, SSH or just plug it into a monitor. All of these options will work for the SlushEngine.

First we have to enable SPI and I2C, these are the communication buses that will be used to communicate with the Raspberry Pi. To Enable these, we need to change there settings using the Raspberry Config program.

sudo raspi-config

This will open up a terminal based configuration window. You can use the arrow keys to scroll around and look at the cool features (now is not the time to enable overclocking). We want to do the following:

Advanced Options > SPI > Yes & Advanced Options > I2C > Yes

Once you have enabled both the SPI and the I2C, you can restart the Raspberry Pi.

With the Raspberry Pi rebooted, you want to make sure you have an Internet connection on the Raspberry Pi. All of the software is located on-line and will be installed automatically using a series of commands. Following the commands below will ensure proper installation. First, we will install the required packages we need to then install other packages (the installers installers).

sudo apt-get update

sudo apt-get install python3-pip git

Then install the library used to communicate with the SPI bus that we enabled before.

sudo pip3 install spidev

Now we will install a package that is used to communicate with the I2C bus. This will communicate with the temperature sensor and the IO on the SlushEngine board. 

git clone

cd quick2wire-python-api

sudo python3 install

All of the required packages have now been installed and we can finally install the SlushEngine software. This will be installed using the same method as was used for installing the I2C driver.  v

cd ..

git clone

cd slushengine

sudo python3 install

The hard work is finally over! Now you can hook up some hardware and we can get some motors moving.

Connecting the Hardware

It is always good practice to make sure that whenever you are connecting wires you have the power turned off. This can save a stray wire shorting out something and maybe killing a board.

First, we will connect the Raspberry Pi. This is done simply by placing the Raspberry Pi into the connector of the SlushEngine. You can see from the pictures below which way the Raspberry Pi should be connected.

Then we can connect the power wires to the Raspberry Pi. In this example, I am using an old laptop charger cable. It provides 17 Volts and 1.5 Amps. This will be more than enough to run a few stepper motors.

The stepper motor can now be connected. The wire coloring of stepper motors can vary depending on where you get your stepper motors from. If you use our stepper motors you can match the coloring of the wires to the connectors as they are seen in the picture. Essentially you need to figure out which wires coincide with which phases of the motor ( phase A and phase B). If you have no way of finding that information you can connect the wires to the SlushEngine and if the motor does not spin properly you can rearrange the wires until the motor runs properly.

Moving the Motor

Moving the motor is the easy part, and if everything is connected correctly, you will have a motor spinning in a few minutes. To test the motor, we are going to use Pythons Idle program. To open this, click menu in the top left corner, then Programming and Python3. Make sure you are using Python 3 or the code will not work correctly.

Now, line by line we can test to see if the motor is spinning, then we will be able to create and run a program. Type the following code line by line pressing enter after each line. This will initialize the Slush library and setup a motor.

import Slush
b = Slush.sBoard()
m = Slush.Motor(0)

The motor will now have moved a very small amount, 1000 micro steps. There are 128 micro steps in a step, so this is a very small and precise angle. Now that you have the motor moving you can try some different commands to see how the motor works. 

print (m.getPosition()), 0), 1

These are just some of the many features of the SlushEngine. You can do other things with the motor as well like setting the power to the motor, setting temperature limits, and using a limit switch to set a home position for the motor.

If you had trouble getting your SlushEngine going, check out the troubleshooting guide.