High precision, direct drive BLDC controller for robotics?

First, thanks for all your hard work, this project looks really great!

I want to check in on whether SimpleFOC would be appropriate for my application.

I’m currently exploring options to direct-drive 4 outrunner BLDC Gimbal motors (Smallest: 7pp, 16V & 1.65A and largest: 21pp, 24V & 2.8A), and I want to uncover the maximum possible angular repeatability for this hardware.

I’m moving very small loads, a very small distance and would like to move quickly, but moving precisely is more important.

I’m currently working with Renesas IPS2200 inductive position sensor with an incremental encoder coil design. These devices provide different levels of repeatability, depending on PCB coil & target design. We have confirmed that our IPS2200 coil design does indeed seem to produce high accuracy for angular readings. It’s analog, but so far, it looks like we’re getting at least equivalent to 20k CPR, and anticipate more from larger coils.

Here be the initial questions:

  1. Will the B-G431B-ESC1 really work for a precision positioning application?

  2. Is there a different driver that would be more likely to deliver high precision angular control at (relatively) low power?

  3. Will I need to implement my own SIN/COS Encoder for this system?

  4. How many motors could a single RP2040 reasonably control with this library?

  5. I’m using limit switches to set end stops for motion, is there an existing homing/calibration step that will set encoder offsets automatically?


Welcome, and hope you find what you are looking for. Wish you success with your project.

General comment, the accuracy is not board dependent. It’s sensor+motor combination dependent. The board only receives the signals and sends the commands to the motor. The better the sensor and the better the motor, the better the control loop is. I’m sure there must be a really bad, poorly designed board that would create problems, but generally, all commercial boards are quite decent. The key here is to find a good and fast MCU to execute your logic.

  1. Probably yes.
  2. Probably no. Not because B-G431B-ESC1 is so awesome but because this is not exactly board dependent that much.
  3. Never worked with that one, perhaps you need to talk to @runger and / or @Antun_Skuric
  4. One.
  5. No.

Let’s see if anyone else has any input on this.


Thanks for the quick response and kind words Valentine!

That’s really helpful.

I’ll be sure to check in as I dig deeper.



Another factor is the MCU itself and the PWM resolution.

The first thing that comes to my mind for high speed and precision for small distances is a hard drive actuator.

Well, that’s why he needs a fast MCU. G431 is as good as it gets before we get into the H classes.

The PWM, 20kHz will be more than good, unless he gets a really crappy driver/MOSFETs or some of the old integrated BTNs.

So, fast MCU, high PWM (controlled in the code), fast driver/MOSFETs.

If he can figure out the B-G431B-ESC1 with SPI connection to the sensor, he will do just fine.


You say you need to get to the target very quickly, how quickly? Rad/s please. Also, how heavy is your payload? Is it on a lever or something very light?


That’s actually an awesome idea, they have very low inertia. But if his payload is heavy they may not be powerful enough to move it.


I’m re-reading your request, and I’m a bit confused. The B-G431B-ESC1 already has an MCU, why do you need a second MCU such as RP2040 ? What is your complete use case?

Interesting, thanks!

As for reading the encoder, the RP2040 has a 16-bit ADC, but that is apparently problematic for other reasons, so I’ve been looking a 24-bit external ADCs, which seem like they could be kind of great for the analog sensor side.

For driving the motors, it looks like the RP2040 has a 16-bit PWM duty cycle resolution. I’m not exactly clear on how limiting that value might be in terms of driving the ESC, is that what you were referring to @David_Gonzalez?

Again I’m even more confused. Why do you need an ADC when the encoder has an SPI interface according to the documentation?

You may be over-thinking this. The PWM frequency has nothing to do with the resolution.

Why don’t you present the complete use case, you will get a lot more help.


This is what I was thinking about @Valentine , not the PWM frequency. Anything above 12 bits should be good enough for high precision. It’s specially important if we’re scaling the voltage (voltage limit in the library) because for low resistance motors we usually use like 10% (or less) of the available duty cycle range.

Got it, thank you. Sometimes it’s hard to do this like that online :slight_smile:

1 Like

Actually reading the data sheet, the SPI is for control only, you apparently need to read analog signals.

Let me check the datasheet more, but I very seriously doubt in the real world you will get any noticeable improvement if you go for 16 bit ADC.

We’re moving fast here! I really appreciate the time.

Great question. After being pretty badly burned on STM32’s over the last 24 months, I’m not able to make them an irreplaceable part of my products in the future. I’ve managed to secure a reel of RP2040’s, and they’re so inexpensive, I’d really love to use them if possible.

I think the right answer is that I would gladly use the ST ESC to prototype, but it would likely get swapped out later.

Ugh, I just learned why Mouser has those parts in stock. 1 per customer per month.


Any alternative (available) part suggestions for the motor drivers are welcomed, though the couple of driver IC’s I’ve seen floating around seem to be pretty hard to get at the moment.

We’re producing a SCARA-style robot arm. The arm is very lightweight (compared to similar robots), and our end effector is usually moving <100g loads, but it’s not quite light enough to use disc drive motors.

Though I do love the creative thinking!

I might be mistaken (please correct me if I missed something!), but I think the IPS2200 sensor only provides analog output. The SPI and I2C lines are only for configuration and error detection.

So cool! Do you know if brushless used in industry are gimbal style wound?

Interesting, please describe where/what shortcomings you encountered. I’ve had only positive experience with STM32 families.

Please be careful, the RP2040 has only 3 ADC IOs. Also it’s a really new chip, with limited support.

LCSC has tens of thousands, no limit, $1.7 per chip. Buy from there.

I have bad news for you, direct drive is the wrong choice if you are really looking into a SCARA arm with high accuracy and repeatability. What’s your angular error and length of the arm? Also how many degrees of freedom and articulation?

For high accuracy please consider a commercial wave reducer. Again, depending on your use case, if you are frying hamburgers you are OK. If you are inserting needles into holes, you are not OK.

You are correct, it seems.


There are probably exceptions, but from what I’ve been able to find, SCARAs usually use relatively heavy NEMA style servos and almost never direct drive. But they’re also usually configured to carry 1-3kg at the end effector.

I’m really confused!

The entire line of STM32 chips have essentially been out of stock since Spring of 2020 (2 years now), and lead times are reportedly 52 weeks out across the board.

I managed to secure enough to produce the products we make, but ST has not done a good job of communicating with their customers through this nightmare (IMO).

[Checks LCSC]


Now I see you mentioned the stock at LCSC… I haven’t been able to source outside of authorized distributors, though when the wheels were coming off last Summer, even they didn’t have anything on-hand.

Indeed! Also the ADCs don’t actually work… So, there’s that.


You’re probably right, but I’ve done a few experiments that make me want to dig a little deeper and learn more before falling back to belts or gears (or strain waves). There are some components I need that pretty much have to be direct drive, so the learning won’t be wasted.

Sometimes, I hate it when that happens!

Hahaha, yeah, things are slowly coming back, albeit at outrageous prices. I see F103 at $125 !!!
But I don’t think STM has anything to do with it, they are just as confused as anyone else.

I’ve been using LCSC for quite some time. They are actually pretty reliable and have the biggest stock, even when everything else was cleaned out. even today I see nearly 300 MCUs from the STM32 lineup.

I hope it works out for you. Please come back and post pictures/videos, we all want to learn.


Thanks - I’ll be sure to do that!

You’ve been a big help this evening.