4
\$\begingroup\$

I'm currently looking for some sort of interface which can generate many (up to 100 potentially) individual PWM outputs. I figure I2C is the best way to go about this, but I'm open to other possibilities.

The only thing I've found so far is the Adafruit PCA9685, but at $15 a pop ($105 for the 7 I'd need,) I'm open to other options.

I don't have particularly high needs in terms of frequency or resolution - a step resolution of 1% (7 bit, I guess), at 10 ms time resolution at 1 Hz update rate would be my lower bounds on performance.

\$\endgroup\$
16
  • 3
    \$\begingroup\$ Do any of the answers to Is there such a thing as a PWM expander like there is a GPIO expander help? \$\endgroup\$ Commented Jan 9 at 18:38
  • 5
    \$\begingroup\$ Those ICs Adafruit uses are pretty inexpensive for the number of channels (about 15 cents/channel USD in 100 chip qty). You could put them on your own PCB. I think the connectors and whatever you're driving with it are going to dominate unless it's LEDs, in which case there are more specialized ICs for that purpose. Of course you could do it all in one chip using an FPGA but that learning curve is steep. \$\endgroup\$ Commented Jan 9 at 18:57
  • 2
    \$\begingroup\$ PCA9685 is current less than 3 dollars a chip on digikey for 16 channels. Hard to imagine you're going to get much cheaper than 25 dollars for something like this. Assuming specs are ok, could drop 6 or 7 on an Arduino shield or whatever format you want easily enough. \$\endgroup\$ Commented Jan 9 at 19:15
  • 1
    \$\begingroup\$ interesting things happen if you disconnect the VDD of a 4017 \$\endgroup\$ Commented Jan 9 at 20:36
  • \$\begingroup\$ @AndrewMorton I did come across this question myself; I found that it did help a bit, but I wasn't sure how to extend the suggestions there to the scale I need \$\endgroup\$
    – Davis Last
    Commented Jan 9 at 21:05

4 Answers 4

3
\$\begingroup\$

If you're open to using SPI, multiple chains of SPI devices can do this, with a more straightforward driver than I2C. As a bonus, SPI will offer you faster updates than you can achieve with I2C. If your host can do multi-bit SPI, even better.

Adafruit themselves have a 12-channel, 16-bit PWM board for $7.50 which is a bit more affordable than the PCA9685 version.

A possibly even cheaper approach, but with more intense CPU overhead, is to implement the PWM directly with shift registers with something like the 74HC595. With this approach the SPI runs all the time, and you implement PWM by controlling the duty cycle in software. Since SPI uses a fixed frequency clock the PWM timing is deterministic.

More here: https://hackaday.com/2011/11/05/controlling-shift-registers-via-spi/

And here: https://forum.arduino.cc/t/software-pwm-using-daisy-chained-74hc595s-spi/38251

TI offers a shift-register style LED driver with built-in current references, saving you the trouble of individual LED resistors. If you only need one color (or use separate R,G,B drivers) then is is a good option: https://www.ti.com/product/TLC59284

\$\endgroup\$
2
  • \$\begingroup\$ The other comments have some very valid answers, but this is what I've arrived on personally - I have an idea that, for me, using GPIO for chip select with these SPI-based boards is the way to go. \$\endgroup\$
    – Davis Last
    Commented Jan 9 at 21:02
  • 1
    \$\begingroup\$ Worth noting that the chip on the adafruit board costs about $3 on mouser, which is a difference of about $31, getting your own PCB manufactured to house the chips (plus the passives needed for it) will probably cost you less than that. \$\endgroup\$
    – xenia
    Commented Jan 10 at 12:07
9
\$\begingroup\$

Probably the most capable solution in a single IC is an FPGA or a CPLD.

Cheap parts can easily handle 100 PWM outputs, or as many as it has I/O pins for. You can add an SPI interface to control it, which is simpler than I2C and just as practical for a point-to-point connection.

You'd need to be able to design the firmware for it in VHDL or Verilog, which are straightforward to learn and well documented on the internet. You can use the manufacturer's free development tools to simulate and compile your design. You'll find plenty of low-cost demo' boards you can try out or rig up, with varying amounts of I/O pins.

An FPGA/CPLD is more expensive per part than a microcontroller but there's parts for £5 that can easily do this. And an FPGA/CPLD is far more capable at this sort of task than a microcontroller and much easier to design for it (said from the perspective of being able to do both).

\$\endgroup\$
0
4
\$\begingroup\$

It's not a peripheral, but... 8x RP2040's is $5.6, each can do 14 PWM's using 7 timers. (one of them is for i2c)

Or even cheaper, do the PWM in software, because why not?
Then you can do 28 PWM channels per chip, say 5 chips, $3.5.

\$\endgroup\$
4
\$\begingroup\$

Use a PLD, that will probably be the best thing. You'll have to do some HDL, but it would give you the GPIO. Another option is a high GPIO count MCU; the PWM could be bit banged at the rates you have without too much trouble.

\$\endgroup\$
4
  • 1
    \$\begingroup\$ Regarding the bit-banging option... an MCU with a DMA engine would be great at triggering GPIO value changes en masse from a hardware timer. \$\endgroup\$
    – Ben Voigt
    Commented Jan 9 at 20:58
  • \$\begingroup\$ You probably wouldn't need that if you didn't want precise timing. But its really a hardware timer with interrupts that you'd need. Even low end MCU's that are cheap and running at 10's of MHz would be plenty for 10ms resolution. If you need more resolution and a high update rate (like better than 1ms and 100Hz update) then you'd need a really fast MCU like in the 100's of MHz. An FPGA/PLC would give you exact timing, as fast as the clock, but is more expensive in time it takes to program and hardware cost. \$\endgroup\$
    – Voltage Spike
    Commented Jan 9 at 21:02
  • \$\begingroup\$ I could be mistaken on the PLC thing then I'll edit. \$\endgroup\$
    – Voltage Spike
    Commented Jan 9 at 21:24
  • 1
    \$\begingroup\$ PLD - Programmable Logic Device :) PLC is an industrial computer with industrial I/O, more or less. \$\endgroup\$ Commented Jan 9 at 21:48

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