Forums

Sharp DSP notch filter

Started by Eeyore May 20, 2009

Jan Panteltje wrote:

> it happened Eeyore <rabbitsfriendsandrelations@hotmail.com> wrote > > >> 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.
I think I preferred even Fortran's GT. GE. etc !
> Make a fortune? LOL, there is a lot of competetion in programming.
Not in C 25 years ago. But that's another story. Graham

Jerry Avins wrote:

> 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.
Guess what design is on the desk right now ! ;~)
> 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.
Yes, but a big investment if it doesn't fix it. I've asked a UK manufacturer if they'll loan one for a week or two but it didn't sound promising.
> > 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.
Possibly, but the Faraday cage worked beautifully. We did a site follow-up and it wasn't actually all that expensive either. I think it came to &#2013266083; 30-40k. After all, it was just sheet upon sheet mostly of 2mm thick mild steel screwed to the interior shell of the building and welded together. They had some clever method for dealing with windows too. Graham

Jerry Avins wrote:

> 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.
Of course. Double benefit. Nearly forgot that. And 'loopy wiring' will have inductance.
> >>>> 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.
It's more the inverse of a spectrum analyser I need. Somthing that 'ignores' the mains and its harmonics and only registers disturbances. I'm glad I got into this EMC lark ( almost by accident along with product safety ) over 20 yrs ago. I can see how some people just don't 'get it'. I think too many people dismiss it as 'boring' but it's actually very clever if your mind is open to the ideas involved. Graham

Jerry Avins wrote:

> Jan Panteltje wrote: > > On a sunny day (Thu, 21 May 2009 20:29:55 +0100) it happened Eeyore > > <rabbitsfriendsandrelations@hotmail.com> wrote in > > > >>> 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.
It may be old but it's good. PL/M (51) is my Forte. There are so many diverse 8051 family derivatives there's rarely one that won't fit the job and I find writing it a total breeze. I even released a product for manufacture with 'beta' code, expecting *someone* would be able to break it. A year went by and it was still being shipped with the same beta code. Seemed a shame to change it, so that's how it stayed. I did once write an embedded application in Pascal ( MX Pascal ? ) to run on a Z80. Don't even ask why. Or mention the EMC problems. That machine ( designed by another firm of 'consultants' ) still makes me laugh to this day. Pascal's OK too. We fixed it and the client was overjoyed. Graham

"Kevin G. Rhoads" wrote:

> First question that occurs to me is ? real time ? or not?
I would like it in real-time, so we can initiatate an event and see the result simultaneously.
> 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.
That would be so much less helpful that I think I'd rule it out.
> 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.
What's the advantage ?
> So, do you have to do this real-time? Or is off-line analysis acceptable?
As you see above, real-time is very much preferred. Graham
On a sunny day (Thu, 21 May 2009 22:13:04 +0100) it happened Eeyore
<rabbitsfriendsandrelations@hotmail.com> wrote in
<4A15C3E0.298E7BC4@hotmail.com>:

>> >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.
> >> Make a fortune? LOL, there is a lot of competition in programming. > >Not in C 25 years ago. But that's another story.
I learned C, lemme see, in 1984-1987 or there about. So 25 years ago, had been in contact with Unix already in 79, but not C programming. At that time I was developing embedded on 8051 / 8047 IIRC, and looking at other micros too. I was the hardware developer, and the software department, those worked in those times a lot with x86 asm, all on real IBM PCs, were a bit eh lemme say: overloaded? by having to learn Yet An Other asm language. The big boss, who was asm freak himself, then decided that we all should learn C. So we had C classes. I clearly remember the first C class we had, and after that meeting was over, I went over to the instructor and asked him: "Where is the input and output in C?". He answered: "There is no such thing in C'." So I replied: "But then I cannot do anything with it, in embedded I need to do I/O". He then said: "But you can use in line asm to make your own out and in routines".... Now that was a relief :-) But competitive environment, we had Z80 too...
On May 21, 2:04&#2013266080;pm, Eeyore <rabbitsfriendsandrelati...@hotmail.com>
wrote:
> "m...@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 &#2013266080;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
I programmed the LMS fit. For the fundamental, you just phase unwrap the sampled signal (presumably a sine) with an arcsin. The phase versus time plot should be series of points that would ideally be a straight line. If you fit a line to these points using LMS, the slope will indicate the LMS best fit to frequency. At the time, that was all I needed to do. But later I hacked a bit by creating a perfect sine wave using this LMS derived slope. I don't recall how I did the amplitude fit, but I think I didn't do LMS, but just ran some optimizer to vary the amplitude to make the difference between samples and the fitted sine wave go to a minimum. This is not a rigorous solution to the problem, but probably valid. Note I did this a few decades ago, so none of this is perfectly fresh in my mind, but the technique as I recall it is sound. As a hardware person, I think the phase locked sampling and comb filter would be the way to go. You probably would have to come up with a VXCO for the phase locked source. I hate all this windowing stuff. Synchronous sampling is much cleaner.
"Jerry Avins":


> 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.
** However, a zero volt AC switch applied to a mains transformer invariably results in a maximum size inrush current surge. The surge current peak will arrive about half a cycle after switch on. In the case of toroidal transformers, current peaks can be over 100 amps. ..... Phil
Eeyore wrote:
> > Martin Brown wrote: > >> 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. > > I'd half though of that. Make sure you include 150 Hz btw, the worst on the line > and 250 tends to be pretty bad too from memory of previous spectral analyses. > However I'd rather go the whole hog because access to studios is relatively rare > and you don't want to go in half-assed.
If you capture the raw data as acquired you have an insurance policy.
> >>>> However I have to go along with Tim. Filtering 50Hz harmonics is not >>>> going to help. The plops and clicks you mention are not a multiples of >>>> 50Hz. >>> That's why I want to eliminate the 50 , 100 , 150 Hz etc so I can see what >>> they ARE. >> It might be easier to grab long chunks of the waveform with the 50 & 100 >> Hz components only crudely nulled out and then use an FFT mask IFT type >> post processing solution to remove your remaining unwanted fundamentals. > > Not really helpful since we want to see it happening in real time in response to > specific events.
You could process it on an ordinary PC fast enough to look like realtime to a human. All you want to ensure is that the signal spike you are looking for will be adequately digitised so removing all the major components to within a couple of volts ought to be good enough. FFTs are very resilient if you signal average the power spectrum.
>> You only need to save the buffer when a click is heard. Something that >> is sharp in the time domain will be extended and spread out in the >> frequency domain. Clicks and pops should still be visible in the FFT >> even with some uncancelled fundamental. > > Sort of used that method for something else but this really is different.
What are you hoping to learn from this experiment? Wouldn't a transient detector be much simpler to implement and almost as good?
>> I'd be more inclined to monitor the buildings 3 phase mains input power >> in realtime and look for contemporaneous sudden changes in the reported >> power usage just after a spike/pop/glitch is heard. > > It's dual single phase actually. They may even be on the same phase but go back to > the street separately.
But total power in is easy to monitor and the signature of the sorts of heavyweight aircon kit likely to cause trouble should be unmissable. Thinking about it I'd be inclined to take along a bunch of wireless webcams pointed at the most likely suspects and record them timestamped with the other stuff.
>>>> These are just random spikes on the mains. If these spikes end >>>> up in your audio circuitry, then you most likely have a ground loop or >>>> another ground related problem somewhere. It means that the current >>>> from the spike shares a return path with your audio signal.
>>> Trust me, my colleague and I know all about ground loops, technical earths >>> etc and have even completely Faraday caged several studios. >>> >>> 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.
>> I presume you have already tried copper/mu-metal/copper sheets above and >> below to prevent ingress of stray magnetic fields. > > Not possible. The studio is complete and not suited to modification. Sure, there's > lots of things you could do if you went back to the beginning. In another story I > could tell you how useless I found mu-metal in an ultra-critical mic amp but that's > a LONG story and I suspect relates to transformer winding methods.
Mu-metal on its own isn't all that good. It has high magnetic susceptibility but isn't that good a conductor. It needs a layer of very good conductor on top to generate field cancelling eddy currents. Bacofoil will do at a pinch. Regards, Martin Brown
After reading the discussion I wonder:

Couldn't you simply connect a transformer to the mains, add a resistor 
divider at the output to get the signal down and record the glitches?

That way we could take a look at the data and see what happends on the 
mains.

You're at a recording studio after all. Recording something shouldn't be 
much of a problem. :-)

Cheers,
   Nils