This project develops a repeatable way to characterize a commercial actuator and verify the safety algorithms intended to control it. Bench characterization, model validation and real-time code generation are working; the STM32 hardware-in-the-loop (HIL) setup is the next stage.
Testbench concept
A PC runs pytest-based experiments, communicates over CAN and records results against the requirements. For HIL, one STM32 will run generated code from the Simulink actuator model and respond on CAN like the real actuator. A second STM32 will run the safety algorithms under test. The physical RMD-L-7015 actuator can be connected to the same bus for comparison.

The real motor's measured behavior informs the model, so the same test suite can eventually run against both the physical actuator and its emulated counterpart. The model also feeds the rotary double inverted pendulum simulation.
Characterization and model validation
Bench tests measure friction and cogging torque, record current-, speed- and position-mode step responses, and check communication-loss behavior. A dq-frame PMSM model with the driver's cascaded control loops replays the measured steps for comparison. An 18-harmonic cogging model is fitted from slow sweeps; the one-per-electrical-turn component changes across power cycles, so the sweeps and step recordings are taken in the same power-up.

Separate recordings at other amplitudes check the fit against hardware rather than only the tuning data. On those recordings, position-mode angle RMS error is 0.2% of the measured range; current-mode angle error is 13%. Hardware repeatability is used as a noise-floor reference. Remaining gaps include the detent-dependent current-mode final angle, a slower simulated position-hold current ripple, and uncertainty in the speed-loop and position integral gain units. Absolute torque is uncertain because the motor torque constant has not been measured.
Real-time model and code generation
A reduced 5 kHz model uses a two-state electrical current loop and stick-slip friction. Compared with the full model, angle and speed RMS differences are within 1.5% of the measured ranges. MATLAB Coder generates single-precision C for the Cortex-M4F; integration and timing on the STM32 are still to be done.

Verification workflow
| Stage | Purpose |
|---|---|
| Requirements | Link requirements and hazards to pytest cases and test results; identify missing tests in a traceability matrix. |
| Characterize | Measure friction, cogging, step responses and communication-loss behavior. |
| Hardware tests | Requirement-linked CAN tests cover communication, stop commands, command loss and step responses; motion tests require explicit opt-in. |
| Model | Compare Simulink responses with hardware data, validate the reduced real-time model and generate C. |
| HIL | Next, run the model on one STM32 and the algorithms under test on another. |
| Fault injection | Extend automated HIL runs to verify fault handling and safety requirements. |
Communication-loss bench measurements showed that the motor continued moving without protection; with a 200 ms protection timeout enabled, it stopped about 0.2 seconds after the last frame. The reported position can shift by a turn after a cutoff and needs re-referencing.
The source, test requirements and measurement plots are available on GitHub. The bench is for development and learning, not a certified safety system.


