0

My goal is to save energy, and I intend to do so by powering a chip with itself, and cut power whenever unnecessary. The best image I can have is of a startled monkey who jumps on the branch, screams its profanities while holding to the branch, and when the screams are done, lets go of the branch and falls back on the floor, asleep.

The chip, in my case an ATtiny45, has a program that just makes a specific sound (hopefully more pleasing than an angry monkey's) with a PWM, but would also power an output pin connecting to a transistor acting as a relay between the battery and the power pin.

This is the ideal protocol:

(No closed circuit, no power)
Press Button
Battery power goes through to transistor
Transistor allows current from Battery to PWR pin
Software: Chip starts PWM to Speaker and Outputs constantly the Hold Pin
Hold pin powers the transistor and thus the chip for when the button won't be pressed
Software: When Button still pressed, makes Chip Scream louder
Software: Button not pressed anymore makes chip scream softer until it's done screaming
Software: Scream is finished, stops powering the Hold Pin
Transistor isn't powering the chip anymore.

I think the idea is plausible, though I can't test it at the moment due to not having NPN transistors (?)

My questions are the following:

  • Truth: Is is possible for a transistor as relay to power a chip on demand?
  • Risks: Is the power going to be stronger due to the amplifying nature of the transistor? What about the chip, I've read that a chip can maintain its code for 20+ years without power supply. Is this true?
  • Goals: Is there a better way to save power? Would it be best for the chip to just have sleep enabled?
  • Name: If this works, is there a better name than the Startled Monkey?

Thanks again for your help, this community has already taught me a lot!

schematic

simulate this circuit – Schematic created using CircuitLab

  • 1
    why do you expect the ATtiny45 to wake up when it is disconnected from power? ... research deep sleep – jsotola Jan 13 at 8:04
  • 2
    I have a feeling, that you would need a PNP transistor in this case, because you need a specific minimum voltage difference between base and emitter for the NPN transistor to get conductive, which would not work with the MCU connected to the emitter. NPN transistors are usually low side switches, not high side. Currently not sure about that, but I've definitely seen a good answer somewhere from Majenko, who described a similar circuit, only based on NMOS transistors. – chrisl Jan 13 at 8:10
1

I think all this effort is unnecessary. The ATTINY45 pulls a maximum of 2uA when sleeping...

enter image description here

..and in practice I've found the typical current to be much less.

If, say, you are using AAA batteries for you project then you could sleep for more than 100 years. In practice your batteries will self discharge long before this, so any potential power savings by completely disconnecting the chip are wasted (and remember there is some leakage loss though the transistors that might even be more than the sleep power used by the ATTINY).

Instead connect the batteries directly to the power pins of the ATTINY and connect the button between any IO pin and ground. Activate the internal pullup on the IO pin and then set a pinchange interrupt on that pin to wake the chip when the button is pressed. Now go to sleep and wait for a button press to wake you.

  • 1
    A lot more simple and practical than my aspiration, especially due to the fact I need to do it for multiple units. Thank you! – B7th Jan 24 at 6:01
2

Your idea is sound, but your implementation is flawed.

First, you don't want to bother with "wake" and things like that - when the chip gets power it just starts from scratch - that's your "wake" signal. Your code will just be "Hold it on" and "Make a sound" followed by "Let it switch off".

You only need one IO pin for that - the "Hold it on" signal. The "catch" signal in your schematic is just the chip getting power.

And then there's your schematic. You should really use a P-channel MOSFET to do the switching of the power, not an NPN transistor. An NPN won't work, and a PNP (which would be what you would use for this if you were using a BJT) would impose a voltage drop, which you don't want.

Your circuit would in fact need to look like this:

schematic

simulate this circuit – Schematic created using CircuitLab

When idle M1 (P-channel with threshold voltage well below the battery voltage) is turned off by R1 pulling the gate up to the source voltage. Pressing the button pulls the gate below its threshold voltage allowing M1 to turn on. The chip then gets power.

M2 (N-channel with threshold voltage well below the chip voltage) is then activated by the chip by driving the GPIO HIGH to bypass the switch and connect the gate of M1 to GND. R2 keeps M2 turned off while idle.

M2 is needed so that there is no current flow between the battery and the GPIO when the power is turned off. Without it current can flow through R1 into the GPIO, through the ESD protection diodes inside the chip, and potentially break the chip.

Now to help clear up some of your questions:

Truth: Is is possible for a transistor as relay to power a chip on demand?

Yes, it is.

Risks: Is the power going to be stronger due to the amplifying nature of the transistor?

No. Amplification, with a BJT, is really a misnomer. It doesn't "amplify" a signal, it takes one small signal and uses that to proportionally control a larger signal. But that's only in the "linear" portion of the curve. When used in "saturation" like this it's more like a switch - power applied to the base turns on the flow of current from collector to emitter.

What about the chip, I've read that a chip can maintain its code for 20+ years without power supply. Is this true?

Yep. Flash memory typically has a retention time in the order of 10 to 100 years. 20 years is a reasonable ballpark figure.

Goals: Is there a better way to save power? Would it be best for the chip to just have sleep enabled?

Zero power is the best low power there is. Even in the deepest sleep mode the chip will still draw power. But if you do it right there can be little difference between the current drawn by a sleeping chip and the self-discharge of a battery as it sits idle.

Name: If this works, is there a better name than the Startled Monkey?

I like the name Startled Monkey. I think I'll use that in future myself.

  • Wow @Majenko this is a thorough answer that makes me understand a lot more! For the PNP, the fact that it does a voltage drop actually would solve another problem of mine. As per another question I posted, 2x3V batteries are too much voltage and could likely destroy the chip, and the PNP induced voltage drop could work, depending on how much voltage is dropped? – B7th Jan 13 at 10:34
  • 1
    @B7th A diode won't protect the chip from the incoming current when turned off. You need to sink current from the gate of the P-channel, which means the diode would have to be oriented to allow current flow into the chip - thus negating any possible protection. The resistors are purely pullup/down resistors to keep the gates at the right level when the chip is unpowered. – Majenko Jan 13 at 10:49
  • 1
    @B7th And for the battery voltage you should be considering a proper buck regulator with very low (or zero) dropout voltage, or at worst a zener diode to clamp the voltage at 5V (which is wasteful of power). – Majenko Jan 13 at 10:54
  • 1
    @B7th You can get a single chip with the P/N channel MOSFETs in them as a pair, such as this one (though of course check your current requirements, but it sounds like you don't need much). – Majenko Jan 13 at 11:36
  • 1
    If you need that many of them, it might be better to not do this in hardware, but putting the chips in sleepmode instead. That way, all that's needed is the chip, the button, and the buzzer. It's perhaps a bit more work to get the software right, but you only need to do that once, not 12-32 times. Current in sleepmode should be negligible, like Majenko said. – Gerben Jan 13 at 14:36

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.