Adding Position Control To An Open Source Brushless Motor Driver

Brushless motors are everywhere now. From RC planes to CNC machines, if you need a lot of power to spin something really fast, you’re probably going to use a brushless motor. A brushless motor requires a motor controller, and for most of us, this means cheap Electronic Speed Controllers (ESC) from a warehouse in China. [Ben] had a better idea: build his own ESC. He’s been working on this project for a while, and he’s polishing the design to implement a very cool feature – position control.

We’ve seen [Ben]’s work on his custom, homebrew ESC before. It is, by any measure, a work of art. It’s capable of driving brushless and brushed motors with a powerful STM32F4 microcontroller running ChibiOS that’s able to communicate with other microcontrollers through I2C, UART, and CAN bus. If you want to build anything with a motor – from a CNC machine to an RC helicopter to an electric long board – this is the motor controller for you.

[Ben]’s latest update considers position encoders. Knowing how fast a motor is turning is very important to knowing how fast a wheel is turning, how much torque the motor is generating, and an awesome step in building the finest motor controller ever made.

Like the last update, [Ben] demonstrates the great control program written for this ESC. This GUI programs the microcontroller on the controller, with protection from high and low voltages and currents, high RPMs, duty cycle changes, and support for regenerative braking.

Thanks [Dudelbert] for sending this one in.

29 thoughts on “Adding Position Control To An Open Source Brushless Motor Driver

      1. As I have said – “only phase current sensing?” I can see the shunts in the schematic, but no voltage dividers/comparators for measuring the BEMF voltage, which is why I was puzzled how it can resolve position only from current…

        1. @AKA I might be wrong, but I’m guessing you’re thinking backwards? It doesn’t “resolve position from current”, it *uses* current to enforce position. The shunts tell you roughly where you are, then you use cunning analogue (pwm) blending (from vector maths) to cause the stator magnets to want to sit in the position you tell it.

  1. Those AMT encoders are awful. I have a bunch of them and they just dont perform as well as the optical encoders from agilent/usdigital. They actually have some position delay from the interpolation going on inside of them which causes issues with tuning and running of servos. I had tried one on the Y axis servo of my laser cutter and it just would not tune, replaced it with an old HP HEDS-9000 series and it tuned right away.

      1. The problem with steppers are lost steps. So the accuracy depends on the load and you do not see if steps are lost. There for a closed loop system like this has strong advantages.

      2. pff yourself. If you want accuracy, you use servo motors and optical encoders. They are precision devices that allow you to position the motor to within +/-1 encoder count which could be 8000 counts per revolution.

        A stepper motor’s accuracy is dependent on how accurately the laminations of the core are stamped, the extruded motor frame, positioning of the magnets, and placement of the coils.

        1. Right, but pff again. 8000 counts is child’s play.
          I work with 18 bit encoders (262144 counts) and 31 bit (2 million+) Sin/Cos encoders on industrial servos.
          Also resolver systems can have extremely high equivalent resolution depending on your evaluation electronics.

  2. This is great. I’ve looked at the AMS magnetic sensor with an idea of doing the same thing. Having a closed-loop spindle motor on my CNC mill would be great for tapping threads in metal.

  3. PIC, TI and ST have a bunch of eval boards for driving BLDC, PMSM motors with hall effect or FOC Clarke / Park transforms. The ST ones are a bit more interesting since they make nucleo compatible ones.

    If ST’s tool chain got a nice simple installer that loaded up everything including settingup OpenOCD, so that the developer just has to plugin an STLink2 and start debugging on a nucleo board then they’d be on to something big.

    Nice work on your project! Looking on your site, I especially like your work with video overlays using OpenCV. I haven’t seen a lot of Chibios stuff before so thanks for documenting it.

    1. Yes, there are. Strangely enough they sell out quite fast tho where ever they pop up. Lately some electric skateboard companys have picked them up and sell them in theyr shops too, and there is a guy in germany who has a website and sells them made by a professional company: http://www.esk8.de/shop

Leave a Reply to AKA the ACancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.