Russell McMahon wrote: > 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. > True. I was wondering why AC coupling it wasn't working -- of course I need a load R. 220ohm/ 1uF is working OK (the resistor gets warm, but nothing to worry about) > >> 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. > 6us looks too low to me. Say I run the PIC at 20Mhz, that would mean a 0.2us instruction cycle, which means 6us would be 30 instructions. Taking into account the interrupt register save/load stuff and the PWM loop, and checking for other interrupts (I'd need other stuff running at a multiple of that period), 30 cycles is too low, and it has to give some time for the main program to run. 16 steps is fine, but not less. >> 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. OK, here is where I get lost with the numbers :P > > An easier approach may be a voltage controlled attenuator where slow speed > PWM is turned into a DC control voltage. This is what I want, isn't it? If I got this right you were (in the previous paragraph) referring to adding a filter *after* the circuit, to the output. But wouldn't it be easier to filter PWM and then feed the DC control voltage to the circuit (base of the controlling transistor)? This is what I was thinking about actually. How can I make PWM into a (clean) DC 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. > The closest I've found to what you mention is: http://users.ece.gatech.edu/~mleach/ece3050/NewNotes/chap02.pdf (last page). Interesting idea... I'll give it a try. -- 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