Hi Iain,
You might want to consider using a PWM chip e.g. TLC 5940
According to the data sheet, you only need 3 pins to write to it, and it will generate 16 channels of PWM for you.
The nice thing is that you should only have to tell it to set a pulse width once, you will not have to keep your program busy clocking out loads of data into the shift registers to keep the motors running at a constant speed. (If you try to generate PWM from a shift register, any interruption in the sending of the data to the shift register could leave your PWM pin high or low for an unplanned period of time. This would cause the motors to slow down or speed up.)
The TLC5490 connections are basically the same as the 74HC595 shift register. Since I know you are trying to reduce the number of pins used, I think you will still want to get the other motor control signals from the shift register, you might consider wiring up the two devices into a chain to keep it at 3 pins, or have the clock and data in parallel, with separate enable lines (4 pins).
Paul
- CW2 likes this