Basic low-power critique - Page 1
Forum section: electronics / projects

author: microbug
author_rank: Frequent Contributor
timestamp: November 21, 2014, 10:24:42 pm
content: Hi,I'm making a little board with a CR2032 battery and SOT-23-6 ATtiny10 which beeps at random periods ('Beep-a-tron': clone of the ThinkGeek Annoy-a-tron but OSHW and my own design). I haven't done low power stuff before, so I've attached my schematic- are there any glaring errors? I calculated that it should last at least a month with one second beeps every 5 minutes, although this would depend on the value of the speaker power set resistor.For the speaker, I used an arrangement where it is directly powered from a tantalum cap (leakage?), with the coin cell charging the cap beforehand. I did this because the coin cell can't cope with much current at a time, and the speaker will be drawing quite a bit when it is functioning. I am driving the speaker through an N-channel MOSFET (I just realised I don't have a gate-source resistor: should I add one?).There is an SPDT switch which controls whether the board is powered from an external 5V source (when developing software I don't want to be running down my coin cells unecessarily).

author: Dongulus
author_rank: Regular Contributor
timestamp: November 22, 2014, 12:36:16 am
content: Does the /RST signal need a pull up resistor or does the ATtiny have one internally?In regards to your speaker circuit, I think you might have some issues. The time constant for the capacitor charging cycle through the 1K is 100 msec and for the discharging cycle through the speaker, somewhere on the order of a couple of msecs. Over the course of 1 second that you drive the transistor on and off, the capacitor will have plenty of time to discharge most of the way and the battery will not be of much help because it cannot drive much current through such a high resistance.Have you tried verifying the speaker circuit on a breadboard using a CR2032? I would just try testing it using only the CR2032 and no capacitor.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: November 22, 2014, 01:36:46 am
content: The always-on MOSFET will drain the battery in a hurry (via 1k)...As shown, that has to be PMOS, or wire it all upside down to use NMOS.Might not hurt to put some damping (R or R+C) or snubbing (D or R+D) across the speaker as well, just to minimize switching spikes, since the voice coil is inductive.After that, for overall consumption, that's going to depend entirely on how well you've managed low battery mode in the MCU.Tim

author: microbug
author_rank: Frequent Contributor
timestamp: November 22, 2014, 09:06:49 am
content: Thanks! I'll switch to a P channel MOSFET (oops). 100k would give a time constant of 10 seconds for charging up the cap... I'll do some calculations to figure out what to do about the speaker.

author: Zero999
author_rank: Super Contributor
timestamp: November 22, 2014, 12:47:38 pm
content: Why not use a piezo transducer which can be driven directly from the MCU?If you must stick with the dynamic speaker, simply use a N-channel MOSFET, a large decoupling capacitor and keep the duty cycle low enough to avoid a large dip in the power supply voltage.

author: microbug
author_rank: Frequent Contributor
timestamp: November 22, 2014, 01:07:07 pm
content: Quote from: Hero999 on November 22, 2014, 12:47:38 pmBecause I want a randomly varying pitch.For the speaker there are several things I'll do:– get a larger decoupling cap; you can get niobium oxide or tantalum caps which are very large (500-1000uF) in SMD packages– make the resistor between the decoupling cap and the speaker larger (I have yet to decide on a size) in order to decrease the power usage– only play brief beepsEDIT: Given power dissipation across speaker of 100mW:current = 0.1/3 = 0.03333 = 33.33mAvoltage across speaker = 0.03333 * 8 = 0.26664voltage across current limiting resistor = 3 - 0.26664 = 2.73336resistor value = 2.73336 / 0.03333 = 82 ohms

author: microbug
author_rank: Frequent Contributor
timestamp: November 22, 2014, 01:38:37 pm
content: OK, I think I might have been mistaken in selecting a loudspeaker instead of a piezo buzzer. I thought (having read the datasheet) that the 'resonant frequency' specification was the only frequency it would work at; but apparently I am wrong. Since piezo buzzers are much lower power, they would be better. I found an surface mount one (datasheet) which should be fine.Will the volume of a piezo buzzer like that one be too quiet at 2.5-3V? If so, I might consider adding a voltage doubler if I have space on the PCB. The complicating factor is that it will be playing high-frequency (12-20kHz) sounds, which will come out quieter compared to lower frequency ones on the frequency response graph.

author: Zero999
author_rank: Super Contributor
timestamp: November 22, 2014, 01:48:18 pm
content: How loud does it need to be?Musical greetings cards and watches use piezo transducers. To get more volume, use two MCU pins if possible to give double the drive voltage.The higher end of that frequency range won't be heard by most people over 25.

author: microbug
author_rank: Frequent Contributor
timestamp: November 22, 2014, 02:22:44 pm
content: Quote from: Hero999 on November 22, 2014, 01:48:18 pmLoud enough to be heard by multiple people in a normal-sized room when it is not too loud. I don't work in audio much, but I think 60dB would be a 'ballpark' figure.Quote from: Hero999 on November 22, 2014, 01:48:18 pmOK, good idea.Quote from: Hero999 on November 22, 2014, 01:48:18 pmThat's the point... I'm 15 so I'll use this at school

author: microbug
author_rank: Frequent Contributor
timestamp: November 22, 2014, 09:01:38 pm
content: OK, I attached rev 2. I removed the driver circuitry, and changed the speaker to an SMD piezo transducer, powered by two IO pins on the microcontroller. I added ESD protection across the transducer in the form of a comman anode dual zener, and put a small decoupling cap on the battery to be on the safe side.BTW, the ATtiny10 does have an internal pull-up on the `RESET pin.

author: RobK
author_rank: Contributor
timestamp: November 23, 2014, 09:53:16 am
content: Do you really need a microcontroller for this? I'm imagining a 555 timer IC configured to generate the tone frequency. To get different/random tone frequencies, you could use a photoresistor to set the frequency of the 555. Different ambient light levels would generate different tones. You could configure a second timer to set tone on/off periods.I bring this up because it seems there's a tendency to throw a microcontroller in every circuit now. Sometimes it's more interesting to think about how a circuit could be made without one.

author: microbug
author_rank: Frequent Contributor
timestamp: November 23, 2014, 10:01:48 am
content: Quote from: RobK on November 23, 2014, 09:53:16 amI'm using a microcontroller for flexibility; I can easily reprogram it and the pushbutton will allow me to switch between different sound (I won't just have normal beeps). I did consider using a 556 but this way is more flexible.

author: wraper
author_rank: Unknown
timestamp: November 23, 2014, 11:03:13 am
content: why do you need 47k pull-up resistor when there is internal pull-up in the MCU with approximately the same resistance?

author: 8086
author_rank: Super Contributor
timestamp: November 23, 2014, 11:05:18 am
content: Quote from: Hero999 on November 22, 2014, 01:48:18 pmAm I being stupid or is that not how it works? Surely you would be increasing the current capability, how would it increase the voltage?

author: microbug
author_rank: Frequent Contributor
timestamp: November 23, 2014, 11:09:37 am
content: Quote from: 8086 on November 23, 2014, 11:05:18 amI had to think about it as well. When pin 1 is 3V, pin 2 is 0V: there is a 3V difference. When pin 1 is 0V and pin 2 is 3V there is a -3V difference (pin 1 - pin 2 = difference). The peak to peak voltage of the waveform is 6V. Compare this to if pin 2 were grounded: the peak to peak voltage would be 3V

author: microbug
author_rank: Frequent Contributor
timestamp: November 23, 2014, 11:15:33 am
content: Quote from: wraper on November 23, 2014, 11:03:13 amWell spotted! I'll remove it.

author: 8086
author_rank: Super Contributor
timestamp: November 23, 2014, 11:32:42 am
content: Quote from: microbug on November 23, 2014, 11:09:37 amI see, must be the capacitance of the piezo that makes it work then.

author: lapm
author_rank: Frequent Contributor
timestamp: November 23, 2014, 11:55:37 am
content: Quote from: Hero999 on November 22, 2014, 12:47:38 pmI was about suggest piezo transducer...

author: Zero999
author_rank: Super Contributor
timestamp: November 23, 2014, 11:59:12 am
content: Quote from: 8086 on November 23, 2014, 11:32:42 amIt has nothing to do with the capacitance of the transducer.

author: 8086
author_rank: Super Contributor
timestamp: November 23, 2014, 12:03:25 pm
content: Quote from: Hero999 on November 23, 2014, 11:59:12 amSo how does it work? There's only ever 3v or 0v on either output, so there's only ever 3v present on one pin relative to the other.How do you get close to 6v without some external capacitance? If the idea is to drive the pins out of phase to increase the voltage then the capacitance has to be the key.

author: Zero999
author_rank: Super Contributor
timestamp: November 23, 2014, 12:06:24 pm
content: There's never ever 6V, you're confusing peak voltage with peak to peak voltage.Using one pin, you get a waveform which goes from 0V and 3V, a peak to peak voltage of 3V.Using two pins driven anti-phase, you get a waveform which goes from -3V to +3V, a peak to peak voltage of 6V.

author: microbug
author_rank: Frequent Contributor
timestamp: November 23, 2014, 12:11:56 pm
content: ^^ +1Final schematic attached for reference if anyone finds this thread in the future.

author: 8086
author_rank: Super Contributor
timestamp: November 23, 2014, 12:19:30 pm
content: Quote from: Hero999 on November 23, 2014, 12:06:24 pmThe ground reference shifts as well as the 3V. So at 180 degrees phase difference, and no capacitance, you end up with either +3V or -3V between the two pins, but only relative to each other, not relative to ground, so you really only have 3V between them either way, like you said, the peak voltage. This part I understand - but this will only ever result in 3v across the outputs at any one time, unless there is something else at play.Surely the only way to end up with the result you describe is to use the capacitance of the piezo to create a sort of semi-persistent virtual ground/3V reference, in order to give the 6V peak-to-peak.Please tell me if I'm wrong, but if you do, tell me why I'm wrong as well. You haven't saidhowyou get a peak-to-peak (which is what I have meant all along, btw, no confusion) of 6V with this method, just that you do. I'm not necessarily doubting you or that it does work, but it doesn't make any sense to me without using the capacitance.It's not just me, by the way:http://electronics.stackexchange.com/questions/15629/driving-piezo-buzzer-from-mcu-pin

author: dannyf
author_rank: Super Contributor
timestamp: November 23, 2014, 01:11:49 pm
content: It is probably not advisable to power the speaker via the button battery.If you have to have some sound, you may consider piezo elements.

author: Zero999
author_rank: Super Contributor
timestamp: November 23, 2014, 01:22:40 pm
content: Quote from: 8086 on November 23, 2014, 12:19:30 pmAll right let's define peak voltage and peak to peak:Peak to peak voltage is the maximum amplitude of an AC waveform, from its positive excursion to its negative excursion.Peak voltage is the maximum amplitude of an AC waveform with respect to zero.A square wave going from 0V to +3V has a peak voltage of 3V and a peak to peak voltage of 3V.A square wave going from -3V to +3V has a peak voltage of 3V but a peak to peak voltage of 6V.

author: microbug
author_rank: Frequent Contributor
timestamp: November 23, 2014, 01:27:14 pm
content: Quote from: dannyf on November 23, 2014, 01:11:49 pmWhy? I've got a dual common anode zener diode across the piezo transducer to protect against kickback.

author: 8086
author_rank: Super Contributor
timestamp: November 23, 2014, 02:41:16 pm
content: Quote from: Hero999 on November 23, 2014, 01:22:40 pmI don't have a problem with any of those statements, but I thought it wouldn't work that way in practice.As it turns out, it does. I just tried it myself. I stand corrected.It works, at least on my 'scope.

author: lewis
author_rank: Frequent Contributor
timestamp: November 23, 2014, 02:46:04 pm
content: It certainly does work, and very well. Google 'Amplifier bridging'.

author: Zero999
author_rank: Super Contributor
timestamp: November 23, 2014, 06:07:34 pm
content: Quote from: microbug on November 23, 2014, 01:27:14 pmThere's nothing wrong with your circuit and yes zener diodes are a good idea, as a piezo can generate fairly high voltages, in response to mechanical shock. I think the reason for the confusion was because you didn't change the symbol in your circuit.http://electronicsclub.info/circuitsymbols.htm#audioQuote from: 8086 on November 23, 2014, 02:41:16 pmIt's effectively an H-bridge. When one pin is high and the other low, the voltage is positive and when the logic levels are reversed, the polarity goes negative. The piezo will be louder because the voltage swing is double and it's being powered continuously.