# My STM32 controller software



## catphish (Jul 30, 2017)

For the last couple of years I've been intermittently learning about induction motors and designing my own controller. It it my hope to eventually build an electric vehicle, but my lack of mechanical ability has so far left me focusing purely on the electronics and software side of things.

Anyway, I wanted to post for a couple of reasons, firstly to thank Mr MPaulHolmes whose similar software provided me with some much needed pointers!

Also to post my progress and designs in case anyone else is working on anything similar and is interested.

My design is based around the following devices:
* STM32 microcontroller
* UCC21520 isolated drivers
* Infineon discreet or hex IGBTs
* ACS hall effect current sensors

Hardware schematic: https://nutty.tk/inverter3.pdf
Software: https://github.com/catphish/stm32_vfd/blob/master/main.c
My very low power test setup: https://imgur.com/a/IR173Ng

I have found the STM32 to be of particular interest in doing this as its powerful ADC, PWM, and floating point math capabilities have been an enourmous improvement compared to my previous implementations.

So far I've only tested this setup with extremely low power (250W) motors, however it is my hope that the design will scale nicely.

I don't know if this work will be useful to anyone, but it's been a fun project, and I do hope at some point I can take on a simple mechanical project like a buggy or go-kart to try out my design on a larger scale.


----------



## jhuebner (Apr 30, 2010)

I rather like your current control scheme. So no FOC here, just regulating the total current, right?


----------



## catphish (Jul 30, 2017)

jhuebner said:


> So no FOC here, just regulating the total current, right?


Thanks! I did a lot of testing with FOC but ultimately I failed to achieve better results than I can with this simple current regulation scheme.

Thank also for all the great work you have published on the subject. Your project has been an inspiration for me.


----------



## boznz (Aug 22, 2018)

Thanks for posting.

Quite easy to understand, the micro is way over specified but a dollar or so extra on the bill of materials for a controller is nothing so why not get the best with plenty of headroom.

It looks like your driving all the current to the motor through the ACS725 chip on the PCB which would not scale much over 15A so I assume you would have to do something else or revert to a current shunt / differential amplifier for a EV capable AC motor, you should also include the scope output of the drivers to show the waveforms generated.

Keep up the good work, its really motivating to experiment and get something working with your own design.


----------

