4
\$\begingroup\$

I'm trying to learn a bit of AVR coding by using an ATtiny13 controller to drive a number of red LEDs, probably high efficiency indicator LEDs. They are controlled by a push switch, where a long press turns them on/off and short presses vary the LEDs intensity level.

At the moment I think I finished the electronic diagram, but I don't know if is correct or not.

All parts are SMD. This is a gift for a friend and due to time constrains my plan is to make sure the PCB is correct, order it at a supplier in China and during the time boards are delivered to sort out the software bit.

I think I got it right but, just for reassurance, can any of you confirm if it looks ok or not?

I'm tinkering this as a hobby so sorry if the schematic looks a bit hairy or if it contains gross mistakes.

Diagram updated: 47 Ohm resistors added, FET reversed. enter image description here

\$\endgroup\$
12
  • \$\begingroup\$ Quick first glance: Put a current limiting resistor on each LED -- not one for all of them (R2). In addition, that resistor seems to be pretty big, I would've expected something around 22-47 Ohms as a current limiting resistor on each LED. Also, you have two LED5, and the right-hand one does not have a current limiting resistor. \$\endgroup\$
    – orithena
    Jul 11, 2022 at 14:47
  • \$\begingroup\$ Good you noticed, that 10k resistor is supposed to sit on gate, I'll move it now. Second, considering I'm using a coin cell, I don't want to use any resistor for the leds, the internal resistance of the coin cell is 15-20 ohm I believe so the current is self limiting. \$\endgroup\$ Jul 11, 2022 at 15:02
  • \$\begingroup\$ Q2 must be mirrored horizontally or the LEDs will be always on. Red LEDs typically have a forward voltage of 1.8V. This would drain the coin cell very fast without resistors! \$\endgroup\$
    – Jens
    Jul 11, 2022 at 16:04
  • \$\begingroup\$ PB3 must have a pull-up resistor unless the ATTiny has one built-in (does it?). C2 can actually be removed if you're okay with making the software do the debouncing. LED5 should have a series resistor. Draw actual wires instead of using labels when it doesn't add clutter, although that doesn't affect whether the circuit works or not. \$\endgroup\$
    – user253751
    Jul 11, 2022 at 16:15
  • \$\begingroup\$ Good point about the internal resistance of the coin cell -- that internal resistance limits the overall current to 60 mA, making one coin cell suitable to drive at most 3 red LEDs (at a forward voltage of 1.8V). According to this question, a coin cell should not be forced to deliver more than 1mA continuous current or 30mA pulse current (for special high-drain coin cells: 3mA/50mA -- still not enough for 8 LEDs plus a µC). Use a different power source. \$\endgroup\$
    – orithena
    Jul 11, 2022 at 16:16

1 Answer 1

1
\$\begingroup\$

But that's not going to work.

There are no current-limiting resistors for the LEDs.

The moment you turn on a LED, it will be powered from the battery. As the battery has internal resistance and there is no external resistance, connecting the LED to battery will draw all the current possibly available via internal resistance to a LED with about 1.6V of forward voltage.

So basically, voltage of battery terminals is set to 1.6V by the LED and because the MCU does not work at so low voltage it will either reset or it will go into state of malfunction because it does not have sufficient voltage to run properly. Battery voltage gets restored if LEDs turn off, but MCU may need reset or power cycle to restart again.

The FET is also connected incorrectly and the LEDs are constantly on. The 10k on FET gate is also quite high and will drive the FET slowly if the FET needs to be controlled with PWM for dimming.

The capacitor on the pushbutton is also quite useless. It needs some energy to charge it, and you short a charged capacitor with the pushbutton, which will cause large current spikes. I know it is for hardware debouncing, but you also have the processing power of the MCU to debounce buttons in software. Or add another resistor to limit pushbutton current to levels it can handle during discharge.

\$\endgroup\$
4
  • \$\begingroup\$ The FET being wrong has been explained by many people already. Look at the body diode. \$\endgroup\$
    – Justme
    Jul 12, 2022 at 8:29
  • \$\begingroup\$ @BogdanAlecsa Yeah, but the FET will only switch through if its Gate-to-Source voltage is more than 1-2V. The way you wired it, it will only ever get 0V or -3V. An N-Channel MOSFET needs its Source towards GND and its Drain towards Vcc to work. \$\endgroup\$
    – orithena
    Jul 12, 2022 at 8:33
  • \$\begingroup\$ @orithena No the body diode will always conduct if it is connected like that. \$\endgroup\$
    – Justme
    Jul 12, 2022 at 8:35
  • \$\begingroup\$ Will add some 47 ohm resistors for the leds and also reverse the fet. \$\endgroup\$ Jul 12, 2022 at 8:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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