0
\$\begingroup\$

I want to make a LED strip driver, using an atmega328 on a custom PCB.

I was able to get it to work perfectly using an arduino UNO, with the mosfets connected on a breadboard. However, when I just had the atmega328 chip on the breadboard (with crystal and capacitors) it was unable to drive the LEDs.

I had uploaded a sketch to use PWM to fade the LEDs on and off, which works perfectly on the full arduino UNO board, but when using the standalone atmega328 the PWM worked sometimes but then seemed to reset the arduino, and was just generally unstable.

How can I resolve this?

Here is the breadboard: Schematic

Thanks for your help

\$\endgroup\$
  • 1
    \$\begingroup\$ According to your breadboard layout, I don't see any current limiting resistor. Has the LED burned out? \$\endgroup\$ – Long Pham Oct 28 '18 at 15:50
  • 1
    \$\begingroup\$ Welcome to EE.SE! Please show your circuit diagram. If you press edit and click on the schematic symbol, there is a built-in graphical editor. \$\endgroup\$ – winny Oct 28 '18 at 16:14
  • 1
    \$\begingroup\$ Maybe your board is lacking decoupling capacitors, especially if he current driven by the MOSFETs if large enough. \$\endgroup\$ – Charles JOUBERT Oct 28 '18 at 16:40
2
\$\begingroup\$

Your breadboard is missing basic components that are on the Uno.

  1. Connect all the power and Gnd pins on the 328P.

  2. Add 0.1uF caps from VCC, AVCC, and Aref (if making analog measurements). Add a 10uF to 100uF cap from Vcc to Gnd on the incoming 5V power rail.

  3. Add 10K pullup resistor from Reset pin to Vcc.

  4. Make sure the crystal caps are 22pF cap (18, 20, 22, in that range). Folks have been known to use much larger, which keeps the crystal from oscillating.

  5. Add current limit resistor to the LED cathode pins (unless it is just used to represent the LED strip in the drawing).

  6. Add small current limit resistor between the 3 328 IO pins and the MOSFETs gate. I calculate it by treating the gate as a capacitor connected to Gnd that needs to be charged up, and you need to limit that charge current to a safe level. 5V/35mA = 142 ohm, so a 150 ohm resistor is good to protect the 328 pin. (and once high, to discharge a cap that has been charged to 5V, same math applies).

  7. Make sure you have N-MOSFETs that will turn fully on with a 4.5 to 5V gate signal. I was using AOI514 on my boards, but that package has been obsoleted, so now I use AOD514, in a SMD package. Very low Rds, 0.0085 ohm typical to 0.012 ohm max with Vgs 4.5V and up to 20A if properly heat-sinked, altho won't need much at low currents. P = I^2 x R, so at 2A and 12mOhm P = 48mW, which is the range I'm designing for a lot of times. Even at 4A, the Power dissipated by the MOSFET is just 192mW.

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

Welcome to Stack Exchange, it's good to see that I'm not the only one completely new to this!

A few months ago, I build a very similar circuit, just featuring an additional usb port to allow control via my laptop. I ran into the same problems as you do right now.
I cannot guarantee that the following ideas will solve the problem completely, but at least the improved my circuit a lot.

  • Most important, add the decoupling/bypass capacitors Charles JOULBERT mentioned in the comments. 100nF ceramic caps are a good to start with, low ESR types will perform better.
  • Sometimes the AVR needs an additional pullup resistor (~10k) at the RESET pin to support the internal one.
  • If you supply your controller with 5V by stepping down the 12V used by the LED strip as well, you might want to add a big electrolytic capacitor to the 12V side. The current peaks that occur while the LEDs are enalbled could be to much for your power supply to handle.
  • Connecting the gate of a MOSFET directly to a microcontroller can work well for some time, but it can cause noise in the supply line of the microcontroller; over time it might even damage the output pins. The problem is the gate charge (usually some hundred nanocoulombs): whenever switching the MOSFET on or off, a small current must flow to change this charge from 5V to 0V (or the other way round). At high switching frequencies, this adds up to quite a high current, maybe above the current limit of the pin.
    There fore you should:
    • keep the switching (PWM) frequency as low as possible (at some point you will be able to notice the switching although you can't actually see it)
    • add a current limiting resistor (~100 Ohm) between the pin and gate (keep in mind that this will decrease the switching speed and the MOSFET will stay in an high-Rds state longer; this can increase the power dissipation and the MOSFET might get hot)
    • if you can't find a compromise between the low switching frequency (to reduce gate current and power dissipation) and the visual artifacts caused by slow PWM frequencies, you will have to use a MOSFET driver IC to provide the necessary gate current. I think for your application, this is not necessary.

I hope this helps you.

\$\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.