Has anyone used multiple MCU on a single board, any suggestion how I'd program them all?

Tags: #<Tag:0x00007fa4976aec38> #<Tag:0x00007fa4976aead0>

Hello electronics enthusiasts, I got a tricky situation to figure out. Does anyone know what’s a typical way of uploading code to multiple MCU’s on a single board?

I’m trying to control a ton of DC motors for my robot hand using PWM signals passed to H bridges. In my current version I have an ESP32 that control a bunch of LED drivers that in turn generate the PWM signals for the motors. And it works :slight_smile:

My problem is that it’s a bit slow, especially since I’m trying to do a current control PID loop. Additionally I have to redesign it anyway to fit some bigger motors. I’ve been looking around and it seems I can replace the PWM LED drivers with STM32 for basically the same price, but with a lot more compute (for an embedded device). The problem is that I would need 4 or 8 of the STM32 on my board, in addition to the ESP32 that is the master controller. Any suggestions how I’d go about programming all the microcontrollers at the same time? I’m tempted to avoid exposing 4 pads for each STM32 and poking it with a programmer individually.

Cheers,
Calin

1 Like

Looks cool! Is the reason you want BOM cost down because it’s moving towards being a commercial product?

For a prototype i like the tag-connect headers for programming, the ones without the clips to retain are quite small (i.e the ones that don’t have 4 massive holes in the footprint). Plus you don’t need any components on the board.

For batch production - build a jig w pogo pins or get your pcba house to upload them (the chip manufacturer can also do this if high enough volume).

Also - why do you need 8 stm32s? How many motors is each stm controlling & what is the limiting factor - gpios? Is code on all stm32s going to be identical?

It is possible to program stm32’s using another stm32 (think i read about using uart but can’t see why other methods wouldn’t work). So you could flash one or the esp32 and then in that code tell it to program the others (and potentially get the others to program more in an avalanchey style). Then when everything is programmed overwrite the esp32 programming script with the code you actually want to run on it.

A long time ago i had a look at robotic hands - never finished the project but would be interested to hear how you get on!

Also you can get connectors that push onto the top of the presoldered chip for programming - this would be another way. Like https://thepihut.com/products/soic-8-pin-test-clip-to-dip-adapter - but i have not used them, always found tag connect much easier.

That’s easy.

You can program STMs via serial port.

Connect all the STMs in parallel to the Esp, and the programming pins directly, flip one of the STM in programming mode, keep the other resettled and then send data via serial port, repeat for the others.

Bonus features: you can write a WiFi bootloader to flash them

Oh that’s nice, I have to connect the to the ESP anyway. How hard is it to turn the ESP into a programmer? I actually haven’t used a programmer yet, only plugged in by USB on the dev kit.

Yep, hopefully this is the last iteration before “production”, if I can find any buyers that need an extra hand or two :smiley:

Also - why do you need 8 stm32s? How many motors is each stm controlling & what is the limiting factor - gpios? Is code on all stm32s going to be identical?

Yeah I need to control a total 24 motors. I saw on the STM32F103 datasheet it has 3 timers with 4 channels each, making 12 PWM outputs, which can control 6 motors. However it seems they share functionality with quadrature encoders, so if I need to add those as well (I’m undecided about that) then I’d need 4 connections per motor-encoder pair; so a max total of 8 STM32s.

The programming issue is more for my sanity during developing. I don’t want to make a code upload take an hour every time.

Depends how hard you want it to be, you could write your own programmer, the STM32 protocol it’s public or you can turn the esp into a transparent uart, via wifi or via USB.

at 160MHz you can get a few shift registers going for a whole load of outputs. Also… TAKE MY MONEY : D