Using the SlushEngine with an Arduino
The SlushEngine is controlled by a standard communications protocol called SPI (Serial-Peripheral-Interface). Any micro-controller or computer that has this interface can communicate with the SlushEngine. In this guide, we are going to connect the SlushEngine to an Arduino.
- Arduino: We will be using the Uno, but just about any of them will work
- Power Supply: 9V - 36V, this could be a wall adapter, a car battery, or a computer power supply
- SlushEngine: This will work with any SlushEngine, but we will be using the Lite model
- Stepper Motor: Nema 17, Bipolar
- Some jumper wires
Connecting the Ardunio to the SlushEngine
To connect the SlushEngine to the Arduino, all we have to do is run jumper wires to the appropriate pins. Follow the image below to see how to connect them, just match the naming on the Arduino pins with the pin names on the SlushEngine. You will also need to connect a wire between ground on the SlushEngine and ground on the Arduino.
Once you have connected all of the pins you can power the SlushEngine and the Arduino.
Make sure that you do not connect the power wires to the SlushEngine in reverse. This can damage the board.
Connecting the Motor
To connect the motor all you need to do is check which of the four wires are phase A and phase B. Usually this is described in the datasheet or product page of the motor. If it isnt dont worry! You can hook the wires up at random until it works. It wont hurt the motor.
Setting up the Software
To program the Arduino you will need to install the Arduino IDE, this can be done on Windows, Linux, or Mac. Once the software is installed, make sure you can program the Arduino using one of the example programs.
Next, make a new sketch and save it somewhere you will remember. We are going to add a library that can be used to control the SlushEngine. Next you will need to download this library. Once you have downloaded the .zip you will need to extract it and copy the folder L6470 to your Ardunio libraries directory. In Linux, this is located where ever you extracted Ardunio.
Once this is done you can start Ardunio and you should be able to see the L6470 driver in the libraries list. This can be found in the drop down Sketch > Include Library > L6470.
Now we can open an example from this library. This can be loaded by selecting File > Examples > L6470 > L6470.
Once the example is loaded you should see some code loaded as in the above image. You can click compile to make sure that the code compiles without any errors.
Running the Code
If you connected everything correctly you can upload the code to the Ardunio and your motor should start moving! Play around with the code to get a feel for it. The commands in the example code will let you do many different things with the motor. Its always fun to see how fast you can make a stepper motor spin before it starts skipping.
If your code does not work some of the following tips might help you work out the issues.
- Reset the Ardunio board or unplug it from the USB
- Check to make sure the SlushEngine is getting at least 9V of power
- Check that all you cables are connected correctly (particularly MOSI and MISO)