Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Run a Attiny85 for a few seconds on a capacitor

Status
Not open for further replies.

JacobT

New Member
Hi Guys
I have no idea whether this is possible, a good idea or whether there is a better way to do it.

I want to use something like an Attiny85 to run a simple PWM circuit, the "issue" is that the only "signal" I can send to the Attiny is cycling the power. Basically it will be running on a battery and I want to control the PWM by cycling the power. I don't know if there is a better way to do this, but I was thinking if I could run the Attiny for up to 4-5secs off a capacitor, then I would have time to switch the power off and on.
I guess I might be able to put the Attiny in sleep mode for the 4-5 secs and then wake it up if it gets power again, potentially decreasing the power needed while the battery is switched off..?

I have no idea whether there are much better/smarter ways to do this so any help and suggestions are more than welcome.
Thanks
Jacob
 
Why? You ran out of pins? Need one more input?

How will the micro know to switch into sleep mode?
If you remove the power, but there is a capacitor to keep the micro alive, then you have not removed the power. How does the micro know you removed the power?

Please send more information.
 
... I want to control the PWM by cycling the power. ...
Welcome to ETO, jacobT!

Turning the μC on and off to control cycling the PWM signal seems a bit draconian (if not crude).

Is there some critical reason a controlling signal on a IO pin couldn't accomplish the same thing? Even a "presence/absence" of power level on an IO would work.

Unless I'm missing something... (it's been known to happen :woot:).
 
Why? You ran out of pins? Need one more input?

How will the micro know to switch into sleep mode?
If you remove the power, but there is a capacitor to keep the micro alive, then you have not removed the power. How does the micro know you removed the power?

Please send more information.

Hmm yes more information:
Why i would like to control via power cycle: Long'ish story, the PWM will be used to control a heating vest used for diving, the electronics will be situated inside a drysuit and hence I will have no access to it. The battery will be located outside of the drysuit. Instead of trying to make a waterproof switch/button for the PWM circuit (and route it outside the suit) I figured I would use the power switch on the batterypack.

How does the micro know you removed the power?
Well I'm an electronic novice, but I figured I could put a diode between the power supply and the capacitor and then connect an input on the AVR to the power line before the diode. So if the input goes low it knows the power has been turned off and as long as the power gets turned on before the capacitor runs out of juice I could use it as a signal.

If the power is not switched on in time before the capacitor run out then it will reset the AVR to its starting PWM level.

There might very well be much more clever and easy ways to do this.... if so please feel free to point me in the right/better direction.

Thanks
Jacob
 
There might very well be much more clever and easy ways to do this.... if so please feel free to point me in the right/better direction.
A magnet on the outside of the diving suit, operating reed switches or hall switches on the inside of the suit.

JimB
 
A magnet on the outside of the diving suit, operating reed switches or hall switches on the inside of the suit.

JimB
Sure but in my experience such solutions unfortunately don't last very long in a diving environment.

Appart from perhaps being a bit crude, is there a reason not to do it via power cycles?

Thanks
Jacob
 
I used once an accelerometer to sense "impacts" i.e. me hitting the light with my hand to turn it on. That way no external switch was needed. It worked fairly well.

But I see no reason why this would not work. I' going to go on a few assumptions.
  • Space for a big cap would not be an issue.
  • Figure 22-2 in the ATTiny's datasheets suggest a power consumption of 2mA @ 5V and 2MHz.
  • Usage of a 0.5V low-drop 5V voltage regulator
  • The battery's voltage is 12V
Bu using the basic cap equation we can calculate that you would need roughly a 1600µF cap for 5s of reliable of operation time. I see no issue with making the cap for example 4700µF or bigger.


5dbde666850137072c65eb90303fcb9c-2.png
 
Last edited:
Left side; battery then battery connections.
The 10k resistor across the battery is to pull that wire to zero volts when the battery is missing. (important)
Diode, and capacitor.
Next 10k resistor goes to the input of the micro. The resistor is needed because the micro should not look at a voltage higher than its power supply and the battery will be 0.7 volts higher.
Right side; Resistor is the heating element in the vest. MOSFET turns the current on/off. (just saw a mistake. The power to the heating element should come from the battery not through the diode. )
upload_2015-11-23_11-26-12.png

I don't know the Attiny85 very well.
Many of the small micros can use an internal OSC so you don't need an crystal.
Many of the small micros can be run very slow. To reduce power. The 2mA in the above post probably could be cut to 0.5mA or much smaller by cutting the speed. I have run some of the PIC micros at 32khz to reduce power to uAs.
The PWM can be very slow for "heating". If the PWM ran at 1hz it would be fine.
Many of the micros can be put into sleep mode until the timer runs out. Run through your program one and set the timer, then go to sleep. Wake up and loop again.
Shut down pieces of the micro you are not using. (ADC and UART)
 

Attachments

  • upload_2015-11-23_7-27-27.png
    upload_2015-11-23_7-27-27.png
    1.2 MB · Views: 463
Cool guys
Thank you for your help!
I don't have an Attiny85 yet (wanted to check if my idea even made practical sense first), but I'll order up some now and well.. I'll probably be back with more noobish questions :)

Thank you for all your comments and help!!!

-Jacob
 
An important point is that the cap should be before the voltage regulator. Keep in mind that voltage regulators themselved draw some current. A basic 78L05 has quite high quiescent current (3-5mA). The same applies for any other additional circuitry. For example if you add an voltage divider for the a/d converter.
 
An important point is that the cap should be before the voltage regulator. Keep in mind that voltage regulators themselved draw some current. A basic 78L05 has quite high quiescent current (3-5mA). The same applies for any other additional circuitry. For example if you add an voltage divider for the a/d converter.
Hmm good point, though surely I could add a voltage divider before the cap, since I would have no reason to "measure" battery voltage while in the "power off" state?

I think I'll get some Attiny85's and play around with them and see what happens.
A very noobish question can you parallel couple capacitors so I don't have to buy a whole lot of different ones to test different capacities?

Thanks
Jacob
 
Hmm good point, though surely I could add a voltage divider before the cap, since I would have no reason to "measure" battery voltage while in the "power off" state?

I think I'll get some Attiny85's and play around with them and see what happens.
A very noobish question can you parallel couple capacitors so I don't have to buy a whole lot of different ones to test different capacities?

Thanks
Jacob

Yes, that is true, and actually better if your goal is to measure the battery's voltage since then the voltage drop of the diode would not interfere. The point was mainly to keep in mind that you may have other devices that draw current besides the microcontroller.

Yes, paralleling caps will just sum their capacitances. I think that having the devce flat is important in case it is going to be a wearable, and connecting multiple smaller ones in parallel is a good way to do it.
 
It looks like there is a 128khz option.
5.0V supply 128kHz=0.19mA
5.0V supply 1mHz=0.9mA
5.0V supply 20mHz=3mA
While the capacitors discharge, your supply will drop. You probably can't turn on the load at 1.8 volts but look at the current.
1.8V supply 128khz=0.08mA
upload_2015-11-23_17-41-23.png
 
Hi guys
Just a quick update. I've had a fun day (apart from the hangover ;-) ) playing with the Attiny85.
Turns out I can put the Tiny in sleep mode where it only uses 7uA and then wake it up using the watchdog feature after ~4secs.
That means right now it looks like I can get away with using a 470uF capacitor which gives me about 5-8secs of runtime (it probably wakes up twice before it runs out of juice).

Thanks for all the help!
-Jacob
 
You can make it wake sooner and just do a small test and go back to sleep.

What battery voltage?
 
You can make it wake sooner and just do a small test and go back to sleep.

What battery voltage?
Yes I could. But since it will be running a heating element, the slight pause of ~5secs will not be noticed and if I wake it up more frequently it will use more power and therefore need a bigger capacitor, as Hantto guessed I would prefer to make the circuit as physically small as posible so the fewer/smaller caps I can get away with the better :)

The battery voltage is 12v.
 
So you might use a LM7805 to get from 12V to 5V. Then a diode to keep the current flowing on way. Then the big cap.
 
So you might use a LM7805 to get from 12V to 5V. Then a diode to keep the current flowing on way. Then the big cap.

The cap should be after the diode and before the voltage regulator. I would also suggest using a regulator wiht a low quiescent current such as the LP2905.
 
The LP2905 has 80uA of current all the time.
Look at LM2936. I think it has 10uA of internal current. (Vin 40V max)
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top