Go Down

### Topic: RE: Low Pass Filter (Read 7329 times)previous topic - next topic

#### ilovetoflyfpv

##### Jun 14, 2017, 02:56 pmLast Edit: Jun 14, 2017, 02:59 pm by ilovetoflyfpv
Hi Gang

I wish to convert a PWM signal into voltage. I understand that the most straight forward approach is to create a low pass filter resistor capacitor circuit (RC). Probably the most helpful article I've found is Passive Low Pass Filter by Electronics Tutorials.

I'm confused however after crunching the numbers (see attached). The typical frequency of a Arduino PWM pin is 490Hz. If a create a RC circuit using a suggested 10µF capacitor and a 10kΩ resistor then according to my spreadsheet my Vout will be 0.16V which is obviously undesirable.

Could someone please tell me where I'm going wrong?

Cheers

Jase

#### septillion

#1
##### Jun 14, 2017, 03:10 pm
You calculate the passing of the 490Hz signal, not the DC you want to calculate So that's approximately the ripple. For the DC part, use 0Hz for the reactance

But normally we look at the cut off frequency of the filter and the attenuation at the input frequency.

And you can increase the PWM frequency very easily and get away with a smaller RC filter.

Also, you do know this will give you a voltage but you may not pull current?
Use fricking code tags!!!!
I want x => I would like x, I need help => I would like help, Need fast => Go and pay someone to do the job...

NEW Library to make fading leds a piece of cake

#### ilovetoflyfpv

#2
##### Jun 14, 2017, 04:27 pm
Hi septillion

Thanks for getting back to me so promptly. I don't quite follow; could you rephrase your first paragraph?

Are you saying a PWM signal comprises of all frequencies up to 490Hz (see attached) and the filter 'highlights' the frequency we're interested in?

Cheers

Jase

#### aarg

#3
##### Jun 14, 2017, 04:36 pmLast Edit: Jun 14, 2017, 04:37 pm by aarg
Your rephrasing is a gross oversimplification, but basically true.
... with a transistor and a large sum of money to spend ...
Please don't PM me with technical questions. Post them in the forum.

#### runaway_pancake

#4
##### Jun 14, 2017, 05:21 pm
The typical frequency of a Arduino PWM pin is 490Hz.
490 Hz on 3, 9, 10, 11.
980 Hz on 5, 6.

https://www.arduino.cc/en/Reference/AnalogWrite
"Who is like unto the beast? who is able to make war with him?"
When all else fails, check your wiring!

#### Jiggy-Ninja

#5
##### Jun 14, 2017, 06:39 pmLast Edit: Jun 14, 2017, 06:39 pm by Jiggy-Ninja
Are you saying a PWM signal comprises of all frequencies up to 490Hz (see attached)
Right idea, wrong on the details.

One of the central mathematical principles behind circuit analysis is that any periodic function (read: waveform) can be represented by a sum of sine waves of various frequencies, amplitudes, and phases. If you are able to decompose a complex waveform into its individual frequency components, it's easy to calculate the effect a filter will have on the waveform since you apply the filter to each frequency component individually, then add them back up to get the result waveform.

So it's not "all frequencies up to 490 Hz". Most of the frequencies will actually be harmonics well above 490 Hz. You have the right idea though.

Quote
and the filter 'highlights' the frequency we're interested in?

Cheers

Jase
Not in the way you're expecting. The point of the low pass filter is to remove all off the frequency components as much as possible, leaving only the DC component behind.

But there's a tradeoff to this. Lowering the filter's critical frequency will reduce (but never eliminate) the effect of the higher frequency components, but it also means that the DC value will take longer to reach the intended level after it changes.

Depending on what you want to do with this signal, it might be better to get a DAC chip.

#### ilovetoflyfpv

#6
##### Jun 15, 2017, 12:40 am
Hi Gang

Wow! Thanks so much for the replies. So a wave is comprised of frequencies (harmonics) both above and below the fundamental frequency. A low pass filter attenuates frequencies above the cutoff frequency (in my case I want an analog voltage so I'm therefore interested in frequencies below 1Hz). Am I on the right track?

So aside from the cutoff frequency are there any other things to consider when making a RC circuit? I was thinking I need to be mindful of the overall impedance of the circuit so as not to overdrive the PWM pin. Is there a method to selecting the capacitor resistor combination?

Really appreciate the help.

Cheers

Jase

#### MarkT

#7
##### Jun 15, 2017, 12:57 am
By definition there is nothing below the fundamental frequency (other than a DC value).  All harmonics
are integer multiples of the fundamental frequency.

Yes, you are on the right track, a LP filter with a corner frequency of a few Hz would be typical for this sort of thing.
Yes the overall impedance is the other variable, together with the corner frequency that defines the
value of both R and C.
[ I DO NOT respond to personal messages, I WILL delete them unread, use the forum please ]

#### septillion

#8
##### Jun 15, 2017, 01:10 am
You're indeed on the right track. And as Mark already stated, there is nothing under the fundamental besides DC. And if the wave is a pure sine there are even no fundamentals. A sine is the "most pure" form of a wave and every other wave can be composed out of multiple sines which is what gives you the harmonics.

And for now you're not interested in below 1Hz, you are interested at 0Hz exactly

And besides the corner frequency the PWM frequency is an important factor. As I said, it's easy to increase that if the timer is not used for other things. By default timer0 is used for millis() and other timing so better not to touch that. But timer1 and timer 2 (so pins 3, 9, 10 and 11) are free to increase up to 62500Hz.

And also don't forget this:
Also, you do know this will give you a voltage but you may not pull current?
Use fricking code tags!!!!
I want x => I would like x, I need help => I would like help, Need fast => Go and pay someone to do the job...

NEW Library to make fading leds a piece of cake

#### tinman13kup

#9
##### Jun 15, 2017, 01:18 am
What are you trying to accomplish with this? Perhaps there is a better way.
Tom
It's not a hobby if you're not having fun doing it. Step back and breathe

#### Southpark

#10
##### Jun 15, 2017, 01:35 amLast Edit: Jun 15, 2017, 01:39 am by Southpark
Wow! Thanks so much for the replies. So a wave is comprised of frequencies (harmonics) both above and below the fundamental frequency.
Not quite. A periodic waveform can 'hypothetically' (theoretically) be 'considered' as a SUM OF sinusoidal signals (comprising a fundamental sinusoidal signal and harmonics of it), plus maybe a constant value (if there is a DC offset). This is the Fourier Series concept. Note that it does NOT mean that the waveform IS physically a sum of these things. It's a hypothetical (mathematical model) equivalence...... that allows people to analyse a waveform in one way.

#### Power_Broker

#11
##### Jun 15, 2017, 02:18 am
This is the Fourier Series concept. Note that it does NOT mean that the waveform IS physically a sum of these things.
I don't see why it isn't (assuming, of course, that the waveform is truly periodic and exists from time t = -infinity to time t = infinity). Either way, there's no need to confuse OP. For all intents and purposes, a truly periodic signal IS physically a sum of the harmonics found by computing the Fourier Series.

One thing to note is that if the PWM signal changes duty-cycle, the overall signal is no longer periodic from t = -infinity to t = infinity. Therefore, it is better to analyze the signal using the Fourier Transform instead of the Fourier Series. Not like this changes the filter circuit much, but it is something to keep in mind.

"The desire that guides me in all I do is the desire to harness the forces of nature to the service of mankind."
- Nikola Tesla

#### Southpark

#12
##### Jun 15, 2017, 02:37 amLast Edit: Jun 15, 2017, 02:52 am by Southpark
I don't see why it isn't (assuming, of course, that the waveform is truly periodic and exists from time t = -infinity to time t = infinity). Either way, there's no need to confuse OP. For all intents and purposes, a truly periodic signal IS physically a sum of the harmonics found by computing the Fourier Series.
It isn't 'physically' a sum of those things. Because.... physically, the physical signal in the time domain is 'The time domain Signal'.... which ...in this case.... is a periodic 2-level waveform (when the input is held at a constant value that is). Not 'physically' a bunch of sinusoids (plus a DC shift, if there is one).

Although, 'hypothetically'...... if we had the time to do it.... you could physically generate a bunch of sinusoids at the suitable frequencies (together with suitable amplitudes) ...... and add them up..... to come up with an "approximation" for the time waveform.

In the lab, you're not going to be able to generate an infinite number of harmonics. It's like e^(-t)..... it never goes to 'zero' until time reaches infinity.....and infinity means you'll never get there....because it keeps going ....forever.

It wasn't a case of confusing the O.P. It's a case of avoiding confusion right from the start.

#### Power_Broker

#13
##### Jun 15, 2017, 02:52 am
Because.... physically, the physical signal in the time domain is 'The time domain Signal'.... which ...in this case.... is a periodic 2-level waveform (when the input is held at a constant value that is). Not a bunch of sinusoids (plus a DC shift, if there is one).
I'm not saying that the PWM signal is generated from the Arduino is an infinite number of sinusoidal voltage sources in series (quite absurd isn't it lol), but you can't deny that the physical signal can still be analyzed and broken down into an infinite sum of sinusoids. To say that a physical signal doesn't follow this property is to say that Fourier and his findings were wrong.

Also, if you look at a PWM signal specifically, even though it is a "2-level waveform", it still is comprised of sinusoids. Take a look at this.

And this, too:
"The desire that guides me in all I do is the desire to harness the forces of nature to the service of mankind."
- Nikola Tesla

#### Southpark

#14
##### Jun 15, 2017, 02:57 amLast Edit: Jun 15, 2017, 03:02 am by Southpark
Also, if you look at a PWM signal specifically, even though it is a "2-level waveform", it still is comprised of sinusoids.
NOPE.... it is NOT physically comprised of sinusoids. The waveform can mathematically be 'expressed' as a bunch of sinusoidal waveforms. It does NOT mean that the physical waveform itself (in this case, the PWM waveform coming out of an arduino) IS a bunch of physical sinusoidal signals (plus a DC value). The sinusoids you're talking about come from the realms of mathematical modelling.

Go Up