HUM: A4988 STEPPER MOTOR DRIVER
You are a beginner with Dasduino. Or electronics? A specific module caught your eye, but you do not know how to use it? Do not worry, HUM is here for you! How to Use Module (HUM) is a blog tutorials series by soldered where you will find all you need in order to begin working with your favorite module. Tutorials include: technical characteristics, work principle, instructions on how to connect the module with Dasduino and the basic code. Everything else is left to your imagination.
When we want to control a step motor using Dasduino, we must have a driver that is connected between the motor and Dasduino. The reason why we have to use the driver is the current the motor uses when operating and it is always higher than the current Dasduino provides at its outputs. The A4988 module is used with bipolar step motors and allows us easier guidance as it has a built-in translator that manages when to turn an individual motor coil on. This module uses specific power supply for the logical part and a specific power supply for the step motor, since the motors require a voltage higher than 5 volts which are used by the logical part of the module. It also includes protection against excessive current, thus providing us with safe operation.
• Logical part voltage: 3.3 V ili 5 V
• Motor voltage: 8-35 V
• Maximum motor current: 2 A
HOW DOES THE MOTOR WORK?
The A4988 stepper motor driver has a translator that facilitates the usage. When impulses are connected to the driver’s STEP pin, the driver monitors the coil which is to be connected to the power supply and how it should be connected (which end to the positive pole of the power supply and which to the negative pole of the power supply) using the translator and logic controller, and depending on the number of impulses, the motor makes the same number of steps. As the driver determines everything, we need to send the impulse of how many steps we want the motor to make on the STEP pin. The DIR pin is used to determine the direction of rotation of the motor and it can be set to HIGH or LOW, depending on the desired direction. Inside the driver are mosfet transistors that allow the driver to deliver up to 2 A current per coil, and we have the protection against excessive current that can be adjusted with a trimmer potentiometer depending on how much current we need for our motor.
This driver also has a micro-step function that allows dividing the number of steps into smaller parts. That is, if we have a motor that takes 200 steps in a single turn, with this function we can achieve more steps, i.e. to achieve a higher resolution of the motor. This way we have the whole step, 1/2, 1/4, 1/8, 1/16 of the step. When using this function, we need to know that, in this case, the motor will take more steps in a single turn and it will also take longer. If we use the micro-step function, depending on how we want to divide the motor step, we need to connect the pins MS1, MS2, MS3 according to the given table, if we want the driver to work properly without dividing the motor steps into micro-steps, we do not connect the pins MS1, MS2, MS3 and then we achieve the whole step.
HOW TO CONNECT IT?
Connecting the A4988 driver is easy, we need to connect the power supply to the logical part for which we can use 5 V from the Dasduino, we also need a power supply whose voltage meets the needs of the motor, but it must be more than 8 V. We connect the motor to the outputs of the driver, and to STEP and DIR pins we connect the digital pins of the Dasduino using which we want to control the motor. A full-circuit wiring scheme is shown below, where Dasduino is used for logical power supply and a 12 V adapter for power supply of the motor.
This driver is easy to program and we do not need a library to use it, we simply have DIR and STEP pins to control the motor. We set the DIR pin to HIGH or LOW depending on the direction of rotation of the motor and on the STEP pin, we make impulses depending on the number of motor steps. Below, there is a code that moves the motor 200 steps to one side and after a one-second pause to the other.