Hi new member here. 48v 750w bldc design question

Hi everyone great community. I already learned so much reading docs.

I want to make myself a 48v 750 bldc it has sensors. I am leaning towards stm32g4. But i am more familiar with samd21. I just want to have 3 phase independent xurrent voltage measure. Probably not necessary but still a good challange.

So question is what do i get with g4 compared to sam21 ?

Hi @Oytun_Yilmaz , welcome to SimpleFOC!

A STM32G4 MCUs can be clocked up to 170MHz, and depending on the exact model, has up to 5 ADCs, OPAMPs and comparators, many timers, CORDIC for hardware trig functions and more. It’s not really a fair comparison to the SAMD21… it would be fairer to compare it to a SAMD51, but I think the G4 is still a bit better.

So I’d say SAMD21 is sufficient to run SimpleFOC but a G4 is excellent for SimpleFOC :wink:

Depending on how much you optimize I’d say your loopFOC frequency would be around 2-3kHz on the SAMD21 but more like 10kHz on the G4, and even more if you optimize things.

Thank you ! Everything I read points to g4 being the best choice, so I will go from there

Some additional clarification about the status of ADCs on the STM32 would be great. A cursory glance would make one think that it’s necessary to have all current measurements on the same ADC for it to work, if that were the case then those opamps on G431 are kinda useless since they can’t be pointed at a common ADC till you get into very large package sizes?

But, it seems there is an example in the code that does it anyway, B_G431. Is there any reason why that guy is all by his lonesome? I would assume that if you were using the G431 you’d want to use the internal routing to free up pins and decrease package size? Is one method preferred over the other? I think I found another thread where the dual G431 ADC wiped out the ability for other ADCs (bus voltage, temp, etc) but it appears even that is no longer the case?

I think I’ve covered all the bases and I’m sure I could get a custom board with the same pinout as B_G431 working, but I would like to be sure I’m not missing anything and the freedom to route things as needed, when possible.

Thank you!!

There’s no problem with using both ADCs on G431. The only caveat is that you can’t have both ADCs read the same channel number simultaneously, but since the channel sequence is flexible you can usually shuffle the order to eliminate conflicts.

I don’t think there’s ever any conflict with the temperature sensor, VBAT, etc. They’re hardwired to particular channel numbers that aren’t used for anything else, so just include those channels in the sequence registers to read them at any time.

And yes, it’s generally not necessary to route the opamp outputs to pins. Just use the internal ADC channels to read them. I think B_G431 only routes them to pins so you can probe them with an oscilloscope for educational purposes.

Read the ADC section in reference manual RM0440 for all the details.

Thank you!!

I was mostly referencing this old thread here, I’ve been sourcing as much info as I can! I know it must be possible, if only because ST’s code will do it. I actually stand a chance of understanding what’s going on with simplefoc though, modifying it to my needs over the obfuscated code manufacturers pump out…

I think there’s another problem with one of the ST STSPIN32G4 dev boards with differential current sensing, too. Differential PGA configuration must use VINM0 according to RM0440. One of the ref designs uses differential sensing and PC5 (VINM1), which won’t work. Is kelvin sensing even necessary? Probably not, if ESP32 works with it’s terrible ADC, but might as well use all the power of the chip if it has it, right?

These are good questions!

The B-G431-ESC1 drivers will run on any G431 MCU - assuming you make the same pin assignments… the reason we have a seperate driver for it is that it uses the OpAmps (and multiple ADCs) which requires a special configuration.

Normally we only support sensing all the phases on a single ADC, with no OpAmps and no differential inputs. To configure that differently will at the moment require you to write your own driver (or hack up ours).

But it’s definitely possible to do it, the STM32s have powerful analog lfeatures, especially the G4s…

I’m working on a brain board, plus a infineon IGBT module to run some “310V” brushless motors. I think between the ST code and what’s already in SimpleFOC code it shouldn’t take much work to rewrite those drivers. Wish me luck!!

1 Like

The stm32g4 is completely different from the samd21 if the objective is a 48v 750w bldc with actual current regulation. The motor-control peripherals are the real advantage, not merely clock speed. Fast multi-ADC sampling, internal opamps, comparators, and high-resol timers made especially for bldc/foc operations are all provided by g4. It eliminates the need for a mountain of external analog equipment and makes full 3-phase current sensing feasible.

Samd21 can run a bldc, of course, but you’ll have to deal with restricted timer features, single ADC sequencing, and ADC latency. it’s fine for basic commutation or low loop rates, not great once you start pushing current bandwidth or higher pwm frequencies. SimpleFOC and comparable stacks strongly favor stm32g4 because it can achieve greater loopFOC rates, synchronize ADCs to PWM edges, and control noise.

Samd21 means learning and light duty, to put it simply. Stm32g4 = much more headroom, cleaner current sensing, and specifically designed bldc control. G4 is the sensible option if 48v/750w is already your goal.