>> Given PWM of a high enough frequency (20 kHz plus frame rate) you should >> be able to simply gate the audio signal with the PWM OR ground it if the >> supplying impedance is high enough. > Actually, the frequencies coming out of the speaker rarely exceed > 2Khz, so I could even use a lower PWM freq and add a lowpass filter. > But I'm not sure how fast I can push the PWM, since I don't want it > taking too much software time. > Now all I really need to do is replace the pot > with another transistor, something like this: That's exactly what I meant - just needs some "fine tuning". Input bias needs work. If you use a resistor load for the output transistor you can AC couple the speaker and avoid the DC in the speaker coil which does no good to speaker or transistor. > +12V --------------------+------------------+------- > OPTO | | > +------------+ | | _ /| > | _|_ |/C +--| | | > INPUT /_\ --> | --------|_| | > | | |\E |/C \| > +--\/\/\/----+ --/\/\/\-+--| > | |\E > |/C | > FILTERED PWM INPUT >-------| | > |\E | > GND ------------------------------+----+------------ > > But, of course, I either need a filtered mostly clean voltage, or a > very high rate PWM (which I'm not sure I can afford). PWM does not need to be too many bits effectively probably. I'd say 4 bits / 16 steps would do depending on application. If you ran this at say 10 kHz with filtering the bit rate = 1/10kHz x 1/16 =~ 6 uS. A 6 uS IRQ would allow simple PWM in software. This may be easy or crippling depending on processorspeed. > How clean can > you get with some R-C filters? Filters provide 20 dB/decade/pole roll off. Pure RC filters can not have enough Q to be universally useful. You can make a 2 or 3 poe low pass with a single transistor in an emitter follower configuration. 3 poles gives 60 dB at 1 decade. For 2 kHz audio you'd need 20 kHz PWM for 60 dB filtering (or is that 40 - no backs of envelopes to hand :-) ). Two stages of filtergives 4 or 5 poles - sensible upper limit for this technology. An easier approach may be a voltage controlled attenuator where slow speed PWM is turned into a DC control voltage. If you have never met a diode switch/attenuator you're in for some fun. Two diodes say cathode to cathode with positive feed via R's to each anode and a common R from centrepoint to ground. When diodes are DC on AC will pass through the two in series (magic ;-) ). As the R to ground is increased attentuation rises. provide this bias voltage with PWM. Google on diode switch. RM > > -- > Hector Martin (hector@marcansoft.com) > Public Key: http://www.marcansoft.com/hector.asc > > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > > > > -- > No virus found in this incoming message. > Checked by AVG Anti-Virus. > Version: 7.0.308 / Virus Database: 266.11.5 - Release Date: 4/05/2005 > > -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist