DSPRelated.com
Forums

Sharp DSP notch filter

Started by Eeyore May 20, 2009
On a sunny day (Thu, 21 May 2009 20:29:55 +0100) it happened Eeyore
<rabbitsfriendsandrelations@hotmail.com> wrote in
<4A15ABB3.D3913DF7@hotmail.com>:

>> Dear Rabit: >> http://panteltje.com/panteltje/xpequ/humfilter-0.1.tgz > >tgz is one of those compressed file types isn't it ? Linux style ?
Yes.
>> Actually it is just an interface I wrote to the code of somebody else, >> the original was at http://www.abelian.demon.co.uk/humfilt/ >> but no longer seems to respond... >> >> It is pretty good rejection, but does affect the sound. >> C code, of coure. > >Aarghhh. No C compiler. Long story. I was offered a job programming in C >about 25 yrs ago even though I didn't know it. I hated the syntax so much I >didn't take it. I'd probably have made a fortune and be a 'C guru' if I had >done back then.
Yes the syntax can be a bit shocking if you are used to school math..... '==' stands for '=' and '!' for is not etc.. += -=, but it works. Make a fortune? LOL, there is a lot of competetion in programming.
First question that occurs to me is ? real time ? or not?

If you do NOT have to do this real-time, there are a lot more options
in terms of processing off-line on a PC, and you can implement non-causal
filters (or more accurately, filters that would require non-causality for
a real-time implementation) which give you much more control and options.

As one example of this, any filter kernel can be used for non-(phase muckup)
if you use it twice, filtering ONCE in FORWARD time direction and ONCE more
in BACKWARD time direction.  THat is easy in offline processing and impossible
in real time.

So, do you have to do this real-time? Or is off-line analysis acceptable?
Eeyore wrote:
> > Jerry Avins wrote: > >> Eeyore wrote: >>> Jerry Avins wrote: >> ... >> >>>> How does mains noise get into the equipment? >>> That's part of the project. To find out. I suspect many different possibilities >>> but we can't rebuild the equipment so we need to find out what it's suspectible >>> too. Plus we expect to be tackling this problem for many types of equipment. >>> >>> >>>> Power supplies are filtered >>>> and regulated, so any noise you experience must enter by another >>>> route. You might look into ferro-resonant transformers. These are >>>> primarily intended to regulate load voltage, but they also suppress >>>> voltage spikes. http://www.elect-spec.com/trnsreg.htm has examples. >>>> >>>> A capacitive shield between primary and secondary of the power >>>> transformer may be all you need. Isolation transformers are built that way. >>> Yup I know. An ultra-isolation transformer will be part of our 'toolkit' too. >>> I've used them before.But we need to know what interference is on the AC line. >> You're on the way, then. Have you analyzed the line's harmonic content? >> There's plenty of instrumentation that can do that. One problem is what >> I call "dilution". The troublesome signals are transient, and tend to be >> swamped by the rest. The spectrum of impulsive noise is rarely impressive. > > Well for example the equipment in this instance, an 'antique' EMI mixing desk > produces 'clicks' when certain other loads are swiched. Now that varied from an air > condition unit drawing some 120A at start-up ( that also dimmed the lighting > momentarily until we put that on another supply ) to common or garden area lighting > and an outdoor security light switching.
I dealt with a similar problem a long time back by switching troublesome loads with zero-crossing triacs. In fact, I still have a converted power strip with an electronic switch in it. It's hard to do that with the outdoor lighting, but a ferroresonant transformer should isolate direct attack from that quarter. Those things can even ride out a missing cycle or two, so glitches are well suppressed.
> The fact that it doesn't always click indicates to me that the phase angle of the > supply when swiched is part of the problem which is why I've designed a zero-voltage > switching 'add-on' for use with light switches. I also suspect magnetic field > interference from 'loopy' wiring.
> We can only tell by testing the various possibilities and to do that we're going to > need to make a certain amount of our own test instrumentation. > > At another studio we found interference from railway signalling currents. The track > ran right behind the plot. An EMC company had passed the site OK because they only > measure from 150kHz up and not in the audio band. I have a recording of the signal > made a simple pickup loop. That studio, along with some others required a total > Faraday cage.
I believe that it was the simplest -- and counting time, the most economical -- approach. There was probably another way. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
Eeyore wrote:
> > Jerry Avins wrote: > >> Martin Brown wrote: >> > Eeyore wrote: >> ... >> >>>> I'm not interested in the 'sound' of the mains other than to see >>>> disturbances on it in the audio band. >> :-) >> >>> Why not null out the 50 & 100 Hz components roughly with an analogue >>> filter and then look at the rest of them. Chances are at least some of >>> the clicks and pops are coming from zero crossing lamp controllers, CFL >>> and other switch mode loads. Fridges, oil boiler and aircon motors seem >>> to have the nastiest startup transients. >> Lamp controllers switch at least once per cycle, usually twice. I can >> understand buzzes from them, but not clicks and pops. > > I reckon it's the peak inrush current of a standard switch and bulb causing > most of the trouble. I just received today a couple of Surgegard samples which > I plan to use in combination with zero-voltage ( and hence current for a > resistive load ) switching. I'm sure this alone will make a difference.
Zero voltage switching is zero current also for an inductive load. Not in the steady state, of course, but at the instant of turn-on. Of course, SCR and triac switches always turn off at zero current.
>>>> Trust me, my colleague and I know all about ground loops, technical >>>> earths etc and have even completely Faraday caged several studios. >> Is it practical to move some equipment to other studios to see if the >> disturbance follows them? > > No. It's just the one studio and control room and you should see the sheer > size of this stuff. > > I'm going to test their technical earth next time we're there too. > > >>>> I do not believe it has anything to do with grounds on the basis of >>>> what I've seen. >>>> >>>> What I'd really like to know is just where I can find info on doing >>>> what I wanted to do, i.e. perform sharp notch filters with >>>> a narrowish bandwidth. I do know what I'm doing in terms of trying >>>> to analyse the problem, I just need some help with the DSP. >> And we've been trying to psych out the problem for you; sorry. Some links: > > All help is gratefully received. > > >> The "online courses" at http://www.bores.com/ Chris Bore is based in >> England and he consults. >> >> Find the appropriate chapters in http://www.dspguide.com/ >> >> There is a bibliography at http://www.dspguru.com/ >> >> You should be able to implement the filters on a general-use computer >> with a good sound card. > > Thanks for that idea. I'd missed that one.
At your frequencies, you can also implement -- better yet, download -- an oscilloscope and spectrum analyzer. Ask if you need links. Somebody here must know them. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
Jan Panteltje wrote:
> On a sunny day (Thu, 21 May 2009 20:29:55 +0100) it happened Eeyore > <rabbitsfriendsandrelations@hotmail.com> wrote in > <4A15ABB3.D3913DF7@hotmail.com>: > >>> Dear Rabit: >>> http://panteltje.com/panteltje/xpequ/humfilter-0.1.tgz >> tgz is one of those compressed file types isn't it ? Linux style ? > > Yes. > > >>> Actually it is just an interface I wrote to the code of somebody else, >>> the original was at http://www.abelian.demon.co.uk/humfilt/ >>> but no longer seems to respond... >>> >>> It is pretty good rejection, but does affect the sound. >>> C code, of coure. >> Aarghhh. No C compiler. Long story. I was offered a job programming in C >> about 25 yrs ago even though I didn't know it. I hated the syntax so much I >> didn't take it. I'd probably have made a fortune and be a 'C guru' if I had >> done back then. > > Yes the syntax can be a bit shocking if you are used to school math..... > > '==' stands for '=' and '!' for is not etc.. > += -=, but it works. > > Make a fortune? LOL, there is a lot of competetion in programming.
Personally, I like Forth for most things I do. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;

"Joe G (Home)" wrote:

> "Eeyore" <rabbitsfriendsandrelations@hotmail.com> wrote > > >I am proposing to engage on a project regarding mains voltage 'purity' > > (and absence of ) with regard to audible clicks and pops in high-end > > professional and hi-fi audio equipment. > > > > Typical EMC filters operate in the RF band and are threfore no use to > > filter audio 'in band' noise that can travel through transformer > > interwinding capacitance etc. > > > > I have found some of the TI INA series that will with suitable > > preconditioning, tolerate mains voltages and give excellent common-mode > > etc rejection. So assembling a 'preamp' front end should be no problem. > > > > What I will need to do however is to filter all the mains frequencies > > and harmonics to a very large degree. > > > > I imagine I would need for example to null 50 Hz +/- 2 Hz to ~ -100dB. I > > have done only a little DSP ( I can't see it happening with analogue > > filters ) and I don't even know where to begin with such a severe filter > > without affecting the pass-band. Same will go for harmonics up to some > > serious number. > > > > Can anyone offer some advice as to algorithms ( number of cycles for > > such a deep notch ) and even better, a readily available eval board upon > > which it could be set up ? Remember I only need to 'hear' audio band, so > > 44.1 or 48 kHz sampling should be OK esp given the oversampling ADCs > > today. > > > Wouldn't it be easer to get a Digital CRO that can record/digitize the AC > waveform --> Tranfer the data to a PC and post process Cro or FFT the > waveform
We're not that wealthy ( the job's not going to pay for it ) and besides I'd like to see it real-time. I'm not convinced the resolution of a scope ADC would be adequate either. Graham

christofire wrote:

> "Eeyore" <rabbitsfriendsandrelations@hotmail.com> wrote > > >I am proposing to engage on a project regarding mains voltage 'purity' > > (and absence of ) with regard to audible clicks and pops in high-end > > professional and hi-fi audio equipment. > > > > Typical EMC filters operate in the RF band and are threfore no use to > > filter audio 'in band' noise that can travel through transformer > > interwinding capacitance etc. > > > > I have found some of the TI INA series that will with suitable > > preconditioning, tolerate mains voltages and give excellent common-mode > > etc rejection. So assembling a 'preamp' front end should be no problem. > > > > What I will need to do however is to filter all the mains frequencies > > and harmonics to a very large degree. > > > > I imagine I would need for example to null 50 Hz +/- 2 Hz to ~ -100dB. I > > have done only a little DSP ( I can't see it happening with analogue > > filters ) and I don't even know where to begin with such a severe filter > > without affecting the pass-band. Same will go for harmonics up to some > > serious number. > > > > Can anyone offer some advice as to algorithms ( number of cycles for > > such a deep notch ) and even better, a readily available eval board upon > > which it could be set up ? Remember I only need to 'hear' audio band, so > > 44.1 or 48 kHz sampling should be OK esp given the oversampling ADCs > > today. > > > > Many thanks, Graham > > You might find Julius Smith's work of interest: > http://ccrma.stanford.edu/~jos/filters/ > > It seems the challenge is to create a comb filter with notches much sharper > than can be achieved with a simple delay and addition. Maybe the answer is > a number of separate single-notch filters that can be made to track the > supply frequency.
Tracking would be neat for sure but as a first option the +/- 4% on notch width would do, most likely less. I like the idea though, then you can calculate the coefficiencts from the tracked fundamental.
> As for development kits, some are available (e.g. Analog Devices SHARC, from > Farnell) but at a price greater than a PC nowadays so there may be some > merit in doing the whole thing in C/C++ or Synthmaker on a PC if an adequate > audio interface is to hand. Especially if there is no intention of > manufacturing later on.
Yes, good idea. No plan to manufacture, at least not now. All I want initially is something 'quick and dirty' but that does the job acceptable well. There are eval boards around for various DSPs. Implementing this on an inexpensive one would save a lot of time and effort. Graham

Vladimir Vassilevsky wrote:

> Eeyore wrote: > > > What I will need to do however is to filter all the mains frequencies > > and harmonics to a very large degree. > > > > I imagine I would need for example to null 50 Hz +/- 2 Hz to ~ -100dB. I > > have done only a little DSP ( I can't see it happening with analogue > > filters ) and I don't even know where to begin with such a severe filter > > without affecting the pass-band. Same will go for harmonics up to some > > serious number. > > The multiple notch filter is simple enough, however it will create the > audible artifacts, and it won't do much help against the power interference.
It's the interference I want to discriminate from the power line fundamental and harmonics and see in real time.
> > Can anyone offer some advice as to algorithms ( number of cycles for > > such a deep notch ) > > Short answer: that won't work.
Not sure what you mean there. I've only a small experience of DSP filtering you see, although I've done some moderately complex audio reverb processing.
> > and even better, a readily available eval board upon > > which it could be set up ? > > Use a PC with a sound card.
Could do, although I'd prefer a 'one box' solution.
> > Remember I only need to 'hear' audio band, so > > 44.1 or 48 kHz sampling should be OK esp given the oversampling ADCs > > today. > > In the broadcasting equipment, they used to inject the AC frequency and > its harmonics into the audio to cancel out the power interference.
That must have been ages ago or specific to broadcast. Besides anything that moves over about 200m gets digitised and goes up fibre optic these days. Not a technique ever used in recording studios I've ever seen and that goes back a bit.
> The phases and amplitudes were adjusted for maximum rejection. That helped > to some extent, however the power interference is rather nonlinear and > nonstationary, which makes the problem difficult and non-trivial.
Exactly.
> So you shouldn't expect the miraculous improvement anyway.
I think you may have misinterpreted what I'm seeking. Tim Wescott's second post hit the nail on the head. Graham

"miso@sushi.com" wrote:

> Eeyore <rabbitsfriendsandrelati...@hotmail.com> wrote: > > > I am proposing to engage on a project regarding mains voltage 'purity' > > (and absence of ) with regard to audible clicks and pops in high-end > > professional and hi-fi audio equipment. > > > > Typical EMC filters operate in the RF band and are threfore no use to > > filter audio 'in band' noise that can travel through transformer > > interwinding capacitance etc. > > > > I have found some of the TI INA series that will with suitable > > preconditioning, tolerate mains voltages and give excellent common-mode > > etc rejection. So assembling a 'preamp' front end should be no problem. > > > > What I will need to do however is to filter all the mains frequencies > > and harmonics to a very large degree. > > > > I imagine I would need for example to null 50 Hz +/- 2 Hz to ~ -100dB. I > > have done only a little DSP ( I can't see it happening with analogue > > filters ) and I don't even know where to begin with such a severe filter > > without affecting the pass-band. Same will go for harmonics up to some > > serious number. > > > > Can anyone offer some advice as to algorithms ( number of cycles for > > such a deep notch ) and even better, a readily available eval board upon > > which it could be set up ? Remember I only need to 'hear' audio band, so > > 44.1 or 48 kHz sampling should be OK esp given the oversampling ADCs > > today. > > I'd be more inclined to sample the AC by phase locking to it.
Yes, sampling the mains fundamental would be neat. I don't think you'd even need to be phase locked for simple notch filters.
> Then you could easily create a comb filter to kill the power line > fundamental > and harmonics. This implies that you should use a 48kHz sample rate.
Readily available.
> I'm not sure you need any filtering prior to sampling given the > dynamic range of ADCs these days.
Agreed. Just a simple first order at some high frequency for luck probably.
> If your spike is say 70dB down from the carrier (60/50 Hz mains), I can't > believe it be significant to the > power supply design.
I wouldn't make ANY assumptions of that nature with today's high SNR audio ! I've seen some astonishing things.
> Besides basic DSP filtering, you could use LMS to get rid of the > fundamental. I suppose you could then LMS for each harmonic.
Hadn't thought of LMS. Not looked at it in ages actually. You mean the off-the-shelf package ? A bit pricey IIRC. Graham

Nico Coesel wrote:

> Eeyore <rabbitsfriendsandrelations@hotmail.com> wrote: > > >At another studio we found interference from railway signalling currents. The track > >ran right behind the plot. An EMC company had passed the site OK because they only > >measure from 150kHz up and not in the audio band. I have a recording of the signal > >made a simple pickup loop.That studio, along with some others required a total > >Faraday cage. > > This just makes me wonder: Are there digital microphones? Nowadays its > easy to build a digital output on a microphone, guitar pick-up, etc.
I think there may be some that claim to be but it's far from mainstream so far.
> I'm also a bit surprised studio equipment turns out to be so > susceptible to electric interference.
LMAO ! Excuse my mirth ! I've seen kit built even in recent times that breaks every rule of good practice for EMC. You just wouldn't believe it. You get these 'one man bands' touting their 'golden ears' genius and I've looked inside some of their kit and seen the problem ( typically hum loops ) instantly. Basic fundamental stupid errors.
> Ever tried to connect the whole > lot to an on-line UPS (AC->DC DC->AC)? That should get you a very > clean mains.
I've had good results with an ultra-isolation transformer in the past which will kill any power line transient but I'm far from sure that's the whole problem. Graham