My first try at using a mosfet.EDIT:lower standby cuurent of SPI LED - Page 1
Forum section: electronics / beginners

author: buck converter
author_rank: Regular Contributor
timestamp: July 24, 2017, 12:23:05 am
content: Progress with my project was going full speed ahead until I realized that apa102 addressable leds use too much current even when the LEDs are off for a battery powered device. So i thought i could use a Mosfet as a switch so they could be turned on with a HIGH signal from a attiny85, and disconnected from ground when the attiny sleeps. After watching a few videos about mosfets, I came up with a diagram. Would this work?Here is the datasheet.https://www.diodes.com/assets/Datasheets/DMN65D8L.pdf

author: Nusa
author_rank: Super Contributor
timestamp: July 24, 2017, 12:42:13 am
content: Don't disconnect it from ground, disconnect it from power. Then you don't have to worry about the data lines providing a path to ground in the off state.

author: rs20
author_rank: Super Contributor
timestamp: July 24, 2017, 12:47:49 am
content: That's not a complete diagram, as you haven't drawn the data and clock connections for the APA102 LEDs. If you have those connected directly to the Attiny85, you'll have to be mighty careful because:If you take the gate of the MOSFET low, the MOSFET switches off, so the drain voltage of the MOSFET rises to the (say) 4.2V from the LiPo. This is correct, it's what you want, because that means that both the VCC and GND of the APA102 are at (say) 4.2V, so there's zero voltsacrossthe APA102, i.e., it's off.However, if you were to make a software mistake, and program the attiny to make it output a '0' on the clock line, that would mean you had:APA102 VCC: 4.2VAPA102 GND: 4.2VAPA102 CI: 0VIn other words, from the APA102's point of view, you'd be applyingnegative4.2V to the CI pin. This is in excess of the limits of the datasheet, and could cause damage, or the LEDs would try to power themselves via the protection diodes in the APA102. The same goes for the DI pin as well.So it'll work fine, but you have to be absolutely sure that your code leaves the DI and CI pins either high or floating before switching the MOSFET off.If this seems confusing, you might consider using a P-channel MOSFET to switch off the supply to the APA102, rather than using an N-channel MOSFET to switch off the ground connection. This might be a bit easier to understand, although you still have to be 100% sure that if the MOSFET is switched off, you must have the DI and CI pins eitherlowor floating.Quote from: Nusa on July 24, 2017, 12:42:13 amCorrect, except if you disconnect the power, you have to be equally worried about the datalines providing a path to VCC in the off state, it's exactly the same problem. It's just easier to intuitively understand the risk if you disconnect from power.

author: buck converter
author_rank: Regular Contributor
timestamp: July 24, 2017, 01:10:04 am
content: Ok, I think I will use a P channel Mosfet, would high-value current limiting resistors on the dataline protect the LED

author: rs20
author_rank: Super Contributor
timestamp: July 24, 2017, 01:21:38 am
content: Quote from: buck converter on July 24, 2017, 01:10:04 amThe DI and CI pins shouldn't draw very much current, so indeed some resistors could offer some protection from programming errors. Just be wary not too make the resistors too large; or else they'll form an RC filter with the input capacitance of the DI and CI pins, and limit the max frequency that you can drive the LEDs at as a result.Thedatasheetthat I found for the APA102 is absolutely awful, it doesn't offer any information that might be helpful for selecting this resistor value (input pin currents, input pin capacitances, etc). I'd go with 100 ohms to 1k as a first guess, I dunno.This is a somewhat subjective decision, some think that the added cost, effort, and potential issues of adding these resistors might outweigh the cost/risk of programming errors. I'm on the fence myself. Up to you.

author: buck converter
author_rank: Regular Contributor
timestamp: July 24, 2017, 01:34:50 am
content: Hmm... any other ways to lower standby current? This is a one-off project, so i'm not worried about cost / effort of LEDS

author: rs20
author_rank: Super Contributor
timestamp: July 24, 2017, 03:35:30 am
content: No, cutting power to the power-hungry device is absolutely the right and best way of reducing power consumption. You can consider other additional power-saving measures too, like exploiting the sleep modes of the attiny.Please don't interpret my previous message as any sort of questioning of your overall strategy, I was only commenting that the specific idea of using those protection resistors is an idea that some people would encourage and others would discourage.