Skip to content

About

Zephyr RTOS firmware that turns a stepper motor and an STM32 B-G431B-ESC1 board into a DYNAMIXEL XM430 smart servo for ROS 2: closed-loop microstepping at 20 kHz, MCUboot, tested on a PC with a simulated motor.

Topics

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

23 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DYNAMIXEL Protocol 2.0 packets from a ROS 2 host reach a controller board running Doppelstep on Zephyr RTOS, which drives a stepper motor with a servo horn through two phase currents 90 degrees apart

Doppelstep

Your stepper, seen as a smart servo: Zephyr RTOS firmware that turns a stepper motor and an STM32 board into a joint that answers as a DYNAMIXEL XM430-W350.
Zephyr RTOS 4.5 · DYNAMIXEL Protocol 2.0 · 20 kHz current control · MCUboot · Tested on a PC

CI Documentation Release License: Apache-2.0

Documentation · PDF manual · Getting started · Hardware and wiring


Overview

Doppelstep is open-source Zephyr RTOS firmware for the STMicroelectronics B-G431B-ESC1 motor-control board. It drives a two-phase stepper motor with closed-loop microstepping current control and answers on the bus as a DYNAMIXEL XM430-W350 (model 1020) in position, extended position and velocity mode. Software written for the servo, such as the DynamixelSDK under the ROS 2 dynamixel_hardware_interface of an OpenMANIPULATOR-X robot arm, drives it without changes. The same firmware runs on a PC with a physical model of the motor, so protocol, motion and protection are tested on every change before they reach the hardware.

Servo emulation The complete Control Table of an XM430-W350, checked as the real servo checks it; position, extended position and velocity mode; Sync/Bulk and Fast Sync/Bulk Read, Bus Watchdog, Reboot, Factory Reset; EEPROM area in flash
Motor control Stepper-C: current loop at 20 kHz in a zero-latency interrupt, motion profiles at 1 kHz, 16 microsteps per full step
Protection Comparators switch the gates off through the timer break input within 0.5 µs; overcurrent, bus voltage and leg faults inside the 20 kHz interrupt; a self-test of the bridge and the wiring before the first Torque Enable; temperature and watchdog
Zephyr drivers A power_stage driver class with one backend per MCU family, the motor behind Zephyr's stepper / stepper_ctrl APIs, the servo as a child node of its UART, an out-of-tree board; layer rules checked in CI
Firmware update MCUboot with an RSA-2048 signature check; serial recovery over the DYNAMIXEL bus itself
Simulation The plant model of Stepper-Lab with power stage values from ngspice, on the PC (native_sim) or on the board
Bench GUI Motion with live plots and CSV recording, the whole Control Table, the SIL test scenarios on the board with an HTML report, firmware update

Measured with the CI build of this version:

Board B-G431B-ESC1: STM32G431CB, Cortex-M4F, 170 MHz, 128 KiB flash, 32 KiB RAM
Application 77 352 B flash of the 87 712 B slot, 20 828 B RAM (simulated motor: 84 020 B)
Bootloader MCUboot, 37 148 B flash
Tests per CI run 157: 115 ztest cases, 32 SIL and integration tests, 10 fixed-point motion tests (plus 45 host tests of the GUI)

Why it is worth a look

Drop-in for the host The host sees an XM430-W350, not a stepper. An integration test drives the firmware with the official DynamixelSDK, the library under the ROS 2 driver, in the control loop of ros2_control: Sync Read and Sync Write at 100 Hz. DYNAMIXEL emulation
Real-time motor control Closed-loop microstepping current control in a 20 kHz zero-latency interrupt; a fault switches the outputs off inside that interrupt. Architecture
Tested before hardware The same firmware runs on a PC with the motor model of Stepper-Lab and power stage values from ngspice: 157 automated tests on every CI run. Simulated motor
Real Zephyr engineering Own driver class for the power stage, the motor behind Zephyr's stepper / stepper_ctrl APIs, an out-of-tree board, devicetree bindings, layer rules enforced in CI. Porting to a new MCU family
Field update over the servo bus MCUboot serial recovery with an RSA-2048 signature; the bench GUI verifies the uploaded image by its hash. Firmware update
Reproducible anywhere Pinned versions, a Docker image published for CI and GitHub Codespaces, a Dev Container, and the same VS Code tasks on Windows and Linux. Development environment

Project status

Doppelstep 0.3.0 drives a real motor and works with DYNAMIXEL Wizard 2.0: checked on the B-G431B-ESC1 with a 17HS19-2004S1 at 12 V and 24 V. Before that, every change runs on the PC against the simulated motor. Changes per release are in CHANGELOG.md; the open items are listed in Status and known limits.

  • XM430-W350 emulation over Protocol 2.0, mapped onto the motor
  • Checked with DYNAMIXEL Wizard 2.0 at the factory 57600 bps: scan, Dashboard in position, extended position and velocity mode, Limit Settings, Control Table (screenshots)
  • Factory values of the Control Table from the devicetree of the board and motor; firmware version from git in Model Information
  • Closed-loop microstepping current control with protection in the interrupt
  • Protection of the bridge and the motor: hardware comparators, self-test before the first Torque Enable, current offset and bus voltage checks
  • SIL and integration tests on native_sim, CI in a published environment image
  • MCUboot with serial recovery over the bus; bench GUI
  • Documentation website and PDF manual
  • Dead time of the power stage: 1200 ns, from an ngspice sweep with the MB1419 gate circuit
  • Effective dead time and current at rest measured on the board without a current probe: 1.05 µs at 24 V, 1.4 µs at 12 V; ripple below the ADC resolution (Measurements with MCUViewer)
  • Dead time measured on the board with an oscilloscope (bring-up step 1)
  • Checked on the board with the simulated motor: all 20 GUI test scenarios, fast loop 37 µs of 50 µs, watchdog, firmware update over the bus
  • Checked with a real motor (17HS19-2004S1, 12 V and 24 V): all 20 GUI test scenarios in three runs, hardware comparators, 2 minutes of moves at 1.5 A
  • Self-test on the board: no supply, open coil, no motor, coil on the wrong legs, swapped coils (test record)
  • Rest of the hardware checklist with the motor: vibration at rest (check 16)
  • Lost steps reported (the motor has no encoder)
  • PWM Limit applied (a duty limit in Stepper-C)
  • Velocity PI / Position PID gains of the Control Table: with an encoder
  • Temperature sensor (power stage NTC) and overheating trip
  • Single-wire TTL bus shared with real DYNAMIXEL servos

Quick start

No hardware needed. In the browser:

Open in GitHub Codespaces

bash scripts/run-tests.sh          # firmware on native_sim + 32 SIL and integration tests

Or on your PC, with Docker and Git:

git clone https://github.com/SystemFromScratch/sfs-doppelstep.git doppelstep
cd doppelstep
docker compose build                                         # toolchain image
docker compose run --rm zephyr bash scripts/west-init.sh     # Zephyr and the libraries
docker compose run --rm zephyr bash scripts/run-tests.sh     # firmware + SIL and integration tests

Then run the simulated servo and move it from the PC, the way a robot controller would:

docker compose run --rm zephyr west build -b native_sim/native/64 -s app -d build-native
docker compose run --rm -p 5555:5555 zephyr python3 tools/sim/run_native.py run --tcp 5555
python tools/sim/dxl_smoke_test.py --tcp localhost:5555      # second terminal

Prebuilt firmware

Every release carries the board images, built and tested by the release pipeline: …-merged.hex (MCUboot and the application) for the first flashing through the ST-LINK, the signed …-app.signed.bin for an update over the bus with the GUI, the same pair with the simulated motor (…-sim-motor.*), the PDF manual and SHA256SUMS. The images are signed with the public development key of MCUboot: for a product, build from source with your own key (Firmware update).

Building

Target Command
Board, real motor west build -p always --sysbuild -b b_g431b_esc1 -s app -d build
Board, simulated motor the same, plus -- -DEXTRA_DTC_OVERLAY_FILE=sim.overlay
PC (native_sim) west build -b native_sim/native/64 -s app -d build-native
Flash MCUboot and the signed application west flash -d build -r openocd

Run west in the container (docker compose run --rm zephyr …), in the Dev Container or in a codespace; the VS Code tasks do the same on Windows and Linux. Before a real motor turns, wire it as shown in Hardware and bring-up and follow its bring-up checklist.

Project structure

app/                    Zephyr application: threads, queues, register mapping, board overlays
drivers/                power_stage/ (STM32, simulation), motor/ (Stepper-C), x430/ (servo)
include/, dts/          public driver APIs, devicetree bindings
boards/                 out-of-tree board B-G431B-ESC1
modules/                build glue of Stepper-C, the X430 emulator and Stepper-Lab
tests/                  ztest suites, pytest SIL and integration tests
tools/                  bench GUI, native_sim launcher, documentation tools
scripts/                CI, tests, layer check, release packaging, host GDB servers
docs/                   documentation website and PDF manual sources
west.yml                pinned Zephyr and libraries
CHANGELOG.md            changes of every release

Documentation

The website at systemfromscratch.github.io/sfs-doppelstep covers the idea and the technology stack, the hardware with the motor wiring, the DYNAMIXEL emulation, configuration, architecture, the simulated motor, firmware update, porting, the development environment, tests and the bench GUI. The same content is available as a printable PDF manual.

python -m pip install -r requirements.txt
mkdocs serve                                  # live preview
python tools/docs/build_manual.py             # PDF manual
python tools/docs/diagrams.py                 # regenerate the diagrams

Author

Anton Vynohradov — Embedded Systems Engineer, Secure Product Architect, founder of SystemFromScratch®: secure embedded systems and compliance-ready engineering, from concept to certification-ready product. systemfromscratch.com · GitHub · LinkedIn · ORCID · contact@systemfromscratch.com

Need firmware like this for your product, Zephyr drivers, a bootloader or CRA readiness? Get in touch.

Contributing

Issues and pull requests are welcome, measurements from a real B-G431B-ESC1 especially. A change must keep the builds free of warnings, pass the layer check and all tests (scripts/ci.sh) and keep the documentation in sync. See CONTRIBUTING.md; security issues: SECURITY.md.

License

Copyright © 2026 Anton Vynohradov. Licensed under the Apache License 2.0. Zephyr RTOS, MCUboot, the libraries and the tools Doppelstep uses come under their own licenses (License).

SystemFromScratch® is a registered trademark. The Apache License 2.0 grants no rights to use the SystemFromScratch® name or logo; they may not be used to endorse or promote products derived from Doppelstep without prior written permission. DYNAMIXEL and ROBOTIS are trademarks of ROBOTIS Co., Ltd.; STM32 is a registered trademark of STMicroelectronics International N.V. Doppelstep is not affiliated with or endorsed by them.

References

About

Zephyr RTOS firmware that turns a stepper motor and an STM32 B-G431B-ESC1 board into a DYNAMIXEL XM430 smart servo for ROS 2: closed-loop microstepping at 20 kHz, MCUboot, tested on a PC with a simulated motor.

Topics

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages