5
\$\begingroup\$

I'm working on a project where I'd like a large number of small microcontrollers (100+, something like an 8-bit PIC, but flexible on what I use) to each perform audio synthesis behavior defined by an 1-4 byte shift register. The idea is to program each micro as an oscillator and have frequency, pulse width, and phase each controlled by the register data and to have one master device pass data to all the smaller devices in a daisy chain configuration.

Think of it as the audio equivalent of a WS LED strip.

For this to work properly, I need a protocol that can spit out high-speed data to all the micros, allow each micro in the chain to pass data on to the next micro as it is being clocked in, and then update each micro simultaneously once the data write is complete.

It also needs to be a protocol that can survive going some distance over a wire run, I will almost certainly add an input / output buffer to the PCBs, but assume wire runs between PCBs can be up to 10 ft.

What am I looking for to do this properly based on the parameters I have described?

\$\endgroup\$
8
  • \$\begingroup\$ this may help ... m.youtube.com/watch?v=vjc4ZF5own8 \$\endgroup\$
    – jsotola
    Commented Jan 29 at 23:59
  • \$\begingroup\$ Are you looking for a physical daisychain, i.e. where each talks to the next (and none other), or do you mean that all are connected in parallel ("multi-drop")? \$\endgroup\$ Commented Jan 30 at 8:08
  • \$\begingroup\$ physical daisy chain \$\endgroup\$ Commented Jan 30 at 19:33
  • \$\begingroup\$ Ethercat if you can afford it. Canopen if good enough. Modbus could work too \$\endgroup\$
    – TQQQ
    Commented Jan 31 at 15:26
  • \$\begingroup\$ @TQQQ - Thanks for trying to help, but answers shouldn't be put into comments. Please consider moving that into an answer. \$\endgroup\$
    – SamGibson
    Commented Jan 31 at 15:36

3 Answers 3

6
\$\begingroup\$

That's literally what SPI is: clocking bits into the shift register in each microcontroller, while clocking out the ones already stored in there.

Since any reasonable MCU already has an SPI peripheral, there's nothing you need to invent.

Distance here is mostly a matter of speed, and you can be as slow as your application allows. ("High-speed" sadly tells me nothing? Is this an easy 1 Mbd, or a hard 50 MBd? Who knows.) Should you need higher speed, the standard way is just to add a differential line driver at each MCU's output, and to just buffer the differential bit clock, as well.

8 bit PICs are currently overly expensive for their capabilities, so you'd probably fare cheaper with an stm32c0 or similar. Also makes the audio stuff much easier, as you get far far far superior timer/PWM units. Plus, programming equipment for cortex-m0 MCUs like these is much cheaper, and the compilers much better, so that this would really be a no-brainer for me.

\$\endgroup\$
10
  • \$\begingroup\$ SPI with a return clock? \$\endgroup\$ Commented Jan 30 at 7:19
  • \$\begingroup\$ For example, or even with return Data, which helps if you don't know the strong length beforehand \$\endgroup\$
    – sina bala
    Commented Jan 30 at 9:17
  • 1
    \$\begingroup\$ Just don't make OPs project unnecessary expensive because of fanboyism. A PIC is still cheaper and perfectly fine for the purpose with its hardware SPI and PWM. It doesn't matter if the stm is 100 times faster but only 50% more expensive. \$\endgroup\$
    – pipe
    Commented Jan 30 at 11:44
  • 3
    \$\begingroup\$ @pipe At least from my distibutors the STM is actually cheaper, esp if we only consider PICs with enough RAM to work on a decent window length. AVRs fall somewhere between those two. \$\endgroup\$ Commented Jan 30 at 16:10
  • \$\begingroup\$ Is there a way to configure a SPI peripheral to automatically write out the data it receives in after a certain number of bits are filled in the configurations I described? Would this involve connecting MOSI to MISO on the next micro in the chain, but keeping the clock and chip select lines connected to the main controller board? \$\endgroup\$ Commented Jan 30 at 19:33
5
\$\begingroup\$

This sounds like a job for DMX512. DMX512 uses RS-485 with simple serial coding, well within the reach of an 8-bit micro (some Microchip devices even have DMX hardware support, see below.)

Up to 512 8-bit DMX nodes per ‘universe’ are supported, at a refresh rate of 44Hz. Data is sent as entire frames at fixed time intervals.

DMX can physically support up to 32 devices in a daisy chain. Stage setups will often break up DMX into several branches using repeaters, or even break them out as separate universes if a higher refresh rate is needed.

DMX512 devices are electrically daisy-chained using twisted-pair 'balanced' audio cables terminated with XLR plugs. Termination is 120 ohms.

Some DMX implementers will use CAT3 type twisted pair cable instead of audio cables. You could choose that and save the cost.

Finally, there are wireless and Ethernet bridging options for DMX512.

More about DMX512 here, from Microchip.

\$\endgroup\$
4
  • 1
    \$\begingroup\$ I also immediately thought of DMX-512, but decided to not suggest it because on second thought it is a poor fit. As it defines the connectors, cabling,electrical interface and isolation, it is too clunky to implement as-is. Each MCU requires UART and RS485 receiver(transceiver), and address configuration, isolated interface, and for 100+ MCUs, you need 200+ XLR plugs and 200+ XLR sockets, and while there are RS485 PHY chips capable of 200+ PHYs on bus, DMX-512 limits that to the original RS-485 max of 32 devices or less if fail-safe biasing and repeaters are used. Similar protocol should work. \$\endgroup\$
    – Justme
    Commented Jan 30 at 6:41
  • \$\begingroup\$ I mean I could easily use the DMX serial format with different connectors. I think buffering is something I'll have to figure out regardless of what format I use, since sending data signals over long cable runs can make that tricky. My main question here would be how to synchronize the DMX register loads such that all the boards update at the same time, which is a requirement for me \$\endgroup\$ Commented Jan 30 at 19:26
  • \$\begingroup\$ DMX syncs after you've sent the entire payload, so this will ensure the update is coordinated. \$\endgroup\$ Commented Jan 30 at 19:31
  • \$\begingroup\$ Also, DMX over RJ45 is common, especially when used for fixed setups. Stage users prefer XLR due to its toughness and serviceability. \$\endgroup\$ Commented Jan 30 at 20:53
2
\$\begingroup\$

I worked on a project like this and ended up using the RP2040 with two RS-485 ICs, one for "upstream" messages toward the controller and one for "downstream" messages, using both RP2040 UART buses. Then, when the final boards were in sequence, they all communicated by incrementing the ID in a JSON message. This allowed the firmware on each board to be identical with no dipswitches or other addressing requirements, and the RS-485 protocol allowed for a highly variable distance between each board.

In the final version, broadcasts could be sent from the controller to all boards, or messages could be targeted to any individual board in the array.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.