Greetings everyone and welcome back. Here's something useful.
The PICO STEPPER MOTOR Driver is a do-it-yourself motor driver that was created from the ground up using the Raspberry Pi Pico as the main MCU and the A4988 motor driver.
A barrel jack serves as the power source, providing the stepper motor with 12V. To power the PICO and supply 5V to the stepper motor driver, we used an AMS1117 voltage regulator arrangement, which steps down the 12V to 5V.
We included a CON4 connector to link stepper motors to this arrangement, which works at 12V and can be used to pair any type of stepper motor. The NEMA17 stepper motor, which is coupled to a custom-built Gear Box for a future project, is being used for testing.
This Article is about the whole construction of this project, including the circuit assembly and final testing, so lets get started with the build.
Materials RequiredThese were the materials used in this project:
- Custom PCB (provided by HQ NextPCB)
- Raspberry Pi Pico
- STEPPER MOTOR DRIVER-A4988
- AMS1117 5V Voltage Regulator
- 10 uF 1206 Capacitor
- 1 uF 1206 Capacitor
- Female Header Pins CON20
- Female Header Pins CON8
- Male Header Pins CON4
- 10K Resistor 0603 Package
- RED LED 0603 Package
We begin by setting up the project's schematic, which is divided into three primary sections: the Raspberry Pi Pico Section, which includes a PICO and an LED that we added using the Pico's GPIO0. Additionally, we have controlled the DIR and STP pins of the motor driver using Pico's GPIO16 and GPIO17.
Next, we have the basic A4988 Stepper motor driver section. To activate the driver, we connected the sleep and reset pins.
We connected a CON4 port to pins A1, A2, B1, and B2 on the driver's stepper motor output.
Both ground pins are connected together, and we have added a 5V pin of the stepper motor driver with a 5V pin of Pico. Additionally, we have added the 12V pin of the driver with the input of the DC Jack.
The AMS1117 voltage regulator setup comes next, which consists of an AMS1117 voltage regulator in its most basic configuration with two capacitors attached to its input and output terminals. A 10 uF capacitor is added to the input, and a 1 uF capacitor is added to the output. Furthermore, we used a DC barrel jack that is connected to the AMS1117's input via an M7 diode. The AMS1117's 12V input is linked to the motor driver that supplies power to the entire system.
After creating the schematic, we prepared the board design and then exported the Gerber data, which will be shared with a PCB manufacturer.
HQ NextPCB ServiceAfter completing the PCB design, we export the Gerber data and send it to HQ NextPCB for samples.
Gerber Data was sent to HQ NextPCB, and a Yellow Solder Mask PCB with White Screen was ordered.
After placing the order, the PCBs were received within a week, and the PCB quality was pretty great.
In addition, I have to bring in HQDFM to you, which helped me a lot through many projects. Huaqiu’s in-house engineers developed the free Design for Manufacturing software, HQDFM, revolutionizing how PCB designers visualize and verify their designs.
HQDFM: Free Online Gerber Viewer and DFM Analysis ToolAlso, NextPCB has its own Gerber Viewer and DFM analysis software.
Your designs are improved by their HQDFM software (DFM) services. Since I find it annoying to have to wait around for DFM reports from manufacturers, HQDFM is the most efficient method for performing a pre-event self-check.
Here is what online Gerber Viewer shows me. Would not be more clear. However, for full function, like DFM analysis for PCBA, you need to download the software. The online version only provides a simple PCB DFM report.
With comprehensive Design for Manufacture (DFM) analysis features, HQDFM is a free, sophisticated online PCB Gerber file viewer.
It provides insights into advanced manufacturing by utilizing over 15 years of industry expertise. You guys can check out HQ NextPCB if you want great PCB service at an affordable rate.
Circuit Assembly Process- We begin the circuit-built procedure by utilizing a solder paste dispensing syringe to add solder paste to each pad of the SMD components. In this instance, the 63/37 Sn/Pb Solder paste, which melts at the temperature of 190° Celsius, is being used.
- We next pick and place each SMD component in its proper location using an ESD Tweezer.
- All SMD components are then permanently soldered to their pads when the entire circuit board is placed on the reflow hotplate, which heats the solder paste to its melting point.
- The THT components, such as the male header pin, female header pin connectors, and DC barrel jack, are then positioned in their proper positions, and their pads are soldered with a soldering iron.
- After that, we position the A4988 Motor driver in its proper location and place the Raspberry Pi Pico on the female header pins.
Circuit assembly is now complete.
CODEWe next uploaded the below sketch into our Raspberry Pi Pico.
const int dirPin = 16;
const int stepPin = 17;
const int ledPin = 0; // Pin connected to the LED
const int stepsPerRevolution = 200;
const int maxSpeed = 1000; // Maximum speed in microseconds
const int minSpeed = 2000; // Minimum speed in microseconds
void setup()
{
// Declare pins as Outputs
pinMode(stepPin, OUTPUT);
pinMode(dirPin, OUTPUT);
pinMode(ledPin, OUTPUT);
}
void loop()
{
// Blinking LED when motor is moving
digitalWrite(ledPin, HIGH);
// Set motor direction clockwise
digitalWrite(dirPin, HIGH);
// Ramp up speed from low to high over 5 seconds
for (int speed = minSpeed; speed >= maxSpeed; speed -= 20)
{
for (int x = 0; x < stepsPerRevolution; x++)
{
digitalWrite(stepPin, HIGH);
delayMicroseconds(speed);
digitalWrite(stepPin, LOW);
delayMicroseconds(speed);
}
delay(50); // Small delay to avoid skipping steps
}
delay(2000); // Hold at max speed for 2 seconds
// Set motor direction counterclockwise
digitalWrite(dirPin, LOW);
// Ramp up speed from low to high over 5 seconds
for (int speed = minSpeed; speed >= maxSpeed; speed -= 20)
{
for (int x = 0; x < stepsPerRevolution; x++)
{
digitalWrite(stepPin, HIGH);
delayMicroseconds(speed);
digitalWrite(stepPin, LOW);
delayMicroseconds(speed);
}
delay(50); // Small delay to avoid skipping steps
}
delay(2000); // Hold at max speed for 2 seconds
// Turn off LED when motor stops
digitalWrite(ledPin, LOW);
delay(1000); // Optional delay between cycles
}
This is a simple sketch that we created that does not require any libraries to function. The stepper motor and an LED are essentially controlled by this code, which causes the motor to accelerate in both directions and blink the LED when the motor is running.
STEPPER MOTOR SETUPWe developed a gearbox for the stepper motor test, which will be used in a future project. This driver circuit is just a part of that project.
- A gearbox with three gears—two 22-teeth gears with a 5mm modulus and one 10-teeth gear with the same 5mm modulus—is included here. We used a Nema17 stepper motor that we salvaged from an old Anet A8 3D printer to connect the smaller 10-teeth gear.
- We connected the stepper motor's wire harness connector to the driver's CON4, which is connected to the A1, A2, B1, and B2 terminals of the A4988 driver.
- The motor begins to rotate when the device is switched on by plugging the DC jack of a 12V 2A power adapter into the circuit via DC barrel jack.
This small yet practical project has resulted in a stepper motor driver board that can run almost any stepper motor. It is powered by the Pico and only needs a 12V input. Theoretically, we could just replace the A4988 Motor driver with another Stepper Motor driver board because most of them have the same footprint.
The Onboard Raspberry Pi Pico makes things incredibly easy to control; we can just connect the Pico with our computer and edit the code, make modifications, and then drive the motor with the 12V power adaptor.
This is it for today, folks. All the documents related to this project are attached, which you can checkout in this article. If you need any additional information, feel free to leave a comment, and I will be happy to assist you.
Special thanks to HQ NextPCB for providing components that I've used in this project; check them out for getting all sorts of PCB or PCBA-related services for less cost.
Thanks for reaching this far, and I will be back with a new project soon.
Comments