Shift register PWM questions

I'm looking for some general information, I suppose, on the various libraries for PWM over shift registers. First, is there a preferred library that is generally recommended? The second question is what is the limit on how many channels can be effectively controlled? The libraries I've looked at use a 'resolution' value and I'm wondering if there is a chart somewhere that shows what the maximum number of channels is at various resolutions. The third question, will the recommended library have any effect on the ability to use I2C to receive data from another uC? the ones I've seen look like they change the timers and I don't know if that has any effect in the I2C bus.

The progect in question is for a lighting controller where my plan is to use a Mega2560 as a master controller, converting DMX to an arbitrary protocol sent on the I2C to a number of slave controllers. I'd like to use a pro-mini (5V) for each slave controller. I'd like to have 32 PWM channels on each slave with as much resolution as possible. I think at least 64 steps would be needed, but may be able to get by with 32. I'll have to see how it looks as a smooth transition in the fade is important.

For the hardware I plan to use 74HC595 shift registers driving logic level mosfets.
Any thoughts are appreciated.

I would suggest to look for a chip that takes care of the PWM for you.
Search for "PCA9685 module".

I have no experience with any such libraries, but I have done PWM over shift registers myself.
You can get reasonably smooth fades on 16 channels, and presumably also on 32 channels, I haven't tried.
The issue is that you can't really do anything else than play a predefined pattern.
Anything that takes more than a few 100 µsec will make it visibly less smooth.

Edit to add: If you want not just any 64 steps, but 64 levels more or less equally spaced to the human eye, you need more resolution. The difference between 2/64 and 3/64 is much more than between 57/64 and 58/64.

i2c is done in the hardware of the Arduino and is not impacted by any timers, etc.

Jobi-Wan , The PCA9685 module may work out for me, I'll have to crunch the numbers. I liked the shift register because its 10 times less expensive than the I2C PWM chip. The extent of the sketch running on the uC would be reading in the 32 bytes corresponding to each output and storing them, then reading those values and sending them out as pwm values to each bit of the shift registers. Thanks for the thoughts. I may see if I can find the PCA9685 for a good price as just the chip, since I need to have PCBs made anyway.

blh64, Thanks. Now that you mention it I seem to recall reading that before. Thanks again.

[…]reading those values and sending them out as pwm values to each bit of the shift registers.

But you’re not sending them out to the 595s as PWM values.
In order to have 64 steps of PWM at 50Hz, your Arduino needs to shift out all those values 3200x/sec, in a very steady pace. (And those 64 steps give you maybe 20 ‘useful’ steps.)

Also, if you offload the PWM-ming then it will still work when you decide you like it so much that you now want more channels.
There are other chips than the PCA9685, the TLC5947 looks nice at first glance, but I happen to have this module.

Jobi-Wan, I assumed you’d know what I meant by sending them out, reading in the data then sending out the corresponding data to the registers, etc. As for adding more channels, the reason being cost effective is important is that I’m planning 512 channels in the first place, a full DMX universe. I’m looking at the PCA9685 modules now and have some on order for testing. I think I can get away with just those modules rather than a pro-mini+shift registers, so about double the cost per channel as what I was hoping, but everything else looks easier to deal with. Thanks for the suggestion, I’ll see how it goes.

Normal PWM works at 500-1000 Hz, not just 50 Hz. That's a very low frequency. The normal PWM resolution is 8 bit, so much better than the 5-6 bit you're asking for.

On the other hand calculating 32 channels based on independent timing 3,200 times a second is a serious load for a 16 MHz microcontroller, and requires some really careful programming from you to be on time.

The PCA9685 doesn't sound that expensive to me, in single units USD 2.26, offering 16 PWM channels each at 10 bit resolution. Up to 32 of them on a single I2C bus, so that's your 512 channels at a cost of just USD 61.44 (volume discount). Add a PCB, a few capacitors and other required components, and you're done.