41 Replies Latest reply on Mar 14, 2020 5:03 PM by shabaz

# Trying to understand how R & C affect an audio signal when used in a high pass filter

Hi all,

I am looking at creating a simple high pass filter for a microphone breakout board which will be attached to a MCU.

I'm not an electronics engineer so this is probably a simple 101 type question for those who are.

I've learnt from Wikipedia that the formula for determining the cut off frequency is:

and that R x C is the time constant.

Now what I am trying to learn is how else does R and C impact the audio signal as this presents me with 2 degrees of freedom.

For example if I went with a 100 ohm resistor and say used a 1 uF capacitor, how does this compare with a 100k Ohm resistor and a 1 nF capacitor as both these options give me the same fc.

I'm assuming it must impact that ramp up curve but not sure how (image source Wikipedia).

Hence the question to the community experts.

The circuit I'm using is as follows:

• ###### Re: Trying to understand how R & C affect an audio signal when used in a high pass filter

The formula is absolutely correct, the actual values of R and C don't matter in the context of the circuit you have drawn.

The plot you have attached is not quite correct for the circuit you have drawn (the very LF end of the trace is "turning up" which it should not do).

In real life the source and load that are not shown in the circuit might have an additional effect.

Try simulating with a source resistance equal to R and you'll see some difference, or add some parasitic capacitance to the load.

Other things matter too, if the R is large the filter may cause noise, partly because of thermal noise in the resistor and partly because the amplifier after the filter may be quieter if driven from a low source impedance.

For a microphone you might want fc to be 100Hz, a good value of capacitor, if you don't much care about noise, would be 100nF, which you can easily get in plastic film or ceramic surface mount at low cost. For audio with any pretensions to quality you should avoid ceramic capacitors because they are often microphonic. Your 100nF cap would need a 16k resistor. If you do care about noise then it gets a bit more complicated and you would need to know what kind of microphone and the design of the load circuits to make a choice.

MK

3 of 3 people found this helpful
• ###### Re: Trying to understand how R & C affect an audio signal when used in a high pass filter

Thanks for insight.

Maybe I should've also stated my intentions with the high pass filter as that may sway things.

What I am hoping to do is only capture frequencies above 1.5kHz or even 3kHz and frequencies below that are ignored or significantly dampened,

I had been toying with another acoustics project idea when I stumbled across this article: https://blog.medel.com/the-best-smoke-detector-for-hearing-loss/

• ###### Re: Trying to understand how R & C affect an audio signal when used in a high pass filter

If you plan to feed the microphone signal into a processor port you might need an amplifier but the smoke alarm may be loud enough that you don't.

You could almost certainly get away with a passive filter between the processor and the microphone - if you can tell me which microphone you will use I could suggest a filter circuit.

MK

1 of 1 people found this helpful
• ###### Re: Trying to understand how R & C affect an audio signal when used in a high pass filter

I was planning to start by using an amplified mic breakout, as I have quite a few different ones. I was planning to place the high pass filter post amplification but before MCU input

I think I have some electrec and mems microphones lying around too in some box somewhere.

Open to all suggestions.

1 of 1 people found this helpful
• ###### Re: Trying to understand how R & C affect an audio signal when used in a high pass filter

The Freetronics module has a digital output or an analogue output. It has more gain than you will need and some filtering around the op amp. You could easily mod the board to give you the gain and frequency response you want.

(Change C1 to 10nF to get 1.59 kHz lf cut off and reduce R4 to perhaps as low as 20k to get the gain down (you will need to check signals when listening to the Smoke Alarm)). You could change the capacitor across R4 to add some HF filtering.

MK

2 of 2 people found this helpful
• ###### Re: Trying to understand how R & C affect an audio signal when used in a high pass filter

I'm rather pleased I decided to post this question as the freetronics mic option was not my first choice. Nice that these are 0603 components so can hand solder without too much difficulty.  So, thanks for your help.

When you say "you could change the capacitor across R4 to add some HF filtering." are you referring to C2.

• ###### Re: Trying to understand how R & C affect an audio signal when used in a high pass filter

Yes, C2 working with R4 sets a low pass cut off at 1/(2.pi.R4.C2) but only if R4 >> R3 (ie R4 >> 5 x R3).

This implies that you can only use R4,C2 as the low pass filter if the amplifier is required to have some gain.

I just checked, the amplifier on the Freetronics board does not have rail to rail output, which means that if you do the obvious and power it from 3.3V to work with a 3.3V micro then it won't work well.

You could change the op amp for a true rail to rail input and output part, or use the Sparkfun board which costs a little more and has only analogue output but has a more suitable op amp fitted.

MK

1 of 1 people found this helpful
• ###### Re: Trying to understand how R & C affect an audio signal when used in a high pass filter

Hi Michael

I am trying to get an intuitive feel for what changing C2 in the Freetronics board does.  If there is no C2 then there is a straight forward inverting amplifier with gain of R4 / R2.  With C2 parallel to R4 in place then at higher frequencies the gain would intuitively be reduced because the negative feedback impedance of the op amp is reduced which reduces gain and thus it acts as a low pass filter.  Is that a valid way to think about it?

Anyway, if the values on the Freetronics board are placed into the formula you give above then I get cut off at 13,200 Hz.  This seems low given human hearing and electret mics (maybe not cheap ones) can detect higher.

Ignoring R2 for the moment I set up a spreadsheet and calculated the impedance for R4 and C2 in parallel and varied it with frequency.  Column 6 is the resultant total impedance and column 7 is the phase angle.  Then assume the total impedance in column 6 can be divided by R2 (10,000 ohm) to get the gain as given in column 8.  Varying the frequency in column 3 gives a 50% gain reduction at roughly 22 kHz by this method.  So my question is whether this is a proper calculation and also wouldn't the phase angle distort the sound?  It does not give sharp cut off either.  Is it a good idea to even have C2 in this application?

Finally, I don't understand what is being done with the sound pressure level output.  The notes on the schematic say that the pin voltage varies with sound pressure level.  But it looks like a comparator with a low pass filter following it.  The comparison voltage is set at roughly 0.07 V with a voltage divider.  The notes describe the low pass filter (I get 60.29 Hz cut off) as “sound level storage.”  I can see where it does something but it doesn't seem like it is meaningful sound pressure level which is normally given in decibels.

Thanks for the thoughtful and knowledgeable answers you give.

Frank

1 of 1 people found this helpful
• ###### Re: Trying to understand how R & C affect an audio signal when used in a high pass filter

Your opening paragraph explains what C2 does in a simple and sensible way - it's a good way to think broadly about what the circuit is doing.

The cut off frequency of a filter is usually defined as the -3dB point, at which the relative gain is 0.7079 of the passband gain.

Your table puts this between 12kHz and 14kHz which agrees with the 1/2piRC value of 13.269kHz.

For a general purpose microphone board this is a sensible choice, you want to keep the bandwidth as low as possible to reduce the chance of unwanted signals interfering.

Most people get very little information from frequencies above 10kHz even though they can detect them - for HiFi it would be bad but for most other stuff just fine.

The output pin labelled MIC is the analogue output and does vary with sound pressure. The SPL pin is the output of a comparator, LP filtered by R10 and C6. The output of IC1B will approximate to pulses who's width will vary according to the sound frequency and amplitude. The filter will smooth these out a bit so you will get a reasonable result if you connect to a digital input and treat the signal as sound present/not present.

There are better ways of doing it, but it's hard to think of one that's any cheaper !

C2 is a good thing, with any measuring system it is usually (almost always) a good idea to reduce the input bandwidth to the least possible to reduce noise and the effect of interference.

It won't work in practice quite like your table because the gain bandwidth product of the TLC272 amplifier is only 1.7MHz at room temperature.

This means that the amplifier gain is about 128 at the cut off frequency but the gain of the circuit with a perfect amplifier would be 70.1, a good rule of thumb is that you need a gain margin of at least 5 for feedback amplifiers to work within a dB or so of expectations, so I reckon that if you actually measure this circuit the -3dB cut off will be at a slightly lower frequency than 13.2kHz.

MK

4 of 4 people found this helpful
• ###### Re: Trying to understand how R & C affect an audio signal when used in a high pass filter

Thanks - great explanation.  I will add this to the list of things I would like to build and experiment with but may never get to :-)

• ###### Re: Trying to understand how R & C affect an audio signal when used in a high pass filter

Although Michael is right, everyone always designs with -3dB for the cut-off, a pedant would say that strictly it's -3.01023.. dB. It's the point where the amplitude is down by one over root two [x 0.7071..].

In books, you'll sometimes see it referred to as 'characteristic frequency' rather than 'cut-off frequency'.

To answer the phase question, as far as I understand it our ears aren't sensitive to phase differences. Apparently, if you take the harmonics that make up a square wave, and adjust the phase relationships between them so that it no longer looks like a square wave, it will still sound like a squarewave [I've not done this myself, so can't vouch for that from personal experience].

1 of 1 people found this helpful
• ###### Re: Trying to understand how R & C affect an audio signal when used in a high pass filter

I found these small Panasonic film caps when I was working on a project over xmas; I hadn't seen surface-mount film caps before!

• ###### Re: Trying to understand how R & C affect an audio signal when used in a high pass filter

I'm a bit worried about using those except when re-flowed properly in a decent oven - but apart from that they are quite nice.

They don't quote temperature coefficient.

MK

1 of 1 people found this helpful
• ###### Re: Trying to understand how R & C affect an audio signal when used in a high pass filter

I wasn't too sure doing it manually either : ) Tried soldering them as quickly as I could..

These are the 1uF parts in the photo below.

• ###### Re: Trying to understand how R & C affect an audio signal when used in a high pass filter

Hi Colin,

Just thinking, if this is not a hi-fi application, if you do not currently have a suitable board, are you ok with building an amplifier with a transistor and passives?

It's an option, but probably more time-consuming than modifying an existing board.

I built an outdoor mic quite a long time ago, it operates at 12V because that's what I needed at the time, but I could dig up the circuit diagram and tweak it for 3.3V if you like. (t's nothing special, typical basic single-transistor amp, but works ok for speech etc). But if you've already got mic-boards and are just modifying those to meet your needs then that's quicker of course.

1 of 1 people found this helpful
• ###### Re: Trying to understand how R & C affect an audio signal when used in a high pass filter

Hi Shabaz

No hi-fi needed. As noted above, I want the mic to only pick up smoke / fire / burglar alarms and mask / dampen all the low frequencies out so as not to be listening in on peoples conversations etc.

I have two options up for consideration. In both cases they'll make use of a 3.3V MCU.

Option 1 is a hardware filter with an analog, or possibly digital, microphone. Option 2 is purely the software route using a digital PDM or I2S microphone.

For option 1 I was looking at low cost (8-bit) MCU options, such as Silabs EFM8 (8051) MCU, In this case I made a presumption that it would be better to use hardware to create my high-pass filter. I rather like the EFM8 as has good ADC speed and resolution for this purpose.

For option 2, I spotted that within CMSIS-Pack (e.g. with the RSL10-SENSE) there was some DSP filtering libraries which could be used in this case. For this option, I would need a more powerful MCU (32bit etc.)

Hope that makes sense.

PS. I already have a 12V microphone (must've bought on a clearance sale or something). I haven't looked at this circuit as yet.

• ###### Re: Trying to understand how R & C affect an audio signal when used in a high pass filter

I see.. In that case both are good options.. it sounds like the option 2 is flexible, since then it can be adapted for screams or breaking glass and so on too, and option 1 is possibly cheaper for the purpose of specifically detecting alarms.

The photo you've got looks similar to what I built - a single transistor and optionally a voltage regulator. Mine was long like that too, in a tube, mic pointed down and sealed from the top, to become a rain-resistant mic. It's installed elsewhere otherwise I'd take a photo of it. It's straightforward to high-pass filter (just first order filter) by reducing the capacitance coupling the electret mic element output to the transistor (there should be a capacitor close to the mic element but I can't see it; maybe it is on the other side in the photo above). But not easy to run that that existing built circuit in your photo at 3.3V, since you'd have to desolder most of the resistors to re-bias things to support that lower voltage.

1 of 1 people found this helpful
• ###### Re: Trying to understand how R & C affect an audio signal when used in a high pass filter

Thanks for the helpful feedback. I had a look and no filter cap on the other side of my 12V mic-module. Anyhow, as you say this mic-module not much use at 3.3V.

• ###### Re: Trying to understand how R & C affect an audio signal when used in a high pass filter

I had some time last night to try an experiment, and got a single-BJT implementation working on 3.3V.. photo below shows it (the top part is all that's needed, the bottom part is just a 3.3V regulator which isn't needed if the 3.3V power rail already exists.

If I talk at normal conversation volume at 30 cm away from the mic, then I see 250 mVp-p output on a 'scope.

I used a 10uF input capacitor for normal audio response, but dropping it to (say) 1uF or 100nF would give a more high-pass response. I can sketch out the schematic if this looks an acceptable level of construction as an alternative to the existing boards. The active part was a BC547C transistor. There's a few resistors on the underside (I only had surface-mount resistors handy so they are soldered across the tracks on the underside).

3 of 3 people found this helpful
• ###### Re: Trying to understand how R & C affect an audio signal when used in a high pass filter

Hi Shabaz

Yes, that would be fantastic if you could sketch out a schematic to help me understand the combinations of resistors and capacitors used.

What I did not understand, as I lack the knowledge, is what you meant by "The active part was a BC547C transistor." Aaaah, it just dawned on me now... me thinks this could have something to do with amplification (gain)...

• ###### Re: Trying to understand how R & C affect an audio signal when used in a high pass filter

Hi Colin,

This is the circuit I used. the 'Audio output' can be fed to a normal speaker amplifier if desired, but for a microcontroller you should omit C5 and R7 and connect the 'Microcontroller ADC Input' signal directly, since it will be within 0..3.3V range.

A couple of large polarized caps are used, but they can be quite small physically, e.g. 10V rated ones, since the supply is just 3.3V.

You'll want to decrease C1 to get the high-pass effect. Worth replacing that with 1uF or 100nF for smoke alarm tones. For normal audio use, it would be larger, like (say) 4.7uF or (as shown) 10uF.

4 of 4 people found this helpful
• ###### Re: Trying to understand how R & C affect an audio signal when used in a high pass filter

Thanks

• ###### Re: Trying to understand how R & C affect an audio signal when used in a high pass filter

The DC operating point doesn't look quite right in LTSpice:

What do you see on Q1 collector in real life ?

Reduce R4 to 1k2 and it's much nearer the mid point, and can manage 1.6V pk-pk with a bit of distortion:

The frequency response is a bit wide open:

The response can be tamed with the addition of R4, C4 and C6

MK

5 of 5 people found this helpful
• ###### Re: Trying to understand how R & C affect an audio signal when used in a high pass filter

Hi Michael,

I just took my older 12V design and changed a few values, and didn't calculate. You're right, the level wasn't centred, however it didn't seem to clip or noticeably distort for the expected signal range (I recorded some audio talking near it) from the electret element, so I didn't tweak further. I was tempted to sound the alarm to try to record that hehe but it was late so not a good idea : ) I don't know if the aim is for it to be installed close to the smoke alarm or on a wall or desk though. That's a good idea with C4. I'll pull off my audio recording onto a server (I spoke some numbers at normal conversation level at 30 cm away). I've not tested it much further though, so I could try sounding the alarm later today! : )

• ###### Re: Trying to understand how R & C affect an audio signal when used in a high pass filter

shabaz  wrote:

I don't know if the aim is for it to be installed close to the smoke alarm or on a wall or desk though.

That depends on application, I suppose. It could even be a wearable too. A wearable is a useful device for those who have a hearing impairment as you can add haptic feedback and some neopixels or oled screen to inform that an alarm has been triggered. With some smarts it could even say what type of alarm has been detected etc.

So, I certainly want something that can handle a range of volumes (or sound pressure) but will still be limited to a specific frequency range. Needless to say, the application could be extended beyond smoke alarms.

Another idea I had, which came about when my daughter had spent a good while in hospital and was hooked up to one these SATS machines. I wanted a way to still alert hospital staff while keeping the volume on this device's alarm low.

Ask any nursing staff and they will agree with me. These things are traumatising as inside a ward you constantly hear these things alarming. Spend a few days there and it effects you. The dilemma is that when the volume is low that's good for the people inside the room but no good for those outside of the room, and vice versa.

So, why not place a little microphone on top of the monitor and attach this microphone to a BLE MCU and this can then send personal alerts etc. to those who have a BLE wearable when those alarm frequencies and sound patterns are recognised.

• ###### Re: Trying to understand how R & C affect an audio signal when used in a high pass filter

I just realized the only recording I have is when it was on a desk, and I was about a metre away, talking at normal conversation level. I didn't record it when I was 30 cm away. Anyway, that 1 metre recording is here: https://app.box.com/s/si8543f38xguxz6elz8jvgndlg3cnqei

I just checked, and Q1 collector is at 0.7V, so as you say it would benefit for being centred more. I'll make the modifications you mention (i.e. including C4 and C6 and R8) so that it's optimal, and then record the smoke alarm! It will be nice having a 3.3V design that can be used for many projects with microcontrollers.

• ###### Re: Trying to understand how R & C affect an audio signal when used in a high pass filter

This exchange was interesting.

One observation: if you drop the value of the input capacitor to 1uF or less, you could also afford to drop the emitter capacitor in value too [would help a bit if it needs to be compact].

I hadn't realised you could use electrets at 3.3V: somehow, I had it in my head that they needed more voltage than that. Is this a modern thing or has it always been the case?

• ###### Re: Trying to understand how R & C affect an audio signal when used in a high pass filter

Hi Jon,

That's a great idea. I think 1uF will easily cover the useful audio range. Regarding electrets, I assumed since it was a JFET inside, that it could work from lower voltage, but it's a good point, now I think about it, I've never tried it at such a low voltage either. I have a different electret element at home, so I can try that too, in case there's a difference.

• ###### Re: Trying to understand how R & C affect an audio signal when used in a high pass filter

I randomly looked through 6-7 datasheets of current manufacturers and standard operating voltage of 1.5 to 2 V with 10 V max does not seem uncommon for the electret mics I looked at.  At this point the BJT design gives good response across the range of human hearing so I presume the next step is to place a high pass or even band band pass filter after the output.

• ###### Re: Trying to understand how R & C affect an audio signal when used in a high pass filter

What Shabaz says makes sense, the bias for a JFET would be quite low. I think it's an example of me making assumptions a long, long time ago [when analogue circuits would never have been operating off a 3.3V rail] and then cherishing them as fact until some clever person comes along and proves them wrong.

I think I might have some old electrets somewhere [decades old], so if I can find them I could try it out and see for myself.

The suggestion further up the thread was to reduce the input coupling capacitor to give the high-pass response [only first order, though].

• ###### Re: Trying to understand how R & C affect an audio signal when used in a high pass filter

Yes, I am having some trouble keeping up :-).  My calculation table with a table was on a cap in the negative feedback on an op amp.  Looking back, you are correct and the original question was on input coupling. That would reduce parts count over a filter on the output.

• ###### Re: Trying to understand how R & C affect an audio signal when used in a high pass filter

That's neat. Essentially it's just an op amp so you could easily use the circuit of Figure 2 in the datasheet with other low-voltage CMOS devices with a reasonable GBP. If you wanted to.

• ###### Re: Trying to understand how R & C affect an audio signal when used in a high pass filter

I made the change as in michaelkellett last diagram, i.e. changed R4 from 2.2k to 1.2k, and added C4 and C6 and R8. It works really well : )

And as mentioned by jc2048 C2 can be reduced (as can C1) if the low end isn't needed, but I kept those at the original values I had for now.

For a test, I placed the circuit on a table, at a distance diagonally of a few metres from the smoke alarm (a typical cheap battery-powered one) on the ceiling. The mic was facing up, but not directly at the smoke alarm. This is the output on the OUT pin, as the alarm begins to sound. The vertical scale is 500 mV per division, so it's a minimum of 1 Vp-p as the sound is sustained, so plenty of output for the microcontroller's ADC!:

This is it zoomed-in; it is a 3 kHz tone.

2 of 2 people found this helpful
• ###### Re: Trying to understand how R & C affect an audio signal when used in a high pass filter

Wow excellent. Hope you had cotton wool in the ears

• ###### Re: Trying to understand how R & C affect an audio signal when used in a high pass filter

I've got a piece of test equipment that makes a loud screech at power-on, so I'm used to pushing one ear against shoulder and using that same arm to push other ear closed with hand, while using the other hand to power-on! : ) I did the same contortion with the smoke alarm : )

• ###### Re: Trying to understand how R & C affect an audio signal when used in a high pass filter

Figured I'd make a PCB layout while I was at it, since sometimes it could be handy to have a 3.3V mic amp. I might order a board next time I place any PCB order for something else.

The board files are here: Microphone Amplifier for Micro-controllers

2 of 2 people found this helpful
• ###### Re: Trying to understand how R & C affect an audio signal when used in a high pass filter

In your drawing,  Capacitance blocks the dc.(good thing) You also want to keep C impedance low at the cutoff frequency so you dont lose signal, like 1 ohm. Most audio from like a electret mike is 200mV .

• ###### Re: Trying to understand how R & C affect an audio signal when used in a high pass filter

Hi Gary,

I think these cheap electret elements are only a few mV output at (say) conversation speech level I think.. I've not measured at the element with the smoke alarm output level of loudness, but from the circuit output level to me it seems in the approx ballpark if the smoke alarms really do output 85 dB at 3 meters (I don't know this for sure though, it was just a brief google search) then it's low tens of mV.

I could be wrong, I've only experienced the cheap electret elements from old-school tape recorders etc. Maybe the ones in larger handheld electret mics are better (I've never looked at the output from them).

2 of 2 people found this helpful
• ###### Re: Trying to understand how R & C affect an audio signal when used in a high pass filter

shabaz - since you mentioned it, I hacked an expired smoke alarm for the buzzer. It is really cool that the driver chip has a little regulator to find the buzzer's resonant frequency where it is the loudest.

I reused the IC and buzzer to put on a robot as an alarm when it was backing up ( like trucks have ) .

The buzzer had to be removed from the robot because when the robot backed up, a few people thought there was a fire alarm, and freaked out.

The electret mikes are spec'd at a certain voltage and mA, so it may depend alot on the design exactly which mV range you end up with. The little ones are likely smaller in rating as well.

2 of 2 people found this helpful
• ###### Re: Trying to understand how R & C affect an audio signal when used in a high pass filter

Those buzzers are definitely loud!! : ) Hehe at just the right frequency to cause stress  : )