Skip to main content

Building a Robot Actuator with ESP32 and a 5010 BLDC Motor






Introduction

Modern robotics demands actuators that aren’t just strong, but also smart — capable of precise control, smooth motion, and safe human interaction. Traditional servos are great for small robots, but they can be stiff, noisy, and limited in range or torque.

This project demonstrates a custom robot actuator built around a 5010 360 KV brushless DC (BLDC) motor, controlled by an ESP32 running the SimpleFOC library. The goal is to create a compliant joint — one that can be moved by hand, but automatically returns to its home position with adaptive stiffness.


🧠 What Makes This Actuator Special

Unlike a typical servo, this actuator behaves intelligently:

  • You can turn it by hand — it feels soft and back-drivable.

  • When you release it, the motor returns to its initial position smoothly.

  • If you twist it harder (e.g., due to gear reduction), it becomes stiffer, resisting displacement more strongly.

  • It’s powered by 12 V and controlled by a simple ESP32 board using FOC (Field Oriented Control) for quiet, precise torque control.

⚙️ Hardware Overview

ComponentDescription
Motor5010 360 KV BLDC (12 N14 P)
Driver3-PWM MOSFET driver (e.g., L6234, DRV8313, or custom)
MicrocontrollerESP32 DevKit
Position SensorAS5600 I²C magnetic encoder
Power Supply12 V DC
FirmwareSimpleFOC running on Arduino framework

The AS5600 provides high-resolution angle feedback, while the ESP32 handles the FOC algorithm at high speed. The 5010 motor, commonly used in drones, provides excellent torque-to-weight ratio when combined with a gear reduction.


🔩 How It Works

The actuator uses a Field-Oriented Control (FOC) loop to control torque and position precisely.
At the core lies a compliance control strategy implemented in firmware:

  1. When the user moves the shaft by hand, the software detects a manual deviation.

  2. It reduces stiffness and limits voltage, allowing free motion.

  3. Once the movement stops, it gradually restores holding torque and returns the actuator to its home position.

This results in a natural, spring-like behavior — soft when you move it, firm when it holds position.


🧰 Firmware Logic Highlights

The core of the firmware is written using SimpleFOC and a few key logic blocks:

  • Angle control loop: Keeps the motor aligned with a target position.

  • Manual detection: Monitors angle deviation and angular velocity to detect hand movement.

  • Adaptive stiffness: Dynamically adjusts P_angle.P and voltage_limit to soften or stiffen response.

  • Return to home: When released, the motor returns smoothly to the original angle.

Here’s a simplified version of the control logic:

if (abs_err > manual_threshold) { // User is moving the actuator manual_mode = true; motor.P_angle.P = soft_P; driver.voltage_limit = free_voltage_limit; } else if (manual_mode && velocity_is_low) { // User released it manual_mode = false; motor.P_angle.P = hold_P; driver.voltage_limit = hold_voltage_limit; target_angle = home_angle; // return to home }

This logic makes the motor behave like a robotic spring joint — a balance between freedom and control.


🧩 Gearing and Stiffness

Because the 5010 motor is geared, torque at the output is multiplied, but so is resistance to back-driving.
To compensate, the firmware uses adaptive stiffness control — if you push harder (moving past the manual_threshold), the motor briefly increases its proportional gain (P_angle.P) and voltage limit to push back more strongly, ensuring a natural feel and stable return to the target.

You can tune this behavior with:

const float soft_P = 0.05f; // free movement const float hold_P = 1.0f; // firm hold const float free_voltage_limit = 1.0f; const float hold_voltage_limit = 4.0f;

🔌 Power and Performance

At 12 V and around 1 A of current draw during active correction, the actuator is both efficient and quiet.
The ESP32’s dual cores easily handle the FOC loop and serial monitoring, leaving room for Wi-Fi, Bluetooth, or ROS2 communication in future updates.


🤖 Applications

  • Robotic arms and grippers with human-safe compliance

  • Exoskeleton joints with soft-touch feedback

  • Animatronics and camera gimbals requiring natural motion

  • Educational robotics — understanding FOC and compliant actuation



Conclusion

This ESP32-based 5010 actuator shows that compliance and precision don’t require expensive industrial hardware.
With open-source tools like SimpleFOC and affordable drone motors, you can build a smart, smooth, and safe robot joint for your next project.

Whether you’re a maker, researcher, or roboticist — this actuator is a great starting point for exploring modern, FOC-based compliant control.



GITHUB Code

Comments

Popular posts from this blog

How to program 8051 based MCU using Ptroteous Schematic capture and Source code editor to use timers using AT892051 + project files

 This tutorial is dedicated to use a 8051 based Microcontroller core and program it using keil's C51 tools on the Proteus Source code editor.  1- Brief History of 8051 one of the first microprocessors 4004 was invented by Intel Corporation as well as  8085 and 8086 microprocessors back in 1981,shortly after Intel introduced an 8-bit microcontroller called the 8051 . It was referred to as system on a chip because it had 128 bytes of RAM, 4K byte of on-chip ROM, two timers, one serial port, and 4 ports (8-bit wide), all on a single chip. When it became so widespread, Intel allowed other manufacturers to make and market different flavors of 8051 with its code compatible with 8051. It means that if you write your program for one flavor of 8051, it will run on other flavors too, regardless of the manufacturer. This has led to several versions with different speeds and amounts of on-chip RAM. 2- Features of AT892051 Microcontroller Compatible with MCS®-51Products 2K ...

What is the ESP32 VSPI / HSPI

 The ESP32 integrates four SPI peripherals. SPI0 and SPI1 are used to access the ESP32’s attached flash memory and thus are currently not open to users to be used . They share one signal bus via an arbiter. SPI2 and SPI3 are general purpose SPI controllers, sometimes referred to as HSPI and VSPI, respectively. They are open for use. SPI2 and SPI3 have independent signal buses with the same respective names. Each bus has three CS lines to drive up to three SPI slaves.  

Most common baud rates table

  The following table shows the most used baud rates. The left side part of the table shows speed and bit duration. The right part shows real transmission speed assuming there is no parity, 8 data bits and one stop bit.   Bauds Bits/s Bit duration Speed Actual speed Actual byte duration 50 bauds 50 bits/s 20.000 ms 6.25 bytes/s 5 bytes/s 200.000 ms 75 bauds 75 bits/s 13.333 ms 9.375 bytes/s 7.5 bytes/s 133.333 ms 110 bauds 110 bits/s 9.091 ms 13.75 bytes/s 11 bytes/s 90.909 ms 134 bauds 134 bits/s 7.463 ms 16.75 bytes/s 13.4 bytes/s 74.627 ms 150 bauds 150 bits/s 6.667 ms 18.75 bytes/s 15 bytes/s 66.667 ms 200 bauds 200 bits/s 5.000 ms 25 bytes/s 20 bytes/s 50.000 ms 300 bauds 300 bits/s 3.333 ms 37.5 bytes/s 30 bytes/s 33.333 ms 600 bauds 600 bits/s 1.667 ms 75 bytes/s 60 bytes/s 16.667 ms 1200 bauds 1200 bits/s 833.333 µs 150 bytes/s 120 bytes/s 8.333 ms 1800 bauds 1800 bits/s 555.556 µs 225...