Stepper motors is a type of DC synchronous motors that divides their rotation cycle into several small steps. There are many applications for them, ranging from 3D printers to CNC machines. Stepper motors are important where precision and accuracy of moving objects is required. Using Arduino we can control stepper motor movement very easily, which helps in building multiple robotics projects such as human robots. Now, let’s discuss how many stepper motors we can integrate with a single Arduino board.
Stepper Motors with Arduino
Stepper motors can be controlled with a high degree of precision without any need for a feedback system. These motors can divide their complete rotatory cycle into several small discrete steps according to the digital input received from the Arduino board. Each digital pulse from Arduino can change stepper motor motion into the number of steps or fraction of complete cycle commonly referred to as “micro stepping”.
Generally, stepper motors fall into two categories:
- Bipolar
- Unipolar
Difference between these two motors can be told by looking into the number of output wires they have. Unipolar stepper comes with 4 wires, and it is most used, while Bipolar stepper motors have 6 wires output.
To control these stepper motors, we need an external motor driver. These motor drivers are needed because Arduino cannot withhold current more than 20mA and normally stepper motors take current a lot more than this. Another problem is kickback, stepper motors have magnetic components; they will continue to create electricity even when the power is cut off, which can lead to enough negative voltage that can damage the Arduino board. So, in short motor drivers are necessary to control stepper motors. One of the commonly used motor drivers is the A4988 module.
Figure shows a unipolar stepper motor is connected to Arduino using A4988 motor driver module:
To read more about how we can connect a stepper motor with Arduino click here.
Now we will move towards the main part to find out how many steppers motors Arduino can support.
How Many Stepper Motors Can Arduino Control
Arduino can control as many stepper motors as you want, it all depends upon the board we are using and number of input output pins available in an Arduino board. Arduino Uno has a total of 20 I/O pins available out of which 14 are digital and 6 Analog pins. However, we can also use analog pins to drive a stepper motor using a motor driver.
Using the A4988 motor driver module it takes up to two pins to drive a single stepper motor, which means Arduino Uno can support a total of 10 steppers motors all at once. The 10 motors also include the Tx and Rx pins on Arduino board, remember while using these pins we cannot upload or debug Arduino sketches anymore. To avoid this, communication pins should remain free so serial data transfer can be possible at any time.
Multiple Stepper Motors Using External Motor Driver
A single Arduino can control several stepper motors. It all depends upon which motor driver module we are using with Arduino. Arduino pins play an important role in controlling multiple stepper motors.
As mentioned earlier, if we use the A4988 motor driver module with Arduino Uno, it has the capacity of controlling up to 10 motors. These 10 stepper motors also include a connection at serial pins Tx and Rx. While these two pins are in use Arduino cannot serially communicate anymore.
A4988 motor driver takes only two pins STEP and DIR. These pins are enough to drive a single stepper motor easily. If we connect multiple steppers with Arduino, then each of them requires a separate motor driver module.
Here in the circuit diagram below, we have connected 9 stepper motors using A4988 module. All of them taking two control pins from Arduino.
Using a separate motor driver module have multiple advantages:
- Motor driver can control stepping logic on its own which frees Arduino to do another task.
- Reduction in overall connections which results in controlling more motors over a single
- Motor driver allows users to control motors without any microcontroller just by using a single square wave.
Multiple Stepper Motors Using I2C Protocols between Two Arduino
Another way of controlling multiple stepper motors is by connecting multiple Arduino boards using I2C communication protocols. I2C has an advantage of Master-Slave configuration which allows one device to control many without any need of external peripherals and wires. By using I2C we can increase the number of Arduino boards which result in providing more pins. All these pins can control stepper motors very easily.
Below diagram illustrate how Master-Slave devices are connected and by limiting number of wires how we can control multiple stepper motors.
Two Arduino boards can be connected using SDA and SCL pins which are at analog pins A4 and A5 respectively. In this way two Arduino boards are connected in Master-Slave configuration. Now each of these Arduino boards can support 8 stepper motors eliminating two wire pairs, one for serial communication and one we just used for I2C communication.
Arduino Analog Pin | I2C Pin |
A4 | SDA |
A5 | SCL |
Conclusion
Stepper motors play a vital role in designing robotics projects. Some projects might demand multiple stepper motors for their functionality. Controlling multiple motors can be possible in multiple ways, here we highlighted how we can control multiple stepper motors using I2C protocol and A4988 motor driver module.