I have an interesting design challenge. Reed switch S1 is feeding pulses at a maximum of five per second into a 3.3 V microcontroller input. I want to halve the pulse rate. I don't have access to the 3.3 V supply so I hope to power the circuit from the original reed switch's pull-up resistor! This may be possible if I can keep the average current requirements low by putting the ATtiny85 to sleep between pulses from the reed switch, S1 below, and running at 1 MHz.
Figure 1. S1 is (normally) connected to SENSOR IN. I want to power an ATtiny85 from the pull-up resistor R2 and only pass every second pulse through by pulling J1-2 to ground by PB1.
The plan:
- Charge up C2 via R2 and D1. This has to provide adequate voltage stability to power the Tiny during the 10 ms pulses when PB1 pulls low.
- Configure PB2 as an interrupt and have S1 wake up the Tiny, check if it's an odd or even pulse and, if even, set PB1 to LOW for 10 ms.
- Go back to sleep.
- The Tiny should draw about 1 mA while awake running at 1 MHz. At 5% duty cycle I'd have a 50 uA average current resulting in an average voltage drop on R2 of 150 mV.
simulate this circuit – Schematic created using CircuitLab
Figure 2. A crude simulation of the circuit. PWM1, etc. represents the duty-cycle of the ATtiny85 while PWM2, etc. represents PB1 pulling the J1-2 line low.
Figure 3. The results of the simulation.
The results are pretty much as expected but leave me with a few questions:
As drawn PB1 is connected to a line which is one diode-drop higher than the Tiny's VCC. I can see two ways to address this: - Use a Schottky diode for D1 which will give several improvements including reducing the overvoltage on PB1. - Add a diode on PB1 input to match the voltage drop on D1. This isn't likely to help much as there should be little current flowing.
- What's the best way to address the points above?
- I've never run a micro as low as 2.3 V before. Are there any pitfalls I need to be aware of?
Many thanks.