New board with the RP2040/Pico

There are in total 26 GPIOs available on the Raspberry Pi Pico. I am considering making a carrier board with support up to 5 BLDC motors for the Pico.

  1. For each motor we need 3 pins for PWMs and 1 pin for EN. That means 20 pins are needed for 5 motor.
  2. As for current sensing, I am considering using an LTC24971 16Bit/16 Channel ADC with I2C communication. That’s 2 pins (SCL and SDA)
  3. And AS5047 with SPI communication for the position sensing. That’s 4 pins.
    So all 26 GPIOs on the Pico are used.
    Any suggustions?

I think the i2c current sensing is to slow but I’m not quite Shure on that.

@miraclemelon ,

Welcome and thank you for contributing.

The idea of using Pico in such manner is certainly interesting. I have never used Pico. Can you first ensure SimpleFOC supports Pico, and if the code supports current sensing using i2c as a protocol? Perhaps reading the documentation would really help you in your desicion. I am not an expert in Pico or Simplefoc but have this feeling that you may hit a few bumps on that road. Hopefully others will contribute to your question more productively.


here it is comfired Pico will be supported,also reading current though i2c is’t a problem rpi_mcu

The normal arduino has a 9600khz adc sampling speed(or 9,6ksps) so anything significantly faster than that and with a faster i2c speed should be fine. The propagation delay of the adc does impose limitations on how fast the foc loop can run, however.

I’ve looked at faster, better adcs for current sensing and a reading for two over spi takes around 40 clock cycles, or about a microsecond at 40Mhz. That shouldn’t limit anything. Though it’s good to keep in mind.

Reading i2c with pico isn’t a problem, however, is current sensing using i2c sensors supported by the library? If it’s not then you need at least two analog pins for each motor. Pico has only 3 analog pins, so you may have a problem there. Could you please check?


The library doesn’t support it at present. Though two sensor operation is supported.

Adding it should be fairly trivial though, just a function that gets the phase currents from somewhere.

I’ve done something similar in the past, where I had four motors, so I ended up controlling four individual motor boards (each with small MCUs) with a central powerful MCU (600MHz NXP Cortex-M7) which did the complex calculations and communications, and sent simple commands to the four motor boards. Using a single MCU to control five motors may be possible, however, @miraclemelon will probably need at least one of the high-end STM32 M7 144 pin MCUs. Plenty of pins to work with. Something like STM32H743ZI, or dual core STM32H747 or any other from the H line.

teensy 4.1 could probably do it. it has 35 pwm pins, 18 analog inputs and a very fast processor. though using your approarch with one mcu per motor would definitely be the simpler one.

How did this go? I think 5 BLDCs is very ambitious, just from the point of view of running the FOC algorithm 5 times, even on a fast MCU like the Pico. I’d love to know if you made it work.

I think a significant problem would be reading 5 AS5047 sensors quickly enough - you’d have to make the SPI work asynchronously I think.
An idea I had for this, which I am slowly working up to testing (got the hardware almost ready, need to find time for the software), is to use SSI based sensors (like the AEAT-8800-Q24 or MA732) and try to read them using the Quad-SPI peripherals some of the MCUs have. Not sure how realistic that is.
The Pico also has its programmable PIO units though - perhaps those could be used to read 4 or 5 sensors via SSI in parallel…

1 Like