Controlling multiple stepper with SPI


#1

Hi there,

I am trying to control the stepper motors from Arduino. So far, I have been able to do control 1 stepper at the time with this guide from Roboteurs. But i don’t know how to control stepper motors more than one. I think we can declare more motor on Arduino code, but in SlushEngine how can i know the pin for Motor 1, 2, 3, 4, 5? Do I have to specify it in Arduino code?

Thanks in advance,
Tulga


#2

Hi Tulga,

The Arduino code should look something like this,

#include <SPI.h>
#include <L6470.h>

// Motors
L6470 Motor1(10)
L6470 Motor2(9)
L6470 Motor3(6)
L6470 Motor4(5)

void setup() {
	Serial.begin(9600)
	
	// Initialise 4 stepper motors
	Motor1.init()
	Motor2.init()
	Motor3.init()
	Motor4.init()
	
	// Acceleration for each motors
	Motor1.setAcc(100)
	Motor2.setAcc(200)
	Motor3.setAcc(300)
	Motor4.setAcc(400)
	
	// Etc.
}

I’m not familiar with Arduino, but you have to specify four slaves (SS), see Serial Peripheral Interface (SPI).

Once four slaves (SS) have been setup, you will then need to connect this to the SlushEngine pins, as highlighted in red (STP0_CS, STP1_CS, STP2_CS, STP3_CS)

This should be able to help you out, in defining multiple CS pins. https://www.bluedot.space/tutorials/connect-multiple-bme280-on-spi/


#3

Hi. Can you please explain what the numbers 10, 9, 6 and 5 are?


#4

Hi Firas,

They were examples of the output pins of the Arduino, that connects to the _CS pins of the SlushEngine. The pin numbering on the Ardiono may not be be correct!

The example shown here https://roboteurs.com/pages/using-the-slushengine-with-an-ardunio, show’s one stepper motor connected, using pin 10.


#5

Hi friend. I have SlushEngine D and I need to control all the seven motors. Can you describe the connection?
Thanks.


#6

Hello,

First, you need the schematics of the SlushEngine Model D, which can be found here SlushEngine Model D.

Second, follow these instruction Using the SlushEngine with an Arduino, and try and get one stepper motor working. You need to understand what RST, CS, SDI, SDO, CLK, FLAG, BUSY and GND pins do.

Third, once you have figured out the pins on the SlushEngine, you should then be able to setup and control more than one stepper motor.

Note: I’ve never used Arduino before, but I’m guessing the GPIO Setup will be similar to RPi


#7

I already know what these pins do but that is not enough. The schematic diagram of SlushEngine Model D does not say anything about how to connect it to arduino. The example of controlling one stepper motor with arduino and the SlushEngine does not give any clue about how to upgrade into controlling multiple motors. Maybe I am missing something here but I am still on step zero.


#8

Hi Firas,

Have you managed to get one stepper motor working using your Arduino and the SlushEngine?