Cortex m0 with spi or i2c for as5047/or as5600l and can bus to esp32

Thinking out loud for a super cheap network FOC motor array. I know that some of the STM32 more advanced motor driver ics use the good old m0 for robotics. I did try to compile foc on one board the STM32F030F4P6 but it complained about not having enough memory of course having only 16kb of memory lol and only 4kb of ram. The STM32F030C6T6 is what is inside the STSPIN32F0A and it runs its own FOC algorithm(I have one its pretty cool and comes with a really amazing brushless motor).
Still something like this would pair well for low power gimbal motors. and with the as5600l for lower speeds its probably the cheapest solution to enable many many motors running on a can bus with simple FOC doing its own thing locally on each motor.
I wonder how small we could squeeze the code.

Hi Adam,

Maybe you can check this:

You can tailor the library according to your needs.

Best regards,

1 Like

The second chip STM32F030C6T6, has 32k flash and 4k sram. I’d have thought that would be enough as atmega328p works with same amount of flash and half sram.

1 Like

@Owen_Williams yes it does:) It’s unfortunate that’s it’s not part of the stm32duino supported boards otherwise I would just get one and try it. And @robin2906 I guess I will give it a go to see what makes sense to cull.

TO get an idea I opened up that minimal branch and loaded up the BLDC_i2c example
for compiling on the blue pill i get

Sketch uses 36256 bytes (55%) of program storage space. Maximum is 65536 bytes.
Global variables use 2104 bytes (10%) of dynamic memory, leaving 18376 bytes for local variables. Maximum is 20480 bytes.
and for that poor little m0 I get

Close but no cigar
region `FLASH’ overflowed by 28040 bytes
compiling for the nano its only
14112 bytes

Hey Adam,

Please try to use sine functions instead of the table. The sine table uses around 20% of memory. Go in the BLDC motor and find _sin() and _cos() functions and remove the underscores. make them sin() and cos().

1 Like

@Adam_Donovan maybe you could help add that board to stm32duino. It’s probably a few hours work if a very similar board exists. I’m in the process of trying to get the b_g431b_esc1 added as a board, my one is taking longer as the closest board has 64pins and mine has 48.

1 Like