Motor control for escooter (based on Xiaomi M365)

Hello !

First, I want to congratulate all members participating for this project. It’s really awesome.
I am working on different projects to make open-source electric scooters : https://github.com/Koxx3/minimo/blob/master/README.md

I am currently trying to improve the behavior of existing controllers… but with SimpleFoc library, I am wondering if I could create my own electric motor controller.

My goal is to use up to 20S batteries (84V fully charged), so I know I’ll need a strong hardware for that. But I’ll keep that for later.

For now, I’d like to replace a Xiaomi M365 firmware. Why this hardware ?
It use a STM32F103 microcontroller, I has a strong power electronic and can be easily customized (talking about the hardware part).

What inside a Xiaomi controller board beside the microcontroller ?

  • 3 low side current shunt (with LMV324 amplifier)
  • 3 resistance voltage dividers for over-intensity protection on each motor phase
  • 3 independant MOSFET drivers
  • 6 MOSFETs
  • 6 PWM directly connected to the drivers.
  • temperature sensors and few other things
  • a voltage divider for battery level mesurment
  • a good disipator (at least enough for the 350W original motor)
  • 1 half-duplex UART and a 1 full duplex UART

the motor has 3 hall sensors

What I would like to achieve : a torque and velocity controlled FOC loop with this hardware.

If I can do that, I can try to build a strong electronic to deliver the max power I would like to have.

So … I’ve seen the @David_Gonzalez project, and I’d like to know what is currently missing to achieve my goal.

For all the “logic” part, I have no trouble developing it.

If I understood correctly, the SimpleFOC library is not currently able to take the current shunt input. Is that correct ?
What else is missing for my project ?

Thanks again for this magical project.

Here is the retro-engineering schematics on this controller…
https://github.com/Koxx3/minimo/blob/master/documents/Driver%20V2.1%20M365.pdf

Are the stlink swdio and swclk broken out too? Looks like an interesting board - I’d be interested to see what you make of it. We’ve certainly got some of the parts working on things similar to that board. You are right that current sensing is still being worked out. Antun’s next version of SimpleFOC board has inline shunts where as david has low side. Last time I spoke to them, sampling current fast enough seemed to be the main problem.

Does your board look like this replacement part on ebay? At ~£25 that could be useful for a few people here if it can be made to work nicely!

Thanks for the schematic PDF. It’s interesting to see what drivers and amps are being used.

Have you flashed any custom code onto this board yet?

I’ve tested 6PWM on an stm32g413 and the storm32 has an stm32f107 I think but that is 3PWM.

Owen

1 Like

yes, STLink can be connected :wink:

and yes, you can use “clones” without issues at 20$/€. The latest official Xiaomi board (v3, not cloned yet) can simply support higher voltage/current wihout modification.

v2.1 => 16S without modification
V3.0 => 18-19S (same hardware but reinforced)

nothing flashed yet. personnaly, I am more a “ESP pro”. My friend worked a lot on the xiaomi controller and will bring it home very soon.

It’s a good news for the current sensing integration !
@David_Gonzalez seems to read the current at a good refresh rate on his latests tests. I hope it will be achieved on any supported microcontroller included in the library :wink:

It might be worth talking to @Alex_Ezzat and his team. They are doing a 4KW solar car! I guess the V3 hardware will be about 1KW?

awesome ! we’ll contact him :wink:

@Francois_DESLANDES
Did you try the xiaomi with simplefoc? There are a bunch of people looking for more powerful boards