In the previous post, we covered the basics of BLDC motors, stepper motors, and the importance of open-loop vs. closed-loop control. Now, it’s time to set up a BLDC motor and its driver, test basic rotation, and prepare for precise position control in later steps.
This guide will cover: ✅ Understanding what a BLDC driver (ESC) is and why we need it. ✅ Connecting the BLDC motor to the driver. ✅ Sending basic movement signals using an Arduino or ESP32.
1. What Is a Motor Driver and Why Do We Need It?
A BLDC motor cannot be directly controlled by an Arduino or ESP32 because:
It requires high power that microcontrollers cannot provide.
It needs precise switching between its coils to spin properly.
A BLDC driver (ESC – Electronic Speed Controller) solves this problem. It acts as a bridge between the microcontroller and the motor by: ✔ Converting low-power signals into high-power outputs for the motor. ✔ Controlling speed and direction using PWM (Pulse Width Modulation). ✔ Switching current between motor coils in the correct sequence.
2. Choosing the Right Motor Driver
For this project, you can use:
1️⃣ ESC (Electronic Speed Controller) – Best for Simple Testing
ESCs are commonly used in drones and RC cars. They are easy to set up and work well for basic rotation tests. Examples:
SimonK or BLHeli ESCs (for sensorless BLDC motors).
Hobbywing or ZTW ESCs (for general use).
2️⃣ Dedicated BLDC Drivers – Best for Advanced Control
If you want more control over position and torque, you can use:
L6234 Motor Driver (for small BLDC motors).
ODrive (for precise motion control).
VESC (Vedder ESC) (for robotics and high-performance applications).
For now, we will use an ESC, which is the simplest option.
3. Wiring the BLDC Motor to the ESC and Microcontroller
🛠️ Required Components:
BLDC Motor (e.g., a drone motor or gimbal motor)
ESC (Electronic Speed Controller)
Arduino or ESP32
12V-24V Power Supply (Battery or Adapter)
3 Signal Wires for PWM Control
🔌 Wiring Diagram
Component
Connects To
Motor Phase Wires (A, B, C)
ESC Output (3 wires)
ESC Power Input
12V-24V Power Supply
ESC Signal Wire
Arduino/ESP32 PWM Pin
ESC Ground
Arduino/ESP32 Ground (GND)
4. Programming the ESC to Control the BLDC Motor
We will send PWM signals to control the motor’s speed and direction.
📝 Arduino Code to Test Basic Rotation
#include <Servo.h>
Servo esc; // Create an ESC control object
void setup() {
esc.attach(Arduino/ESP32 PWM Pin number); // Connect to ESC signal pin
esc.writeMicroseconds(1000); // Minimum throttle (stops the motor)
delay(2000); // Wait for ESC to initialize
}
void loop() {
esc.writeMicroseconds(1500); // Mid-throttle (motor spins slowly)
delay(3000);
esc.writeMicroseconds(2000); // Full speed
delay(3000);
esc.writeMicroseconds(1000); // Stop the motor
delay(3000);
}
💡 Explanation of the Code
esc.attach(Arduino/ESP32 PWM Pin number); → Connects the ESC to Arduino/ESP32 PWM Pin number
esc.writeMicroseconds(1000); → Sends a low PWM signal (stops motor).
esc.writeMicroseconds(2000); → Sends a high PWM signal (full speed).
The motor spins at different speeds every 3 seconds.
5. Testing and Troubleshooting
✅ If Everything Works Correctly:
✔ The motor starts spinning after initialization. ✔ The speed changes every 3 seconds.
❌ If the Motor Doesn’t Move:
❌ Motor doesn’t start?
Check if the ESC is armed (some require a special startup sequence).
Ensure the power supply is strong enough (12V or higher).
❌ Motor jerks but doesn’t spin?
If using a sensorless ESC, try a higher startup speed.
If using a sensored motor, make sure Hall sensors are connected properly.
Next Steps: Step 3 – Adding an Encoder for Position Feedback
Now that we’ve tested the BLDC motor’s basic movement, the next step is adding an encoder to measure its position. This will allow us to control the motor like a stepper motor.
In Step 3, we will: ✅ Explain what an encoder is and how to read position data. ✅ Display encoder values on the serial monitor. ✅ Prepare for closed-loop position control.