SOLVED: Decoupling? Effect on LCD of fading up/down RGB out of sync.

I've got astripboard with 6 RGB LEDs assembled on it. Each set of 6 Red, 6 Green, 6 Blue are controlled by an NPN tranistor, from a PWM pin on the MCU.

I've modified the fade sketch to test PWM and I'm fading each one up and down between 0 and 255 with a 30ms interval.

The only difference is they are out of sync. Red starts at 0, Green starts at 100, Blue starts at 200.

If I have an LCD still active, from a previous sketch so no LCD reset, I notice the LCD flicker. This is to do with the way the 3 signals are out of sync as it goes at a slower rate than any individual LED, but you can see the effect as regular, so it's some kind of modulation or harmonic issue with the three PWM's out of sync.

The LCD is mounted on an I2C backpack with a PCF8574.

Now, I have 0.1uF caps on across the MCU supplies right next to the pins. I've also tried 0.1uF cap across the supply to the backpack/LCD (where the leads plug into the breadboard).

This seems to have no effect.

I don't have access to an o-scope.

Could it be that I need a decoupling cap closer to the PCF8574 on the backpack and/or decouplng on the supply lines at the stripboard with the LEDs on?

It's just occured to me that it may be to do with different PWM frequencies too. This is on a 1284P and I'm using PIns 30, 8 and 9 on Bobuino variant. That translates to PD4 (OC1B), PD5(OC1A) and PD6(OC2B) Could it be that the two timers are different PWM frequencies and it's interacting?

I'll have a try with different PWM pins ot see if it makes any difference too.

I've had a play with this to try and figure out what is happening.

I added MENWIZ in and set up so I can control my three PWM LED channels between 0 and 255 in real time.

Taking any single LED up through the brightness level had an effect on the display contrast. It started off with a kind of cycling striping and then the frequency seemed to increase and the display contrast got dimmer and dimmer the higher I went with the brightness.

I attached my voltmeter close to the LCD power connections and it was at 4.6v. Take the LEDs up in brightness and the volts dropped consistently as the contrast faded.

I've got two breadboards linked together and power was coming in on the top left, by a 328P. My 1284P and LCD etc were all down the bottom left. I moved incoming power connections closer to these components and volts were 4.9v and dropped to around 4.7v with all LEDs at full brightness. was a simple volt drop issue due to the two breadboards and distance between supply in and the feeding connections.