
Bldc&foc motor controller
bejaouihamza/bldc-foc-pcb
This open-source hardware project is a compact, single-board FOC (Field-Oriented Control) motor driver designed for precision robotics, drones, CNC machines, and automation systems.

Six-axis robotic arm I designed and built end to end: custom STM32H562 controller PCB, bare-metal C firmware, RS485 multi-motor bus, and a PID current-feedback gripper that holds an egg without cracking it. Includes KiCad, CAD, firmware, and host tests.
Dexter pcb is an open-source printed circuit board by clucasjiang, from the clucasjiang/dexter_v1 repository on GitHub. It is a 2-layer board of 65 × 40 mm with 36 parts on 73 nets, routed with 183 tracks and 22 vias.
It is built around the MAX3485ED, XT60PW-M and DW127R-22-14-23. Its parts include 14 capacitors, 8 resistors, 4 ICs, 2 connectors and 1 diode. It belongs with the interfaces and adapters and robots and motor control boards and the STM32 boards of this library.
Dexter is a six-degree-of-freedom robotic arm with a force-controlled gripper, a PETG-CF 3D-printed structure, custom controller electronics, and embedded C firmware. The project brings together mechanical design, PCB design, motor communications, and feedback control—from an early prototype to a fully assembled arm that can hold an egg without breaking it.
I designed, built, assembled, programmed, and tested Dexter independently. The stepper-driven arm and the firmware in this repository are the completed, tested first version of an ongoing robotics project. I am now developing a second version with BLDC motors to improve motion quality, control performance, and overall results.
Core technologies: KiCad · STM32H562 · Embedded C · RS485 · PID control · Motor current feedback
| Gentle grasping | Arm motion |
|---|---|
![]() | ![]() |
| A PID force loop regulates the grip to hold an egg without breaking it. | A wave demonstration shows the assembled arm in motion. |
The egg demonstration highlights the central controls challenge: applying enough force to retain a delicate object while limiting additional closing motion after contact.
| Early prototype | Fully assembled arm |
|---|---|
![]() | ![]() |
| An early build used to develop the mechanical arrangement. | The completed assembly integrates the joints, housings, wiring, and gripper. |
Inside the housings: stepper motors, harmonic reduction, and the pulley structure that drives the arm.
The KiCad controller project includes the schematic, PCB layout, component libraries, footprints, and 3D models.
The stepper motors have built-in drivers from ZDT, so the STM32 can send movement commands directly over RS485 and read back position, speed, and motor current. Each motor has its own address on the bus.
| Subsystem | Implementation |
|---|---|
| Main controller | STM32H562 microcontroller running the arm application and peripheral interfaces. |
| Power | 24 V input through an XT60 connector and an AP63203 regulator for the 3.3 V logic supply. |
| Motor bus | MAX3485 RS485 transceiver; firmware addresses joints as 1–6 and the gripper as 7 at 115200 baud. |
| Grip feedback | The claw motor's built-in phase-current feedback, read over RS485 in milliamps and used as a proxy for grip load. |
| Development interfaces | Debug/programming connections, reset/boot circuitry, and a serial command console. |
| External stop input | PC13 accepts a normally closed emergency-stop loop; an open input requests a stop. This connection is external to the current controller PCB. |
The firmware pin assignments match the controller PCB: PA0/PA1 carry the UART4 motor bus, PA2 controls the MAX3485 transmit enable, and PB5/PB6 provide the UART5 serial console.
The firmware uses a bare-metal C11 application with separate board, protocol, joint-control, gripper-control, and scheduling layers.
arm.c converts joint angles and speeds into motor commands using each joint's reduction and direction. It supports absolute joint moves, configurable travel and speed limits, manual reference capture, explicit arming, and individual or whole-arm stops. Feedback monitoring checks following error, lack of progress, motion deadlines, stale telemetry, and driver faults.
zdt.c implements the ZDT X-firmware protocol over RS485, including trapezoidal position moves, current-limited commands, configuration checks, and telemetry decoding. Transactions validate reply framing and acknowledgements, use bounded timeouts, and avoid automatic motion retries. Decoded feedback includes position, speed, following error, current, voltage, temperature, and driver status.
gripper.c uses the claw stepper's built-in phase-current feedback as a proxy for grip load. The application polls aggregate status from motor 7 every 20 ms, obtaining current, position, speed, and driver flags together.
The outer PID turns measured phase current into small opening or closing corrections:
The application dispatches finite, current-limited position moves (0xCD), using the drive's internal control loops. Unfiltered current limits, reply freshness, and gripper travel checks remain active while a move is pending. Communication errors, driver faults, or loss of the claw's volatile reference marker stop operation. The installed motors run X firmware in closed-loop mode.
Current is a proxy for motor torque and grip load, not a calibrated jaw-force measurement in newtons. Friction, jaw geometry, and direction affect the relationship. GRIP takes milliamps. The tested configuration uses a 100 mA maximum target, 150 mA drive limit/software trip, 40 mA/s target ramp, and 3 mA deadband. These limits and the PID gains are used by the completed stepper-driven arm, including the gentle grasping demonstration above. Limits live in robot_config.h, and PID defaults in gripper.c.
STATUS reports joint positions and targets, claw phase current and target in mA, feedback validity and age, faults, measured loop frequency, missed releases, longest update, and watchdog-reset status.Current application motion is joint-space control with manual referencing; Cartesian inverse kinematics, automatic homing, and coordinated trajectory planning are not implemented.
Start with the Dexter STEP assembly for the mechanism, the KiCad schematic for electronics, and robot_app.c for application behavior.
Requires CMake 3.22+, Ninja, and the GNU Arm Embedded toolchain (arm-none-eabi-*) on PATH. From the repository root:
cd Firmware
cmake --preset Debug
cmake --build --preset DebugOutputs are build/Debug/dexter_legacy.elf, .hex, and .bin. A Release preset is also provided. dexter_legacy.ioc contains the STM32CubeMX project configuration.
The tests run on a computer without connecting the arm. With CMake and a native C compiler, run from the repository root:
cmake -S Firmware/tests -B Firmware/build/host-tests
cmake --build Firmware/build/host-tests --config Debug
ctest --test-dir Firmware/build/host-tests -C Debug --output-on-failureThe claw tests check that it closes when current is low, opens when current is high, and stops on too much current or old feedback. There are also tests for the motor protocol and loop timing. The full firmware has also been tested on the assembled arm; the demonstrations at the top of this page show the resulting motion and grip control.
Connect a 3.3 V serial adapter to the console at 115200 baud, 8N1. Commands are uppercase and newline-terminated.
| Command | Purpose |
|---|---|
HELP, STATUS | Show commands or runtime diagnostics. |
ZERO, ARM | Capture the manually positioned zero pose, then permit motion. Place the gripper fully open before ZERO. |
MOVE joint degrees deg/s | Move one joint to an absolute angle relative to the captured zero. |
GRIP milliamps, OPEN | Regulate measured motor phase current (default range: greater than 0 through 100 mA), or return the gripper to its open reference. |
DEMO | From the zero pose, move each joint sequentially to 5° and back at 2°/s. This is a commissioning routine separate from the wave GIF. |
STOP [joint], DISARM, CLEAR | Stop all axes or one axis (1–7), stop and disarm, or clear a fault while disarmed. |
After placing the joints at zero and the claw fully open, use ZERO, then ARM, then select a tested GRIP target in mA. The position reference is lost on reset. Stop commands preserve motor enable where possible, but software stops and the MCU watchdog cannot guarantee holding torque after power or communication loss; gravity-loaded joints need physical support during commissioning.
| Path | Contents |
|---|---|
| CAD/ | Portable STEP assembly of the complete mechanism. |
| PCB/main_controller/ | KiCad controller design and supporting libraries. |
| Firmware/App/ | Motor protocol, arm and gripper controllers, command interface, and scheduler. |
| Firmware/Board/ | UART/RS485, external stop-input, and watchdog interfaces. |
| Firmware/Core/ | STM32 startup and system initialization; vendor support resides in Firmware/Drivers/. |
| Firmware/tests/ | C tests for the motor protocol, claw control, and loop timing. |
| README/ | Demonstration GIFs and photographs of the design process and assembly. |
| Qty | Value | Footprint | References |
|---|---|---|---|
| 8 | 100nF | Capacitor_SMD:C_0603_1608Metric_Pad1.08x0.95mm_HandSolder | C1, C2, C3, C4, C5, C9, C11, C12 |
| 3 | 0 | Resistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolder | R3, R4, R5 |
| 2 | 10uF | Capacitor_SMD:C_0603_1608Metric_Pad1.08x0.95mm_HandSolder | C6, C10 |
| 2 | 2.2uF | Capacitor_SMD:C_0603_1608Metric_Pad1.08x0.95mm_HandSolder | C7, C8 |
| 2 | 22uF | Capacitor_SMD:C_0603_1608Metric_Pad1.08x0.95mm_HandSolder | C13, C14 |
| 2 | 390 | Resistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolder | R6, R8 |
| 2 | XT60PW-M | easyeda2kicad:CONN-TH_XT60PW-M | CN1, CN2 |
| 1 | 10K | Resistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolder | R2 |
| 1 | 120 | Resistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolder | R7 |
| 1 | 3.9uH | Inductor_SMD:L_Changjiang_FNR4030S | L1 |
| 1 | 4.7K | Resistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolder | R1 |
| 1 | AP63203WU-7 | Package_TO_SOT_SMD:TSOT-23-6_HandSoldering | U2 |
| 1 | DW127R-22-14-23 | easyeda2kicad:HDR-TH_14P-P1.27-V-M-R2-C7-S1.27-2 | H1 |
| 1 | HX 2.54-2P WT | easyeda2kicad:CONN-SMD_2P-P2.54-XH2.54-WT | U4 |
| 1 | LED | LED_SMD:LED_0603_1608Metric_Pad1.05x0.95mm_HandSolder | D1 |
| 1 | MAX3485 | Package_SO:SOIC-8_3.9x4.9mm_P1.27mm | U3 |
| 1 | STM32H562RGTx | Package_QFP:LQFP-64_10x10mm_P0.5mm | U1 |
| 1 | SW_Push | Button_Switch_SMD:SW_SPST_TS-1088-xR020 | SW1 |
The 32 most common of 36 parts.

bejaouihamza/bldc-foc-pcb
This open-source hardware project is a compact, single-board FOC (Field-Oriented Control) motor driver designed for precision robotics, drones, CNC machines, and automation systems.

BenjamimKrug/robo_humanoide
Repositorio para arquivos gerais necessários para o desenvolvimento do Robô humanoide





danielwilczak101/EasyControls
Originally part of the NASA Asteroid flyer program has been repurposed by the EPPL to allow anyone interested in controls to go online and connect with a real working device and test their own control algorithms on a…

IITB-Rocket-Team-Avionics/Ember
Experimental Flight Computer with potential mitigations of previous issues faced by FLYTE and a testbed for new systems.
It measures 65 × 40 mm and has 2 copper layers, 1.6 mm thick.
36 parts, built around the MAX3485ED, XT60PW-M and DW127R-22-14-23. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.
From the clucasjiang/dexter_v1 repository on GitHub, at the commit this page was made from: the board is PCB/main_controller/dexter_pcb.kicad_pcb and its schematic PCB/main_controller/dexter_pcb.kicad_sch. PCBKit opens the board in the browser, with nothing to install.
Its repository states no licence, so its author keeps all rights: ask clucasjiang before reusing the design.