Tutorials — Learning Through 48 Examples¶
XM10's features are covered through 48 progressively structured examples. Each folder contains source code and a README, and every README follows the same format: Goal → Prerequisites → Key Code → Experiments → Next Steps + Common Mistakes. The introductory examples (Ex.09 and below) are designed to complete in under 30 minutes. Control and advanced examples (Ex.11 and above) may take anywhere from 45 minutes to several weeks, depending on difficulty.
The full example catalog is at examples/README.md. If you get stuck, check the "Common Mistakes" section at the bottom of each README first. Claude Code users can simply say "Ex.XX isn't working" and the example-helper skill will respond with the relevant common mistakes and troubleshooting documentation.
Recommended Learning Paths¶
Choose the path that matches your current level.
| Path | Target Audience | Sequence | Estimated Time |
|---|---|---|---|
| Beginner | New to embedded systems — just get it working | Ex.00 → 01 → 04 → 07 → 09 → 11 | About 3 hours |
| Intermediate | Familiar with embedded basics — communication, real-time control | Ex.02 → 05b → 08 → 09 → 12 → 14 → 18 | About 1 week (1–2 hours/day self-study) |
| Advanced | Control algorithms + hands-on AI design | Ex.03 → 09 → 15 → 16 → 17 → 19 → 20+ | About one semester (1–2 weeks per example from Ex.20+) |
| Physical AI Applications | Rehabilitation, learning-based control, etc. | Ex.21 → 31 → 32 → 33 → 36 | Self-directed (difficulty: ⭐⭐⭐) |
Estimated times are for typical users. The "one semester" estimate for the Advanced path assumes spending 1–2 weeks per example for in-depth study. A quick run-through is possible in a few days, but following the variant experiments and cited papers takes significantly longer.
Sample 16-Week Course Schedule¶
A suggested semester schedule for university courses. Adjust freely based on student background and board delivery timing.
| Week | Topic | Examples | Assignment / Deliverable |
|---|---|---|---|
| 1 | Environment setup + first build | Ex.00 | Video demo of board LED turning on |
| 2 | Button + LED + state machine | Ex.01 → 02 → 03 | Add 4 custom LED modes of your own |
| 3 | External GPIO + ADC | Ex.04 → 05 → 05a | Control 4 LEDs using an external switch |
| 4 | Multi-channel ADC + safety switch | Ex.05b → 05c → 06 | Demo simultaneous measurement of 8 FSR channels |
| 5 | USB serial communication | Ex.07 → 08 | Real-time sensor monitoring via PC terminal |
| 6 | Binary streaming + xm10 tool | Ex.09 | Capture 4-channel graph + analysis report |
| 7 | USB-CDC data capture + storage | Ex.09 + xm10 tool | Stream 10 minutes of data → save as .xmlog → export CSV for analysis |
| 8 | Midterm / Mini Project 1 | (open) | "My board, my data" mini project presentation |
| 9 | KIT H10 exoskeleton basic modes | Ex.11 → 12 → 13 | Comparison video of 3 operating modes |
| 10 | PD real-time control | Ex.14 | Tune your own PD gains + compare step responses |
| 11 | Debugging + memory patterns | Ex.18 → 19 | Health Dashboard result analysis |
| 12 | Gait intent recognition + Tiny AI | Ex.16 → 17 | 7-phase FSM demo + intent signal graph |
| 13 | Impedance + transparent mode | Ex.20 → 21 | Compare virtual spring stiffness variations |
| 14 | Gait phase adaptive torque | Ex.23 → 25 | Measure gait phase estimation accuracy |
| 15 | Learning / adaptive control | Ex.26 or 27 | ILC convergence curve or MRAC adaptive trajectory |
| 16 | Final Project | (open application) | Team project presentation + GitHub submission |
Teaching tips: - The first 2 weeks are where students struggle most with environment setup. Schedule dedicated time for TA or instructor-led check-ins. - The Week 8 mini project is effective for maintaining motivation. Run it as an open-ended prompt like "build anything using what you've learned from Ex.05–09." - For Week 16, teams of 3–4 are recommended. Teams that dive deep into the Physical AI application track (Ex.21, 31, 32, 33) at the end tend to produce the strongest final projects.
Examples not in this schedule (Ex.05d, 10, 15, 22, 24, 28–36, 38–44) are naturally left for self-directed study or a follow-on course in the next semester.
Part 0 — Board Verification¶
| Example | Title | Difficulty | What You Learn |
|---|---|---|---|
| 00 | Board smoke test | ⭐ | State machine + LED + USB serial — no external hardware required |
Part 1 — XM10 Basic I/O Control¶
From fundamental I/O to state-based programming (FSM) — the core of embedded control.
Button & LED (Ex.01 ~ 03)¶
| Example | Title | Difficulty | What You Learn |
|---|---|---|---|
| 01 | Button + LED basics | ⭐ | Poll button state and control LEDs |
| 02 | Events + special effects | ⭐⭐ | Detect click events, single-shot LED blink |
| 03 | State machine (FSM) | ⭐⭐ | Long-press mode switching, per-state behavior separation |
External I/O — GPIO & ADC (Ex.04 ~ 06)¶
| Example | Title | Difficulty | What You Learn |
|---|---|---|---|
| 04 | External digital control | ⭐⭐ | External switch/LED on expansion port |
| 05 | Analog sensor introduction | ⭐⭐ | Voltage measurement on fixed ADC pins |
| 05a | DIO→ADC dynamic switching | ⭐⭐ | Read FSR by switching a DIO pin to ADC mode |
| 05b | FSR 8-channel batch read | ⭐⭐ | 8 channels + resolution configuration |
| 05c | Mixed ADC 12-channel | ⭐⭐⭐ | Fixed 4 + DIO→ADC 8 |
| 05d | DIO/ADC hybrid | ⭐⭐⭐ | Digital and analog simultaneously |
| 06 | Safety state machine | ⭐⭐ | Limit-switch-based FSM |
Recommended ADC series order: Ex.05 → 05a → 05b → 05c → 05d (progressive difficulty)
Part 2 — USB Communication¶
Exchange real-time messages with a PC and stream data. Essential for debugging and data collection. On Rev 2.0 you can also send structs with field names and units, or save data to a USB memory stick.
Note: The USB serial (CDC) port can only be opened by one program at a time. For Ex.07–09 and Ex.44, make sure only one of a serial terminal, PhAI Studio or the
xm10tool is open. Running them simultaneously will cause a conflict.
USB Serial Communication — Ex.07 ~ 09¶
| Example | Title | Difficulty | What You Learn |
|---|---|---|---|
| 07 | USB serial basics | ⭐⭐ | Send text messages to a PC terminal |
| 08 | Sensor data monitoring | ⭐⭐ | Real-time sprintf output of sensor data |
| 09 | High-speed binary streaming | ⭐⭐⭐ | PhAI V2.2 protocol, 1 kHz transmission (view the user channel with the xm10 tool) |
To save and analyze a captured stream on the PC, use PhAI Studio recording or the
xm10tool in the repo —python pc-data-tool/xm10.py recvshows a live graph while the raw stream is saved as.xmlog, thenexportpulls out CSV (guide). PhAI Studio is still under development, so for now use thexm10tool to view and save your own (custom) data structs, such as the ones you send withXM_SendUsbDataWithId. (On Rev 2.0 you can also save directly to a USB memory stick — see Save Data to a USB Memory Stick. On Rev 1.1, on-board file storage was removed in v2.5.0 and is not supported.)
Struct Logging — Ex.44¶
| Example | Title | Difficulty | What You Learn |
|---|---|---|---|
| 44 | Send a struct to the PC with field names, units and types 🛑 Rev 2.0 only | ⭐⭐⭐ | Register a struct once and its field names, units and types travel with the values — integers, bool, arrays, scale factors, and a different rate per struct (view it with the xm10 tool) |
Saving to a USB Memory Stick — Ex.10 · 34¶
There is only one USB-C port. While a USB memory stick is plugged in, PhAI Studio, the
xm10tool and firmware upload over USB are unavailable. Unplug the stick and connect the PC when the save is finished. (not yet confirmed on the board)
| Example | Title | Difficulty | What You Learn |
|---|---|---|---|
| 10 | Save values to a USB memory stick 🛑 Rev 2.0 only | ⭐⭐⭐ | Start and stop saving with a button, save one struct at 100 Hz, insert markers, check missing samples in the statistics |
| 34 | Save H10 gait data to a USB memory stick at 1 kHz 🛑 Rev 2.0 only | ⭐⭐⭐ | Save the H10 gait data (96 B) every 1 ms — body data, checking missing samples |
Part 3 — KIT H10 Exoskeleton Basic Modes¶
The three fundamental operating modes of the KIT H10 exoskeleton robot.
| Example | Title | Difficulty | What You Learn |
|---|---|---|---|
| 11 | Passive Mode | ⭐⭐⭐ | Automatic reciprocal motion using predefined movement commands |
| 12 | Active Assist Mode | ⭐⭐⭐ | Detect user intent and apply assistive torque |
| 13 | Resistive Mode | ⭐⭐ | Built-in H10 mode — resistance sensation like walking through water |
Part 4 — Control Algorithm Fundamentals¶
Your first hands-on control algorithms.
| Example | Title | Difficulty | What You Learn |
|---|---|---|---|
| 14 | PD real-time torque control | ⭐⭐⭐ | PD formula, discrete differentiation, torque saturation |
| 15 | Inverted pendulum gait assist | ⭐⭐⭐ | Gravity compensation MgL·sin(θ) + Lyapunov stability |
| 16 | Tiny AI sensor fusion | ⭐⭐⭐ | On-board 3-layer neural network inference |
| 17 | Gait intent recognition (FSM) | ⭐⭐⭐ | 7-phase gait state machine + per-phase torque |
| 18 | System debug monitor | ⭐⭐ | Loop execution time measurement, status dashboard |
| 19 | Memory-aware design | ⭐⭐⭐ | Ring buffer, pool allocator, malloc-free implementation |
Part 5 — Advanced Control Algorithms¶
Interaction dynamics, transparent mode, and gait-phase-based control — the canonical techniques of exoskeleton control.
| Example | Title | Difficulty | What You Learn |
|---|---|---|---|
| 20 | Hogan impedance control | ⭐⭐⭐ | Virtual spring-damper interaction (Hogan 1985) |
| 21 | Gravity compensation (transparent mode) | ⭐⭐⭐ | Mgl·sin(θ) + friction compensation + gradual activation |
| 22 | CPG adaptive oscillator | ⭐⭐⭐ | Automatic gait rhythm synchronization (Ronsse 2011) |
| 23 | Gait phase adaptive torque | ⭐⭐⭐ | 4-segment sinusoidal torque profile (Quinlivan 2017) |
| 24 | Virtual constraint (HZD) | ⭐⭐⭐ | 5th-order Bézier trajectory (Westervelt 2003) |
| 25 | Stance-phase variable stiffness | ⭐⭐⭐ | Smooth stance/swing transition (Collins 2015) |
Part 6 — Learning + Adaptive Control¶
Control that learns from each gait cycle or automatically adapts to changes in the user.
| Example | Title | Difficulty | What You Learn |
|---|---|---|---|
| 26 | Iterative Learning Control (ILC) | ⭐⭐⭐ | Learn torque profile from each cycle (Emken 2007) |
| 27 | Model Reference Adaptive Control | ⭐⭐⭐ | Online gain adaptation via MIT Rule (Slotine 1991) |
| 28 | Admittance control | ⭐⭐⭐ | Force input → position output (the dual of impedance, Keemink 2018) |
| 29 | Left/right coordination control | ⭐⭐⭐ | Anti-phase symmetry + affected-side reinforcement (rehabilitation) |
| 30 | FF + FB hybrid control | ⭐⭐⭐ | Model-based feedforward compensation + PD feedback |
Part 7 — Physical AI Applications¶
The key stages of Physical AI — transparency → intent detection → learning → autonomous replay.
| Example | Title | Difficulty | What You Learn |
|---|---|---|---|
| 31 | Disturbance Observer (DOB) | ⭐⭐⭐ | Estimate remaining disturbances for true transparent mode |
| 32 | Gait intent via foot contact | ⭐⭐⭐ | Gait phase estimation from heel strike events |
| 33 | Kinesthetic teaching + replay | ⭐⭐⭐ | Human demonstrates by hand → board replays the motion |
| 35 | Multi-layer transparent control | ⭐⭐⭐ | Real-time switching between transparent / wall / left-right coupling modes |
| 36 | On-device kinesthetic learning 🛑 Rev 2.0 only | ⭐⭐⭐ | Train a small neural network on-board → replay with LQR — Internal Flash UserNV API is supported on Rev 2.0 only |
| 38 | Periodic background task | ⭐⭐ | Offload low-frequency auxiliary work, minimize control loop jitter |
| 39 | Task lifecycle management | ⭐⭐⭐ | Create, suspend, and terminate tasks; RTOS task state machine pattern |
| 40 | EMG proportional assist 🛑 Rev 2.0 only | ⭐⭐⭐⭐ | External 4-channel ADC EMG → envelope → proportional torque, button calibration + 0xF0 streaming to the xm10 tool (EMG competition foundation) |
| 41 | IMU Hub attitude dashboard 🛑 Rev 2.0 only | ⭐⭐⭐ | Up to 6 IMUs' quaternion → Euler (roll/pitch/yaw) conversion, auto connection detection + 0xF0 18-channel (50Hz) streaming to the xm10 tool (CAN-FD sensor hub) |
| 42 | EMG Hub biofeedback 🛑 Rev 2.0 only | ⭐⭐⭐ | Receive hub-processed muscle activation (envelope/MVC%), button calibration + LED feedback and a 0xF0 4-channel (50Hz) live view in the xm10 tool (CAN-FD sensor hub, no motor drive) |
| 43 | Two boards talking over serial 🛑 Rev 2.0 only | ⭐⭐ | Connect two XM10s directly over the External UART (PD5/PD6) — copy only inside the callback, find frame boundaries with a byte state machine |
The IMU Hub and EMG Hub are modules under internal development. To use them, please contact us at https://huphailab.com/contact.
Trying an Example¶
- Open the
.cfile for the example you want from theexamples/folder. - Copy its entire contents into
XM_Apps/Control_Task/control_task.c. - Build in STM32CubeIDE and upload to the XM10.
- Follow the example's README to verify the behavior.
If this is your first build or flash: First Build & Run · For AI-guided setup: Getting Started with Claude Code