> But then, come to think of it, if the audio is binary (which it > is), > isn't it easier to just gate the DC voltage from the smoothed out > PWM > using the audio signal, instead of attenuating the audio signal? That's an excellent idea - and is more or less what you have done in the circuit you subsequently posted. A capacitor to ground from the wiper of the PWM pot would provide an adequate filter (see below) as you can make the cutoff frequency as low as you wish (ie cap as large as needed) to get smooth DC from your PWM. If you put a filter cap on the PWM pot output its effect will vary as the pot wiper moves. By using an output resistor at least as large as the pot value between pot wiper and switch transistor and placing a filter cap from the transistor end of this resistor to ground you get a more constant impedance and filter cutoff frequency. The present arrangement with the opto gating the pass transistor on is OK provided you get clean on/off switching at all levels of PWM/DC control signal. With 12v supply you risk reverse biasing the PNP switch transistor b-e junction so substantially that some transistors will break down and make magnificent noise generators. Exact breakdown varies with parts. Altering the pot (or two resistors in its place so that it is hard on and hard off will best do what you want - then let the PWM do the actual volume controlling. For small values of smoothed PWM to DC the switch transistor is not going to get enough forward bias to turn on well. As Vc approaches ground, available Vcb with transistor on will decrease - which causes the effect you notice. If you want PWM/DC to go all the way to ground you can replace the PNP with a small cheap N Channel MOSFET with (IMPORTANT) the drain to the PWM pot input and source to the amplifier. This will remove the effect you see now. Put say 100k gate to ground and 10k gate to opto and you will get hard switching with the PWM doing all the volume control. Functionally you COULD swap drain and source and the FET would be just as happy (as, unlike bipolar transistors, they operate in 2 quadrants) BUT the body diode would conduct when Vpwm rose above about 0.6v. Using smoothed PWM / DC allows the PWM to operate very slowly indeed. If you had say a 1 second time constant filter you could use say 100 HZ PWM frame rate = 1600 Hz bit rate for 4 bit PWM. A 1 mS interrupt would suffice. PWM code is almost trivially easy * and very compact. This does however drop the PWM bit rate right into the audio band of interest, but this is unlikely to be an issue given the quality of the sound source and a filter two decades lower than the PWM frequency. The amplifier is arguably "a bit naughty" but if it works OK leave it alone at this stage and work on the above. I have heard credibly good speech and singing through a PC speaker. Maybe you can revive a lost art :-) RM * Inc vPWMCOUNTER IF vPWMCounter > kPWMMax then vPWMCounter = 0 IF vPWMCOUNTER > vPWMLim then bPWMOut = 0 ELSE bPWMOut = 1 ENDIF -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist