How do I calculate the values for an LC or PI filter?

Hey guys,

So a while back I posted this thread about an issue I was having with noise from my LED drivers:
http://forum.arduino.cc/index.php?topic=150336.0

DC42 said that the noise was likely to be 1khz, and suggested some component values for an LC filter. But he didn't explain how he arrived at those particular values.

Since inductors are often expensive, especially ones which can handle high current, and I need one which is small as well, I want to be able to calculate the capacitors I would need for different values of inductor, so I can choose the least expensive and smallest inductor I can.

I'd also like to know how to do the same for a PI filter, as from what I've read these seem like they'd be twice as effective at the cost of one additional capacitor, which isn't too bad if I could get away with small caps.

You want the inductive reactance to be the same as the capacitave reactancee. So suppose you want the cut off frequency, that is the frequency where the input value is cut by a half at the output, called F, you make
Two Pi F L equal to one over two Pi F C

For a Pi filter you make the values of the capacities the same.

So:
2Pi x F x L = 1 / (2Pi x F x C)

And:

2Pi x F x L x 2Pi x F x C = 1
2Pi^2 x F^2 x L x C = 1

So:

C = 1 / (2Pi^2 x F^2 x L)

And if F = 1000:
C = 1 / (6.283 x 1000000 x L)

And we assume L = 330uH (0.00033H)
C = 1 / (6.283 x 1000000 x 0.00033)

C = 1 / 2073
C = 0.000482 Farads
C = 482uF

Hm... The value seems sane, so I think I did the math right, but it doesn't match up with the 1000uF that DC42 said I should use with a 330uH inductor.

Oops, wait, I forget to square Pi:

C = 1 / (2Pi^2 x F^2 x L)

C = 1 / (39.478 x 1000000 x L)
C = 1 / (39.478 x 1000000 x 0.00033)
C = 1 / 13027.74
C = 0.00007676
C = 77uH?

Now it's even further off of the suggested 1000uF. :confused:

Oops, wait, I forget to square Pi:

No one said you should.

The values are not critical. If you want to cut down on 1KHz signals more you have the break frequency lower. There is no way DC42 actually calculated anything he is just using standard values. Do the maths and see what cut off frequency his values gave you.

You could try an online calculator for a sanity check, for example
http://www.siversima.com/rf-calculator/lowpass-filter-designer/

You want the inductive reactance to be the same as the capacitave reactance

Thats the resonant frequency, exciting an LC filter with its resonant frequency is normally what you design to avoid!

This is where the 1/(LC)^0.5 equation comes from

suppose you want the cut off frequency, that is the frequency where the input value is cut by a half at the output, called F, you make
Two Pi F L equal to one over two Pi F C

Sorry but this isnt right, you set them equal to each other, put in your W (desired resonant frequency) in order to work out the values for resonance!, this way you are designing a system to resonate

Plot the circuit, add in a parasitic R, then calculate the transfer function

H(s) = 1/(LCS^2 +RCS +1)

insert S=jw, square, equate real and imaginary then take the square root

|H(s)| = 1/( (1-LCW^2)^2 +(WRCJ)^2)^0.5

set to 0.707 and solve for W, This will give you the equation for the -3db point, I won't post the equation here, its not common to find it online, its much more complicated than you are giving it credit for, Its not as easy as working with first order filters, which as far as I can tell is all the OP needs anyway

Its surprising how many engineers don't know how to do stuff like this, how many engineers can solve the quartic equation the above yields?... not very many I am afraid, whoever posts the correct solution first wins a mars bar!, the work is done

The OP needs to decide what frequencies he needs to cut out, he also needs to know what frequencies are present in the system so he can keep the resonant frequency well away, a decade away is common with the cut off point a decade above this

But thats still not the full picture!, the equations assume no load which for DSP applications is just fine, however if this is a power filter, or an appreciable load is flowing then the plot thickens, if its complex terminated then the orders of the equations increase, hell I can think of many a time when the transfer functions need to go out the window and all the state space stuff comes in, its basically as complicated as you want it to be

For a Pi filter you make the values of the capacities the same.

LCL, Pi, and T filters are quite another step up from this, but they succumb to the same analysis

There is no way DC42 actually calculated anything he is just using standard values

I haven't seen the post you are talking about but going on dc42's posts then I would be surprised if he hadnt calculated something,

For me rules of thumb, standard values etc are nice to use when you know what you are doing, its such a richer experience to do things the hard way sometimes

Plus one, Resinator.

Grumpy_Mike:

Oops, wait, I forget to square Pi:

No one said you should.

You did! You gave me an equation with 2Pi on both sides. I solved for C. That required me to move everything else over to the other side of the equation which left me with a bunch of variables multiplied together, and 2Pi was featured twice, so that's equivalent to squaring it.

If my math is wrong, show me where.

Resinator:
I appreciate the help, but I don't understand a thing you just said. I don't know how to deal with imaginary numbers, and until today I'd never even heard of a quartic equation. (I had to check to make sure you didn't mean to write quadratic.)

Is a first order filter one with just a capacitor or just an inductor? Wikipedia wasn't clear on that. I have tried adding all sorts of capacitors to remove the noise, and had only moderate success by adding several caps of different values (up to 4700uF), and I've read using inductors alone is no more effective at reducing noise.

Someone above linked this calculator:
http://www.siversima.com/rf-calculator/lowpass-filter-designer/

That only calculates PI filters, not LC, and I find the fact that it accepts frequencies only in the MHz or GHz range suspicious, but it does seem to allow me to enter .001MHz.

I have no idea what I should set the impedance to, but setting it to 1466 ohms gives me 330mH for the inductor, and 153.5nF for the two capacitors. That's way off from what DC42 suggested here:
http://forum.arduino.cc/index.php?topic=150336.msg1131664#msg1131664

So, I'm still completely lost. I have no idea if the values I am getting are sane, and I don't know whose advice to trust. :frowning:

Oh, and yes, this is for filtering power. PWM noise from some LED drivers is getting into my audio system.

(You know, I'm still not clear on why this affects my amplifier when it is powered from the same battery, but not when the power source is separate.)

Is the noise coming in on the power supply lines?
Or are the audio input lines picking up emissions from the LED switching?
2 different solutions. One is to filter the power supply better where it feeds the audio amp.
The other is to filter the input to the amp, maybe with a notch filter (think equalizer) that takes out the LED switching frequency.

CrossRoads:
Is the noise coming in on the power supply lines?
Or are the audio input lines picking up emissions from the LED switching?
2 different solutions. One is to filter the power supply better where it feeds the audio amp.

I don't know, nor do I know how to determine this.

I assume the amplifier has sufficient filtering on its input. It happens with both the Lepai2020A+ and the DTA-2, both available on Parts Express. The issue does not seem to affect the 3W amplifier I have integrated into the board itself. Well, it may, but it's so quiet that it doesn't matter. The issue with the external amps is an extremely loud high pitched buzzing noise that increases in volume as more LEDs light up. It's louder than the audio itself.

If I connect a servo to the board, or dim an automotive LED driven by a 12V boost converter using PWM I also get varying amounts of static. If I recall correctly, this does affect the 3W amplifier on the board, but again, the effect is lessened. By which I mean, on the 3W amplifier, the noise is much quieter than the audio, while on the 20W amplifiers, the noise ends up being much louder than the audio... unless they are powered from a wall adapter instead of the same battery (D cells or LiPo - should be plenty of juice). Then they behave like the 3W amp where noise is minimal.

I found this interesting article just now:

It's talking about essentially the same issue I'm having with an audio circuit and LED driver running off the same supply, and shows the use of a Pi filter between the analog supply and the digital signals. I was going to put the filter on my LED drivers, but if I can just put a single filter before the audio circuity, that would be much less expensive and allow my boards to be as small as possible, which is important for my applications.

Is that a schottky, or a zener diode between the analog supply and the digital circuit? And is that necessary?

That article seems to cover exactly what I need. It's even calculated the values for the 1khz noise that DC42 said I likely had in my circuit, and the capacitors are fairly small. I also don't think that diode there is actually necessary for the filtering, it's probably just a reverse voltage protection diode.

I should probably still increase the capacitance on my LED modules and at the power input on my board because they are probably woefully inadequate. I assume that shouldn't affect the design of this filter.

That is a shottky diode (or regular silicon diode), and it is probably not needed.

Yes, filtering power to the audio circuit is likely easier.

And if you filter power to the audio amp, you can use a low value resistor to minimize voltage loss, and a very large capacitor to make a simple RC lowpass, and avoid any issue with resonance in an LC filter.

I appreciate the help, but I don't understand a thing you just said

I didn't fully explain, however I did post the transfer function, do you know how to derive the transfer function I posted?

You can throw all the deep theory at it if you like, at the end of the day its nothing more than the potential divider equation

I don't know how to deal with imaginary numbers, and until today I'd never even heard of a quartic equation.

Imaginary numbers is just trigonometry and quartic equations are raised to the power of 4

Is a first order filter one with just a capacitor or just an inductor

Yes, one energy storage component, an LC filter is a second order systems as it contains two energy storage devices

Its first order differential equations and second order differential equations, the number of energy storage devices determines what order differential equations you end up with

have no idea what I should set the impedance to,

But you design a filter to pass certain frequencies and block others, you are filtering square waves, square waves contain infinite harmonics so its not just one frequency you have present
Designing resonant filters to filter these waveforms is not trivial, you have to make sure the resonant frequency is not excited which means doing a FFT to see what frequencies are present and designing around that not easy to do

330mH for the inductor, and 153.5nF

a 330mH inductor is a very big inductor, a 153nF cap is very small

I used matlab to do a bode plot of the system you propose, then I changed the components to 3mH and 10uF

I can show you how I worked out the transfer function, how we solve the equations and just how complicated this can be the advice Mike gave was actually really bad advice and the filter would not last very long

I I were you I would use an RC filter, very easy to design, very easy to work with, no resonance but it will still filter good enough for you, we can even do the same thing to get the equations for that and its a nice learning curve

eeee.jpg

the advice Mike gave was actually really bad advice and the filter would not last very long

Have you actually read the question and what the OP was trying to do?

You are way way over thinking this one.

Resinator:
I didn't fully explain, however I did post the transfer function, do you know how to derive the transfer function I posted?

I'm afraid not. My math skills are extremely rusty.

I can show you how I worked out the transfer function, how we solve the equations and just how complicated this can be

If it's that complicated, I probably won't understand the math. That page on maxim however made it seem fairly easy to calculate the capacitor needed for a Pi filter though, so I'm curious why you're indicating the math is very complex.

I I were you I would use an RC filter, very easy to design, very easy to work with, no resonance but it will still filter good enough for you, we can even do the same thing to get the equations for that and its a nice learning curve

That sounds good, but if it's that simple why didn't Maxim do that? And why would anyone ever use an expensive inductor that would be prone to resonance?

I have used this calculator in the past for RC filters:
http://sim.okawa-denshi.jp/en/CRtool.php

For 1000hz and a 47uF capacitor, it says my resistor should be 3.3 ohms. That seems high. I don't know for certain, but given my speaker is 4 ohms, I think if I stuck a 3.3 ohm resistor in series with it not only would the resistor have to dissipate half the power which think would be something like 1.25W, but my volume would also be halved. Neither of those is desirable. I'd have to use a huge 4700uF cap to get the resistor value down to where it wouldn't affect my volume much and where it wouldn't dissipate too much power for a large surface mount resistor to handle.

Of course I could be way off here. But I think I've got the numbers right.

Have you actually read the question and what the OP was trying to do?

Yes, he is trying to filter out the noise from PWM switching, something I know a fair bit about

Have you read my response and understood it? do you have any counter argument as to why I am wrong?, can you solve the equation to work out the -3db point?

You are way way over thinking this one.

No Mike this is the bare minimum thinking required, its the easy version without the differential equations, you aren't thinking about it enough to say that

The advice you gave to the OP wasn't just an over sight or a schoolboy error it was absolute gibberish, that if followed would lead to a system that blew up (resonance is nasty and to be avoided, not designed for).

Not having a go or trying to embarrass you, the equation you posted is akin to sizing a power factor correction capacitor it bears no relation to the OP's problem, its really bad advice, theres no denying that, hence you having nothing to justify your comments its like you were making it up as you went along

I'm afraid not. My math skills are extremely rusty

I will post a proper reply later when I get home, its really interesting stuff