0
\$\begingroup\$

I have built the following:

schematic

simulate this circuit – Schematic created using CircuitLab

In the schematic, the LEDs represent a 12V LED strip with red, green, blue and white channels. I'm using four IRL630 N-Channel MOSFETs (datasheet).

The 12V battery is actually a 20A power supply. The 5V battery comes from a raspberry Pi's GND and +5V pins. As you can see, the negatives (grounds) of both power supplies are connected.

The Atmega328 currently has a very simple program on it that fades colors (from red to green to blue to white, indefinitely), by PWM.

Problems:

With a load of 1.2A (i.e. a LED strip that requires max 1.2A at 12V), everything works smoothly most of the time. Sometimes the Atmega will freeze and the colors stop fading.

With a load of 3.6A, the color transitions are "skippy", i.e. the fading stops intermittently and then jumps straight to the color where it should be and continues fading.

With a load of 6A, the fading works for about 3 seconds and then all MOSFETs seem to enter saturation simultaneously, giving way to a bright white full-on LED strip.

What I've tried:

I tried decoupling, i.e. a 10nF capacitor between the Atmega's Vcc and GND. The effect I observed is a super-accelerated crazy color rainbow with intermitent strobe light effects. I've removed the capacitor.

I tried decoupling as above while separating 12V and 5V GNDs (don't ask me why). It didn't work, the LEDs just kind of lit up a little bit and stayed at one color. I unplugged it shortly after.

I'm a programmer. What am I doing wrong?

Additional details

  • I'm using 0.75mm² solid copper wires (18AWG according to Google), for everything up to the LED strip.
  • The connectors to/from the power sources are made out of aluminium, same gauge.
\$\endgroup\$
  • 1
    \$\begingroup\$ Power MOSFETs have a significant gate capacitance. The Atmega's outputs probably aren't powerful enough to properly drive them directly at whatever PWM frequency you're using. I don't know if that's the direct cause of your problem though. It might be a 5V power issue causing the Atmega to glitch out. Try a different (better) power supply for the 5V, and maybe some smoothing and bypass capacitors between VCC and GND. \$\endgroup\$ – Dampmaskin Feb 10 '17 at 14:58
  • 2
    \$\begingroup\$ Try more Vcc decoupling. Show your layout. \$\endgroup\$ – winny Feb 10 '17 at 14:59
  • 1
    \$\begingroup\$ What is your PWM frequency? For large loads, you might need to lower the frequency to fully turn on/off the mosfets. \$\endgroup\$ – Douwe66 Feb 10 '17 at 15:00
  • \$\begingroup\$ where are your led burn resistors or current controller? \$\endgroup\$ – JonRB Feb 10 '17 at 15:00
  • \$\begingroup\$ Dampmaskin thank you, will do. winny: more decoupling = more Farads? And sorry, but what is a layout? Douwe66 thank you, will try lowering the freq. \$\endgroup\$ – thwd Feb 10 '17 at 15:04
2
\$\begingroup\$

It's hard to guess what the actual problem in your circuit is, but you can try the following things:

  • Add a cap close to the uC input of the supplying power, e.g. 10uF 10V
  • Lower the PWM frequency, 200Hz should be enough to prevent flickering
  • add resistors between PWM-pin and MOSFET-gate to reduce strong current changes, try 10 to 100 Ohm
  • Keep the grounds connected! This is important for the functionality.

In your case, I think it's necessary to implement all of these suggestions.

\$\endgroup\$
2
\$\begingroup\$

The PWM frequency should be fine, Arduinos use around 400 Hz which is low enough with more than enough margin. If the PWM frequency was too high you'd also problems at lower currents.

I expect that your problem has more to do with the series resistance of the wiring. I suspect that the sources of the NMOSfets are not really at ground level (0 V) at those high currents. Then the Arduino cannot switch off the NMOS.

Solutions:

Use thicker cabling.

Connect the Arduino's grounding as close as possible to the sources of the NFETs, such that the large current does not "lift" the Arduino's voltage.

I'll draw what I mean:

schematic

simulate this circuit – Schematic created using CircuitLab

I know both schematics look the same but now imagine that the wires have some series resistance, think where the large current flows. In the bad schematic there will be a voltage drop between the source of M1 and the point where the GND connection of the Arduino is. It can be that M1 is off but there are 2 other NMOSFETs which could be on so a current can still flow. I'm assuming part of the source to 12 V battery connection is shared between all 3 LED channels.

In the Good schematic that voltage drop is less relevant as the Arduino's ground is the same as the NMOS's source so it can properly shut it off. You do need to have all 3 NMOS sources connecting to one point, ground the Arduino there and then use one connection (multiple wires in parallel is OK though) to the battery.

\$\endgroup\$
  • \$\begingroup\$ Do you reckon that 0.75mm² solid copper wiring (18 AWG) won't cut it? That's what I currently have because it's exactly the size of my perfboard's holes. \$\endgroup\$ – thwd Feb 10 '17 at 15:35
  • \$\begingroup\$ Probably just OK if not too long, look here: en.wikipedia.org/wiki/American_wire_gauge 18 AWG is about 21 m ohm/meter. Multiply by cable length then current and you have the voltage drop. So at 6 A you get 120 mV per meter. Also do not neglect contact resistance etc. Best to find out is to program full brightness at one RGB color, for example: Red and then with a multimeter measure if all voltages are what they should be. \$\endgroup\$ – Bimpelrekkie Feb 10 '17 at 15:40
  • \$\begingroup\$ "The PWM frequency should be fine, Arduinos use around 400 Hz which" - He never said he was using Arduino, just an atmega328p. If he's using the 328 without arduino software, it's quite likely his PWM frequency is not the arduino-standard 490Hz. \$\endgroup\$ – marcelm Feb 13 '17 at 21:18
1
\$\begingroup\$

It sounds like a supply problem. Maybe the 12v supply isn't as capable as you think.

I would put a diode on the 5v line to the mcu and on the mcu side of the diode, put a large capacitor (like 22uf / 47uf capacitor) there.

I would also shield the mcu away from the power supply.

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

I took everything apart, measured and tested.

In the end, I conclude that the problem was that the wiring in the LED strip itself that is too thin to carry enough current from end to end.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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