DRV8825: the driver for stepper motors

drv8825

Un motor driver It is a circuit that allows direct current motors to be controlled in a very simple way. These controllers allow managing the voltages and currents at which the motor is being supplied in order to control the rotation speed. In addition, they serve as a protection method to prevent the electronics of the motors from being damaged by limiting the current that circulates (chopping).

Therefore, if you are going to create a DIY project that will include one or more DC motorsWhatever type they are, and especially for stepper motors, you should use a motor driver to make things easier for you. Although there are methods to do it differently, using transistors, modules with motor drivers are much more practical and straightforward. In fact, these drivers rely on transistors to do their job ...

Why do I need a driver?

El driver is necessary for motor control, as I've said before. Also, you must bear in mind that the Arduino board and its microcontroller are not capable of powering the movement of the motor. It is simply designed for digital signals, but it would not work well when a little more power has to be supplied as required by these types of motors. That is why you have to have this element between the Arduino board and the motors.

Driver types

Know that there are several types of drivers according to the type of engine to which they are destined. This is important to know how to differentiate it to get the right driver:

  • Driver for unipolar motor: they are the simplest to control, since the current flowing through the coils always goes in the same direction. The driver's job simply must know which coils it has to activate on each pulse. An example of this type of controller would be the ULN2003A.
  • Driver for bipolar motor: these motors are more complex and their drivers are too, like the DRV8825. In this case, they can be activated with current in one direction or the other (north-south and south-north). It is the driver that decides the direction to change the polarity of the magnetic field that is produced inside the motor. The best known circuit for reversing the direction is called Punete H, allowing the motor to rotate in both directions. That H-bridge is made up of several transistors.

The latter have become even more popular in recent years because they are also included in some 3D printers to control printing with the head. It is possible that if you intend to mount a 3D printer or if you already have one, you will need one of these to be able to control the motor or replace this part if it has been damaged. They are also used for robots, plotters, conventional printers, scanners, electronic vehicles, and a long etc.

DRV8825

There are several models of drivers on the market. For example, him DRV8825 is an upgraded version of the A4988. This driver only needs two digital outputs from the microcontroller to be able to handle the motor properly. Only with that you can control the direction and the step of the motor with these two signals. That is, with this it is possible to perform stepping, or for the motor to rotate step by step instead of rotating quickly like other simple motors.

DRV8825 allows working with voltages higher than those used by the A4988, since can reach 45v instead of the 35v of the A4988. It can also handle higher currents, specifically 2.5A, that's half an amp more than the A4988. In addition to all that, this new driver adds a new 1/32 microstepping mode (1/16 for the A4988) to be able to move the stepper motor shaft more precisely.

Otherwise they are quite similar. For example, both can reach high operating temperatures without problem. Therefore, if you accompany them with a small heatsink, much better (many models already incorporate it), especially if you are going to use it above 1A.

If the encapsulation reaches high temperatures, as a precaution you should turn it off. It would be nice to consult the datasheets of the model you have bought and see the maximum temperature at which it can work. Adding a temperature sensor next to the driver to monitor the temperature and use a circuit that interrupts the operation if it reaches that limit temperature would be highly recommended ...

The DRV8825 has protection against problems of overcurrent, short circuit, overvoltage and overtemperature. Therefore, they are very reliable and resistant devices. And all for quite a low price in specialized stores where you can find this component.

Microstepping

microstepping

With the technique of microstepping steps lower than the nominal step can be achieved of the stepper motor you are going to use. That is, divide the turn into more portions to be able to advance more slowly or more precisely. To do this, the current applied to each coil is varied by emulating an analog value with the digital signals available. If perfect sinusoidal analog signals are achieved and 90º out of phase with each other, the desired rotation would be achieved.

But of course, you can't get that analog signal, because we work with digital signals. That is why these should be treated to try to simulate the analog signal through small jumps in the electrical signal. The resolution of the motor will depend on this: 1/4, 1/8, 1/16, 1/32, ...

To select the resolution you want you must control the M0, M1 and M2 pins of the module. The pins are connected to ground or GND by pull-up resistors, so if nothing is connected they will always be LOW or 0. To change this value, you will have to force a value of 1 or HIGH. The values ​​of M0, M1, M2 respectively those that have to be according to the resolution, are:

  • Full step: Low, Low, Low
  • 1/2: High, Low, Low
  • 1/4: Low, High, Low
  • 1/8: High, High, Low
  • 1/16: Low, Low, High
  • 1/32: all other possible values

Pinout

DRV8825 pinout

El DRV8825 driver has a simple connection scheme, although having enough pins can be a bit complicated for the less expert. You can see it in the image above, but make sure to position the module properly when you are looking at the pins, since it is common to make mistakes and take it inverted, which results in a bad connection and even damage.

How recommendation to connect the driver, it is recommended to properly adjust and calibrate the device by following the steps below for proper operation and not to damage it:

  1. Connect the driver to the voltage power supply without motor connected or microstepping.
  2. Measure with a multimeter the tension that exists between GND and the potentiometer.
  3. Adjust potentiometer until it is the proper value.
  4. Now you can turn off the power.
  5. At this moment yes you can connect motor. And reconnect the power to the diver.
  6. With the multimeter measure the intensity between the driver and the motor step by step and you can make a finer adjustment of the potentiometer.
  7. Turn off the power again and you can now connect it to Arduino.

If you are not going to use microstepping you can adjust the intensity of the regulator up to 100% of the rated motor current. But if you are going to use it, you must reduce this limit, since the value that will later circulate will be higher than the measured one ...

Related article:
L298N: module to control motors for Arduino

Integration with Arduino

ARduino and DRV8825 schematic

To use the DRV8825 driver with Arduino, the connection is quite simple as you can see at the top in this electronic schematic from Fritzing:

  • VMOT: connected to power up to 45v maximum.
  • GND: ground (motor)
  • SLP: at 5v
  • RST: at 5v
  • GND: to ground (logic)
  • STP: to Arduino pin 3
  • DIR: to Arduino pin 2
  • A1, A2, B1, B2: to stepper (motor)

Once connected and properly adjusted, the code for its control is also straightforward. For example, to control a stepper motor you can use the following code in Arduino IDE:

const int dirPin = 2;
const int stepPin = 3;
 
const int steps = 200;
int stepDelay;
 
void setup() {
   // Configura los pines como salida
   pinMode(dirPin, OUTPUT);
   pinMode(stepPin, OUTPUT);
}
 
void loop() {
   //Se pone una dirección y velocidad
   digitalWrite(dirPin, HIGH);
   stepDelay = 250;
   // Se gira 200 pulsos para hacer vuelta completa del eje
   for (int x = 0; x < 200; x++) {
      digitalWrite(stepPin, HIGH);
      delayMicroseconds(stepDelay);
      digitalWrite(stepPin, LOW);
      delayMicroseconds(stepDelay);
   }
   delay(1000);
 
   //Ahora se cambia la dirección de giro y se aumenta la velocidad
   digitalWrite(dirPin, LOW);
   stepDelay = 150;
   //Se hacen dos vueltas completas
   for (int x = 0; x < 400; x++) {
      digitalWrite(stepPin, HIGH);
      delayMicroseconds(stepDelay);
      digitalWrite(stepPin, LOW);
      delayMicroseconds(stepDelay);
   }
   delay(1000);
}

I advise you to also try some code examples that you will find among the examples that come with the Arduino IDE and try modifying values ​​to learn how it affects the motor.

For, more information about stepper motors, their control and Arduino programming, I recommend download our programming course for free.


The content of the article adheres to our principles of editorial ethics. To report an error click here!.

3 comments, leave yours

Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   Jesus said

    Hello, I am building a homemade CNC with drv8825, my question is if I can put nema 23 2.8a motors since they are somewhat cheaper than 2.5a, would I have a problem? Thank you

    1.    Isaac said

      Hello Jesus,
      Thanks for reading us. As for your question, keep an eye on the driver you are going to use so that it is compatible with those engines. The case of the DRV8825 is up to a maximum of 2.5A. Look to see the TB6600, which can go up to 3.5A if I remember correctly ...
      A greeting!

  2.   Rodolfo said

    Salaudos. What is the value of the electrolytic capacitor that is in the motor power supply. Thanks.