What's the resister for in a low pass filter?

I'm going to be driving an analog input from pwm. The analog input is designed to be driven by wiring a pot from a +5 reference line to the analog input.

I was thinking about throwing a cap on there to even out the PWM spikes because I don't know what that will do to the device I'm driving. I see everybody else talking about a "low pass filter", but they have a resister too.

What's the resister for?

By the way, I don't care about "responsiveness". If it takes the circuit a few seconds to rise to it's new level that's fine with me. I'm only concerned with a nice even flow of power. (Because I don't know what's in the black box I'm driving).

A lowpass filter with a capacitor and a resistor is just a normal voltage divider but "R2" is frequency dependent.

INPUT + + | | | | R | | + +------------ OUTPUT +

-------- C

+ + + GND

Vout = Vin * ( R2 / (R1+R2) )

Here R1 is just R1, R2 = 1/ (i*w*C) using complex numbers. Calculating Vout like this also gives you a phase shift. If you're just interested in amplitudes, calculate the absolute value of Vout. For complex numbers this is just: abs(Z) = Sqrt(Z*Z'), with Z' being the complex conjugate of Z. If you do all the math you'll end up with: |Vout| = Vin * 1 / Sqrt( (wRC)² +1)

If you google for passive RC filter and "transfer function" you'll find lots of info on that.

While all the above is correct, using a 1K resistor and a 10uF capacitor will do what you want.

While all the above is correct, a little more knowledge will make you feel more at home with it.

And in case you care about responsiveness one day, you might need it ;-)

a little more knowledge will make you feel more at home with it.

I agree. The purpose of the low pass filter is to eliminate the PWM modulating frequency while converting the PWM duty cycle to an smoothed average analog output voltage. A understanding of the filtering process and components would allow one to solve for different PWM switching frequencies.

Another related topic is the load impedance considerations of what you are controlling with the filtered analog output signal. If the impedance of the circuit you are driving is too low then it is often required to 'buffer' the analog filtered signal with a op amp or transistor stage.


I did google low pass filter and my limited understanding from that research was that if all I want is a steady signal I don't need the resister, and so I want to know if my understanding is right. In other words, doing the math with r1 at 0.

After all, if I use a resister I will never be able to drive the output at 100% right? The voltage drop over the resister will prevent that?

Another thing I'm trying to undersand:

Here's the spec sheet for what I'm trying to drive:


It says the control pin input impedance is 1k ohm.

Can I drive 9 of these off of one output pin? Or is it going to draw too much power?

Looking at figure 13 or 14 of the datasheet and reading a bit, I think you can just directly use a PWM pin to control the LED brightess. No need for a filter. If you wire it directly to an arduino it would need 5mA per driver at 1k input impedance. So an arduino could maybe drive 5 of these on a single pin. Using circuit 14 though you can use a lot more. The 2N4403 PNP transistor has a current amplification of about 100 and the demo circuit would allow 1mA max. base current - Vref = 5V, base resistor 5k - (which the arduino would have to absorb), so you could drive at least say 20 of these. That’s not the absolute maximum, but no need to over stress the little chip too much. I’d use demo circuit 14 for many drivers and demo circuit 13 for just a few.

Hi madworm,

a little more knowledge will make you feel more at home with it

I would disagree with you. A guy asking if a resistor is needed on a low pass filter is likely to be frightened off by talk of complex conjugates. It is like some one asking you if you vote by putting a cross on the ballot paper and you replying with a reading of the American constitution. (I'm English and we don't have a written one).

One of the tricks of education is not to overload, confuse or frighten a student but to lead, and encourage exploration.

Little girl says "Daddy where do I come from", embarrassed dad embarks on and explanation of the facts of life. When he has finished he asks "why did you want to know". Girl replies "well my friend Jane comes from New York so I wondered where I came from"

This is starting to get a debate on principles. I agree that giving back too much information can be confusing, but I didn’t say anything about differential equations or “worse” things. I thought c-numbers was basic math, but maybe that’s a thing of the past.

So let’s just say the filter needs the resistor to work into, burn some power at unwanted frequencies.

It's nice of you guys to debate the best way to help me out, but I still don't know what the resister is doing :)

That being said I'm probably in over my head. I'm a software programmer, by electrical capabilities are pretty weak. I need to drive 9 of these so I'm going to have to build a circuit that not only converts the pwm to an analog voltage but also can use a transistor to make the circuit source the power off the 5v pin.

I think I'm gong to need some more grounding in the basics. I wonder if there's a circuit simulator or something I can download and play with. I guess this circuit will give me the chance to learn to use the osciliscope in the basement.


You can use LTSpice to simulate electronic circuits. It's free and might give you a big headache at first.


This may also fall into the category "too much information" though.

That's definatly "Too much information", but I really want to learn and there's only one way to do it.

So I tried to model what we've been discussing, and below is what I have.

The first thing I need to figure out is how to steady the PWM signal, so this is a low pass filter as I understand it. R1 is 1k, cap is 10uf. The input impedance of the control pin is also 1k.

Before I added in the resister and ground to simulate the control pin everything was "fine". 100% duty cycle on the PWM generated almost 5V. But after I added the resister and ground to simulate the control pin the whole thing turned into a voltage divider and I only see 2.5V at the control pin.

So what is it that I don't understand about this?

Version 4
SHEET 1 880 680
WIRE 64 80 -16 80
WIRE 224 80 144 80
WIRE 336 80 224 80
WIRE 448 80 416 80
WIRE -16 112 -16 80
WIRE 448 112 448 80
WIRE 224 176 224 144
WIRE -16 224 -16 192
FLAG -16 224 0
FLAG 224 176 0
FLAG 448 112 0
SYMBOL voltage -16 96 R0
WINDOW 123 0 0 Left 0
WINDOW 39 0 0 Left 0
SYMATTR Value PULSE(0 5 0 0 0 2m 2m)
SYMBOL cap 208 80 R0
SYMATTR Value 10µf
SYMATTR SpiceLine V=50V
SYMBOL res 48 96 R270
WINDOW 0 32 56 VTop 0
WINDOW 3 0 56 VBottom 0
SYMATTR Value 1k
SYMBOL res 320 96 R270
WINDOW 0 32 56 VTop 0
WINDOW 3 0 56 VBottom 0
SYMATTR InstName Ctrl
SYMATTR Value 1k
TEXT -50 248 Left 0 !.tran 50m

Ok, I’ve spent a few hours reading and experimenting and I’ve almost got something working.

<This image was removed because it was replaced by a newer version and I don’t want to cause any confusion>

Here’s the link to the code if you want to lode it into LTSpice: http://frugalreef.com/wiki/Image:Buckpuck_driver.jpg

But there’s some things I don’t understand. Why is the voltage drop so high over the transistor? Why does the current flowing into the buckpucks from V2 appear negative? (BP1 - BP9).

I want to use some sort of filter on the PWM signal because I’m told these buckpucks look flickery when strobed at too low a duty cycle. I need to get up to 5v because it takes a full 5v of power on the control pin to shut them off.

Thankyou for all your help guys, I’ve learned a ton already.

the problem with using NPN transistors like that is:

they work by adjusting the base-emitter current, which is driven by the base-emitter voltage. if you add the 1k load resistors between emitter and GND, the base-emitter voltage is reduced as the emitter is not on GND anymore, but at a higher level (which is whatever voltage drops on the resistors). ultimately V(BE) would go to zero if the current and thus the voltage drop on the load resistor is too high (transistor off). I assume in this case it will only be barely on, so that the difference between base end emitter is about 0.7/0.8V (when the base-emitter diode starts to conduct). a nice example of a constant current source ;-)

note that this won't change much (or at all) if you crank up the supply voltage for the transistor! that way you will never get an output voltage any higher than the V(base)-0.7V or so. the transistor is choking itself.

maybe you'd have more luck using an PNP high side driver or an operational amplifier (voltage follower) to add some driving capability. or use an active low pass, but filter design is an art of its own (and the usual examples on the web give bad ripple sometimes).

This is the best I could get to work with a real PNP transistor. I was poking a bit in the dark with pre-biasing the base, as I don't have any graphical datasheet of it. It may not be linear in terms of output voltage vs. duty cycle.

Version 4
SHEET 1 1100 680
WIRE 288 -64 128 -64
WIRE 128 -32 128 -64
WIRE 288 32 288 -64
WIRE 288 32 224 32
WIRE 368 32 288 32
WIRE -256 80 -368 80
WIRE -96 80 -176 80
WIRE -48 80 -96 80
WIRE 128 80 128 48
WIRE 128 80 32 80
WIRE 160 80 128 80
WIRE 128 112 128 80
WIRE -96 128 -96 80
WIRE -368 160 -368 80
WIRE 224 176 224 128
WIRE 320 176 224 176
WIRE 416 176 320 176
WIRE 528 176 416 176
WIRE 640 176 528 176
WIRE 736 176 640 176
WIRE 832 176 736 176
WIRE 928 176 832 176
WIRE 1024 176 928 176
WIRE -96 224 -96 192
WIRE 128 224 128 192
WIRE -368 272 -368 240
FLAG -368 272 0
FLAG -96 224 0
FLAG 368 112 0
FLAG 224 256 0
FLAG 320 256 0
FLAG 416 256 0
FLAG 528 256 0
FLAG 640 256 0
FLAG 736 256 0
FLAG 832 256 0
FLAG 928 256 0
FLAG 1024 256 0
FLAG 128 224 0
SYMBOL voltage -368 144 R0
WINDOW 123 0 0 Left 0
WINDOW 39 0 0 Left 0
SYMATTR InstName ArduinoPWM
SYMATTR Value PULSE(0 5 0 0 0 0.002 0.002 500)
SYMBOL res -160 64 R90
WINDOW 0 0 56 VBottom 0
WINDOW 3 32 56 VTop 0
SYMATTR Value 1k
SYMBOL cap -112 128 R0
SYMATTR Value 10µf
SYMBOL voltage 368 16 R0
WINDOW 123 0 0 Left 0
WINDOW 39 0 0 Left 0
SYMBOL res 208 160 R0
SYMATTR Value 1k
SYMBOL res 304 160 R0
SYMATTR Value 1k
SYMBOL res 400 160 R0
SYMATTR Value 1k
SYMBOL res 512 160 R0
SYMATTR Value 1k
SYMBOL res 624 160 R0
SYMATTR Value 1k
SYMBOL res 720 160 R0
SYMATTR Value 1k
SYMBOL res 816 160 R0
SYMATTR Value 1k
SYMBOL res 912 160 R0
SYMATTR Value 1k
SYMBOL res 1008 160 R0
SYMATTR Value 1k
SYMBOL pnp 160 128 M180
SYMATTR Value 2N2907
SYMBOL res 112 -48 R0
SYMATTR Value 2k
SYMBOL res 112 96 R0
SYMATTR Value 11k
SYMBOL res 48 64 R90
WINDOW 0 0 56 VBottom 0
WINDOW 3 32 56 VTop 0
SYMATTR Value 10k
TEXT -256 296 Left 0 !.tran 0.1

And now that we've definitely passed the threshold of "too much information", I'm waiting for the experts to kick in again.

another option that becomes more and more attractive is to use a digital potentiometer !

there are chips ( http://www.arduino.cc/en/Tutorial/SPIDigitalPot ) that act as digital potentiometers that can be talked to easily.
this would get you a clean DC voltage between 0 and 5V with 8bit resolution. to add the necessary juice for feeding you drivers, you’d have to add a simple opamp voltage follower (maybe LT1056, so you can simulate it too) or maybe a power-opamp for even more current. most opamps will need a symmetrical power supply. some (like TLV2774) are rail-to-rail will work a single supply voltage, but may not be cheap.

I never expected that the dimming would be the hard part of this project.

When I run the simulation on your circuit, the output voltage starts at about 4.8 but then it drops to about .4 after about 8 miliseconds. It does this even after I change ncycles to 0, so that the PWM wave is continuous. Am I doing something wrong?

I like the digital potentiometer, that will certainly solve my analog output problem. Because it has 6 channels, it even accommodates the fact that my final design will be driving 4 banks of these buckpucks.

Of course, as you said, it won't put out the power I need. I can only push 11ma through it, and I need to push about 45ma. I'll have to research opamps tomorrow and see what I can learn about them.

I also noticed something in the buckpuck datasheet tonight. It says "Control Pin, Shutoff Threshold: 4.2V". Maybe I don't need to get all the way up to 5V to shut off these buckpucks.

Thanks again for all your help.

I'm not sure if setting "ncycles" to 0 works as expected. I always changed the duty cycle with "Ton".

Good luck.

Here’s my DigitalPot and OpAmp based voltage follower circuit:

But according to the simulation it’s not working. Output from the opamp does not equal the input voltage to the op amp and I don’t understand why.

You can find the LTSpice code at: http://frugalreef.com/wiki/Image:Buckpuck_driver.jpg