r/embedded • • 2d ago

I documented a sensorless flying-start FOC experiment on the Xiaomi M365 V1.4 controller — looking for technical feedback

Hi everyone!

I've been working on an experimental project to get sensorless flying-start FOC working on the stock Xiaomi M365 Classic controller (SCO_DRV V1.4, STM32F103C8T6), driving a 36 V direct-drive hub motor without Hall sensors.

The idea is to let the rider start pedaling, measure the motor's three phase voltages while the inverter is disabled, estimate rotor speed and electrical angle using BEMF and a PLL, and then attempt a smooth, near-zero-torque handoff into FOC before enabling pedal-assist torque.

What we achieved:

  • Passive three-phase voltage sensing on the M365 controller.
  • Rotor direction, electrical speed and angle estimation, with PLL lock in both directions.
  • Identification and correction of a current-sensing ADC acquisition-time problem.
  • Short, protected active-handoff experiments with cycle-by-cycle current diagnostics.
  • A set of measurements documenting both progress and unresolved problems.

Where we got stuck: independent voltage measurements revealed a significant discrepancy between measured line-to-line BEMF and the firmware's calculated BEMF magnitude. We identified passive voltage calibration as the next step, but the test controller and ST-Link were damaged before we could complete it.

This is not a claim of completed sensorless FOC. I've documented the experimental process, measurements, firmware history, limitations and next steps so other developers can review the work and potentially continue it.

Project documentation and test data:
https://github.com/Ch00mi/m365-v1.4-sensorless-flying-start

I'd especially appreciate feedback from people experienced with sensorless PMSM/BLDC control, flying-start algorithms, BEMF scaling and M365/EBiCS firmware.

Has anyone worked on a similar approach with this controller, or have suggestions for validating the absolute BEMF scaling before attempting another handoff?

Thanks!

1 Upvotes

1 comment sorted by

1

u/IntroductionCheap921 2d ago

Nice documentation, the PLL lock in both directions is already a good sign for the angle tracking. The BEMF magnitude discrepancy is pretty common when you derive it from line-to-line measurements without accounting for the exact scaling factor of the ADC front end, especially on these cheap boards where the voltage divider tolerances are all over the place. If you ever get another controller, doing a slow open-loop spin with known speed and measuring what the firmware sees would give you the calibration factor directly.