I was wondering whether it would be possible to use a BLHELI32 compatible ESCs with SimpleFOC.
It should be possible as they all use STM32 controllers afaik.
The interfacing would have to be done via the programming pins (usually accessible).
Encoder could be connected on the ESC input pin either via PWM (once available) or analog or via the programming as well (maybe via I2C?).
I am aware there are a lot of very well built boards available, but these ESCs are extremely cheap to have and I wonder if they would work as servo controllers.
My approach would be to buy the B-G431B-ESC1 to get my toolchain running with Owens tutorial. Then I also have an ST-Link device I could hook up to the real ESC.
I’m thinking about trying this as a project, but wanted to know if I am on the wrong track before I invest money and time into it.
I’ve been looking at this kind of hardware for a while… I don’t think it will be easily possible to just buy BLHeli boards and use them with SimpleFOC. Here’s why:
Usually, they don’t have many IOs. The flight controller boards have the IOs, but the ESCs have only what’s necessary for their function. So it would be hard to attach encoders and other sensors to the ESC.
The ESC usually integrates an inexpensive driver, often Fortior Tech. These drivers run in 1-PWM mode, i.e. don’t allow separate control of the motor phases. So they can’t be used for FOC-control. (in theory you could use SimpleFOC’s higher level PID functions to drive a 1-PWM driver… that’s something one could look at, but it would not be FOC).
Even if the ESC integrates a MCU, it typically will have only 1-PWM lines exposed to the flight controller. So “breaking in to” this type of board would require soldering directly to the MCU pins and stuff like that. Not really an attractive option even if you do make it work
But, looking at various designs for these ESCs has been a great inspiration for me. They do some interesting stuff on those boards to make them so compact.
And in terms of the basic setup, if you replace the driver with a 3-PWM or 6-PWM capable one, and add the needed io lines for sensors, etc, then the basic designs will definitely work with SimpleFOC. They’re fairly no-frills FET-based inverter designs.
However, it is probably important to remember that because of the way they are used they are essentially “self-cooled” by the air-stream as they fly. On a ground-based robot, extra heat dissipation will be needed.
If you’re looking for “ready to run” simpleFOC-like boards and code, take a look at the Basecam, ODrive or Moteus projects. They’re aimed at driving motors more slowly, with FOC control.
The B-G431B-ESC1 is an evaluation board. It’s maker sells these boards at a very low price, to showcase their products ( they sell chips and software, not ESC’s ). It is easy to program them ( they even have a builtin programmer ).
A commercial ESC on the other hand is not meant to reprogram. You can load it with a new version of it’s existing software, but it might be impossible to load it with anything else. It will have a bootloader that can prevent this.
It is also not going to be that much value for money hardwarewise.
I’ve looked at one myself, because the manufacturer was so kind to produce very high resolution pictures of it.
What I saw was an 8-bit 8051-compatible MCU running at 48 Mhz.
The G431 is a 32-bit MCU running at 170 Mhz.
Another thingy : If you load whatever hardware with the Arduino firmware, it becomes an Arduino.
That is : 8 bits PWM at 590 Hz. ( from 12 bits at 20.000 Hz )
That isn’t entirely true. Many arduino board have the ability to set analogReadResolution(12) to get your lost bits back and there is nothing stopping you using registers (or HAL_ libraries) to get faster analog speeds. I agree that this is typically harder than using vendor frameworks.
I also agree that super cheap escs are often impossible to program. Never trief a blheli32 though! If SimpleFOC and sensorless FOC then they would become more interesting.
…Write, I think. Of course, anything is possible in software. You just have to do some ( or a lot ) more work. You would need to increase the PWM clockspeed. If you can do all that, you can probably write your own Clarke and Park transforms and the PID controllers and then you wouldn’t need SimpleFOC.
I read somewhere that BLHELI-32 is paid software. That will make the boards that run it a little more expensive.
The Board has an stm32 MCU and I believe it routes 6 pins to the FETs via this fortior chip as drivers. Would that mean it is possible to run in 6PWM mode? This board is 3 layers I believe, at least I’m not able to follow the traces.
As you probably already realized I am not an expert with this
I managed to “solder” some wires to the exposed programming pads, but they are indeed tiny. Soldering to the pins of the 5x5mm UFQFPN32 is impossible to me, so I will be stuck with the swdio, swclk and the PWM input pin (still have to figure out to which input it connects).
This means to control the motor I would be able to do software I2C, step/dir or anything like that only. There are versions of blheli_32 boards with what they call telemetry output via dedicated pins. Its probably better to go with those for any real use as it probably exposes some kind of serial interface.
For me this is a theoretical thing anyways as I don’t even have a use case, but want to play around with electronics again after a longer break.
However, now I am facing a problem I think @Jan_Donker is referrring to: The chip is protected. (see screenshot)
Is it still possible to uplaod anything to it? Are there fuses I can change or should I just try to compile something and download it?
In theory, yes. The Fortior chip FD6288Q used is a 6-PWM gate driver, so that part looks promising.
However, as you’ve found, the lack of connectivity can be a real challenge.
The chip could be protected, but try this first: using SYM32CubeProgrammer, connect to the chip, and option the “Options Bits” screen. There open the “Read Out Protection” tab and see if this is switched on, and can be switched off. If so, then it should solve your problem.
ESC’s in general work in 6-step mode, where you estimate the rotorposition by measuring the voltage at the third wire.
They aim at maximum power at high speeds.
FOC control on the other hand aims at maximum efficiency at lower speeds. It estimates the rotor position by measuring current. The algorithm requires DSP capabilities and a way to measure current.
So both methods require specialized hardware, but it doesn’t mean one would be more expensive.
The SimpleFOC method just uses a positionsensor that the other 2 don’t require.
If you want an ESC to do precise positioning you might try alternating between 2 steps so the rotor will be somewhere in between, just like microstepping a steppermotor.
I think Texas Instruments does it that way.