Powered by Invision Power Board


Forum Rules Forum Rules (Please read before posting)
  Reply to this topicStart new topicStart Poll

> Low Pass Filter
zonks
Posted: August 01, 2015 02:10 am
Reply to this postQuote Post


Member
****

Group: Trusted Members
Posts: 111
Member No.: 4,146
Joined: January 28, 2006




I've been doing some experiments with PWM using a 5V PIC to drive a small 8-ohm speaker using the following circuit:
https://www.dropbox.com/s/4cbra6zwxs77h0l/schem.png?dl=0

For pure tones it sounds fine, but when I play sampled music or speech there's a lot of high frequency noise present so I'd like to add a simple RC low pass filter to get rid of it.
However with this particular circuit arrangement where the transistor sinks current to energize the speaker coil, I'm not exactly sure where the resistor and capacitor should go.

I initially thought this was the right way:
https://www.dropbox.com/s/6iwbvqvc7v6cz2p/schem2.png?dl=0

The output was inaudible when I tested it. I used Rf=10K, Cf=680pF for a cut-off frequency of around 24 KHz, but I think the problem here is that the resistor appears as part of the load (going from 51+8 ohms to 51+8+10K ohms), so I don't think it should be in series with R1. But then, where?


PM
Top
Sch3mat1c
Posted: August 01, 2015 03:27 am
Reply to this postQuote Post


Forum Addict ++
Group Icon

Group: Moderators
Posts: 20,510
Member No.: 73
Joined: July 24, 2002




What sample rate? What's "high frequency noise"? If it's audible, it's probably not modulation noise, but sampling instead (aliasing or quantization?). Pulses at typical audio sample rates (assuming the resolution of said pulses is good enough) should sound about as good as proper DAC-rendered audio.

For sure, you don't want to add resistance, to an already quiet (maybe?) speaker. Resistors in series are equivalent, so you can just use that first resistor for the job. In which case your capacitor needs to be a lot bigger (~0.1uF?). But actually it needs to be bigger still, because the capacitor is working against the resistance of the speaker (~8 ohms?), not the series resistor -- the series resistor is just there to limit current so the speaker is a manageable volume and doesn't burn out the transistor.

On the upside, the diode is probably unnecessary: the capacitor will shunt away whatever inductance the speaker has.

Tim


--------------------
Answering questions is a tricky subject to practice. Not due to the difficulty of formulating or locating answers, but due to the human inability of asking the right questions; a skill that, were one to possess, would put them in the "answering" category.
PMEmail PosterUsers Website
Top
zonks
Posted: August 01, 2015 03:50 am
Reply to this postQuote Post


Member
****

Group: Trusted Members
Posts: 111
Member No.: 4,146
Joined: January 28, 2006




There's sort of a scratchy, tinny white noise sound that's high pitched, which is what I assumed it was. The sample rate at which I'm varying the duty cycle is about 15.6 KHz.

I see what you mean, I need to keep R fixed and change C. It looks like I can use Cf=120nF with the existing 59 ohm resistance to get about a 22 KHz cutoff. Thanks for clearing that up!
PM
Top
Sch3mat1c
Posted: August 01, 2015 04:02 am
Reply to this postQuote Post


Forum Addict ++
Group Icon

Group: Moderators
Posts: 20,510
Member No.: 73
Joined: July 24, 2002




And PWM rate, and number of bits..?

15.6kHz suggests a maximum output frequency of just shy of 8kHz, which means your filter needs to be at least 7.something kHz, if it's an ideal brick wall! An RC filter is embarrassingly soft, so that to get any useful attenuation at 8kHz, you need a cutoff below 1kHz -- which is going to poop on a lot of your intended audio.

So expect to need more like, uh, speaker resistance might be 6 ohms, so 3.3uF is the minimum to do anything useful here.

If it's too unpleasant, you'll probably want to consider kicking up the sample rate, if you can. Even if you don't have the samples to do it (e.g., if it's stored on a microcontroller, you'll be limited on data storage), there are ways to resample the data so it's smoother (typical example being 192k DACs working on 44kHz audio -- it's upsampled and digitally filtered, saving on analog filter requirements).

Tim


--------------------
Answering questions is a tricky subject to practice. Not due to the difficulty of formulating or locating answers, but due to the human inability of asking the right questions; a skill that, were one to possess, would put them in the "answering" category.
PMEmail PosterUsers Website
Top
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

Topic Options Reply to this topicStart new topicStart Poll

 


:: support us ::




ElectronicsSkin by DutchDork & The-Force