Blog

Running Four Brushless Motors With A Single Pi Pico | Hackaday

Sometimes, you have to drive four motors, and you need to do so with a certain level of control. You could throw a lot of parts at the problem, but you don’t necessarily have to. As [Shaun Crampton] demonstrates, you can run four brushless DC motors with a single Pi Pico.

[Shaun] set about developing a brushless motor controller from scratch with the Pico, relying on its PIO hardware and the TI DRV8313 — a handy three phase motor driver. Before he knew it, he was implementing field oriented control (FOC) in MicroPython, only to find that it was a little too slow for proper motor control work. He soon switched to C for the lower overheads, and was readily driving a brushless motor with his own code. Before long, he’d implemented torque limiting and PID speed control. He was even able to optimize things to the point where he had four motors hanging off a single Pi Pico, complete with Hall sensors for feedback. Variable Dc Motor

Running Four Brushless Motors With A Single Pi Pico | Hackaday

The full story is well worth reading, as it goes from “Hello, World” all the way to the end of the project. If you’ve never experienced the joy of your own code getting a motor to spin, you might enjoy following in [Shaun’s] footsteps. Files are on GitHub for the curious.

We’ve seen a lot of motor controllers around here, many of which draw heavily from other projects online. It’s a great way to learn the basics of what is a very well established field. Meanwhile, if you’re cooking up your own project in this space, do drop us a line!

With all respect, I thought you utilised Pico as 4-1 esc, but you just use “motor drivers” so title is pretty clickbait. Got disappointed

I thought that at first too but to be fair the drivers are pretty basic, they are just 3 half bridges and you need to control pretty much everything with the microcontroller. The microcontroller will need to provide the signals to the half bridges (no different really than if you made your own half bridges circuit), the microcontroller will also need to read from the encoders and current sensors.

So most of it is done in the microcontroller with the driver just being the drive circuitry and not much more.

It’s not click bait. The DRV8313 is just a driver. It doesn’t control the motor at all. It’s only the output stage.

It is a 4-1 (sensored) ESC. He just used an integrated half-bridge chip.

It becomes obvious that the pico doesn’t have the power to drive a motor, and that it only sends the pulses over gpio pins, to basically devices that will amplify those signals to actually be able to power these motors. It’s definitely a lot cheaper (though probably less reliable) than Tesla motor controllers.

Can you get full torque on a DC motor while running it at slower speeds?

Yes, I measured the torque by stringing bean cans from a motor and got the rated torque for three motors I was using

Why not? The pi is controlling AC motors, but if you program it for dc motors, all you’d have to do is create a pulse width based program, add a capacitor on the gpio pin output, and have a device amplify the voltage to the voltage the motor accepts. For dc motors, it makes no sense, but it’s basically the same as replacing the pi with a potentiometer.

Is this actually FOC? Instead of having a feedback loop for the magnetic field current, it just drives a sinusoidal PWM voltage 90° ahead of rotor position. This will result in an actual torque angle of less than 90° depending on coil inductance and rotational speed.

This will work, and is certainly a usable approach. But I think it is not what is usually called FOC, and I expect the efficiency to be significantly worse.

Yes, think you are right 🤦‍♂️ got myself confused about where the line was.

What I have works great with the motors I have. Perhaps I’m just working at low enough speed that it doesn’t matter.

As I noted in three blog, I was inspired by SimpleFOC here. The main “innovation” is probably the PIO and DMA stuff to get the most out of a Pico.

I think for many small motors it will be almost equivalent to “true” FOC – if you are interested and have a 2-channel oscilloscope, you can make a basic measurement circuit for it:

1. Connect three 1 kohm resistors together, one end at each phase and the other ends connected together.

2. Take a ferrite ring and put one of the phase wires through it.

3. Connect first oscilloscope channel with tip on the phase with the ring, and ground to the middle point of the 1 kohm resistors.

4. Put second probe ground wire through the ferrite core and connect it to the tip of probe.

This way you can measure the voltage and current on the phase. The voltage will be back-EMF voltage of the motor, which is always 90 degrees ahead of rotor position. The current will be aligned with the magnetic field. The phase difference between voltage and current tells the efficiency, for well-trimmed FOC the difference would be less than 10 degrees.

It is possible to do a full FoC+SVM on RP2040, at a 125us PWM cycle. Barely enough for one motor, but certainly possible, I built such a controller.

Of course, everything is in fixed point.

This is AKA “open loop FOC”. If you take the resistance, inductance and k-value of the motor into consideration it can work as well as (or even better) than closed-loop FOC with current feedback. I’ve used this to drive motors up to 30k RPM

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.

Running Four Brushless Motors With A Single Pi Pico | Hackaday

Three Phase Motor Driver By using our website and services, you expressly agree to the placement of our performance, functionality and advertising cookies. Learn more