I´m trying to control 4 separate LED strings with PWM output on a ATMEGA328P.
The first string (RED) is connected to pin PD6 (OC0A), the GREEN string is connected to pin PD5 (OC0B), the BLUE string is connected to pin PB1 (OC1A) and the WHITE string is connected to pin PD3 (OC2B).
Individually, the outputs work. I can dim the strings individually. The problem arises when I try to dim the outputs on pins PD6 and PD3 simultaneously. When the string on PD6 is active (max output) and I try to activate the PD3 string, nothing happens. The opposite same thing happens, if the PD3 string is active, and I try to increase the output on PD6, nothing happens. The other strings (PB1/PD5/PD3 or PB1/PD5/PD6) work simultaneously.
The power supply has more than enough current to supply the strings simultaneously.
I´m using AnalogWrite on Arduino IDE with no other hard config on timers´ registers.
const int RedPin = 6; // PWM output pin for Red Light.
const int GreenPin = 5; // PWM output pin for Green Light.
const int BluePin = 9; // PWM output pin for Blue Light.
const int WhitePin = 3;
void rgbw(byte r, byte g, byte b, byte w)
{
analogWrite(RedPin, r);
analogWrite(GreenPin, g);
analogWrite(BluePin, b);
analogWrite(WhitePin, w);
}
How many LEDs in a strip? 5V strips, 12V strips, ...)?
Based on your description, more than two or three might be the cause of your problem as you don't mention any drivers (mosfet, transistor, ic).
I think that a wiring diagram will be useful. I also think that the full code will be useful (or at least a representative example that exhibits the behaviour).
If you using an analogWrite in your code and reference the pins by its Arduino numbers- why do you mentioned it such way - PD3 (OC2B) - in your question? To looks smarter than you are and make understanding your message more difficult? Or perhaps you work with PWM another way? Show your code.
Normally there are no interference between PWM channels when you using it by analogWrite command. The problem is elsewhere.
I would suggest that you connect external Pots with analog channels, acquire the wiper signals, apply byte y = map(analogReadAX, 0, 1023, 0, 255); function, and then pass y to analogWrite() function at 500 ms interval. Now, check if there is any cross talks.
I´m using a LED driver IC (ZXLD1370) and controlling the output via its PWM input. Power supply 24V and 6 LEDs (3.2V each) in series in each string. 1 IC per string.
Sorry if I made it confusing, I just wanted to point out each of the timers that are being used internally, and also because I´m trying a similar code on another language where I need to manually configure the outputs. I´m gonna run some more tests today.
The 328P has 3 timers. Its 6 PWM outputs therefore do NOT allow for 6 independent PWM signals, but 3 pairs of 2 complementary outputs. Please refer to the Timer chapters for timers 0, 1 and 2 in the datasheet.
If you want to independently control 4 PWM channels at the same time, use a different controller or an external PWM generator (eg PCA9685).
I'm not sure why you're seeing interdependent behavior on the PD3 & PD6 pair.
Actually, the driver is working in buck mode, since the input is higher than the output, always (24VDC input and 18VDC output - 6 LEDs in series, 3V each).
I´ve attached the schematics for the microcontroller and the driver ICs (4 channels).
One more thing came up: I was running some tests and the same issue happens even when
the PWM is not being used. I just set the output pins HIGH, so it would set the drivers to max. output. Again, PD6 and PD3 output 5V but only one of the drivers work. So I thought it would be an issue with the board but I couldn´t find anything wrong. Individually, all drivers work.