RE: Low Pass Filter

Hi Guys

I appreciate the input but bear in mind my math/science is mid high school level (work in progress). I'm having great deal of trouble understanding how a signal that is 490Hz has a DC component and this occurs at 0Hz.

When is the signal 0Hz? Are we simply taking a snapshot of the PWM signal when it is high (5V)? If this is the case then the capacitive reactance will be infinite? I feel I'm missing some key concept. :frowning:

@septillion

I don't understand what a pure sine wave is?

I don't understand what the pros/cons of adjusting the frequency?

@tinman13kup

I'm wanting to generate an analog voltage for an On Screen Display. I know that an RC circuit is commonly used to do this. I want to understand why.

@Southpark & Power_Broker

Fourier Series Concept? YIKES! There's no need to use that kind of language here. ;D This is way over my head.

Any help would be greatly appreciated.

Cheers

Jase :slight_smile:

ilovetoflyfpv:
I appreciate the input but bear in mind my math/science is mid high school level (work in progress). I'm having great deal of trouble understanding how a signal that is 490Hz has a DC component and this occurs at 0Hz.

When is the signal 0Hz? Are we simply taking a snapshot of the PWM signal when it is high (5V)? If this is the case then the capacitive reactance will be infinite? I feel I'm missing some key concept. :frowning:

@septillion

I don't understand what a pure sine wave is?

I can understand the confusion. At high school, I only knew what a sinewave was. But probably didn't know what frequency was... I think haha.

Anyway..... you know what a sinusoidal signal is, right? In maths....
y(t) = sin(t) defines ONE particular sinusoidal signal from a family of sinusoidal signals. This one happens to be a 'sine' wave. The wavey pattern of y(t) plotted versus time will repeat itself every (2.pi) seconds. This is known, because....in maths.... the sinusoidal expression is generally written with 1 more parameter... ie y(t) = sin(w.t) where w = 2.pi.f

'w' is called 'angular frequency', units of radians per second. I can't type greek symbols...but 'w' is actually supposed to be like a running-writing 'w'.

Yep.... pi is 3.14159 etc. And 'f' is the 'cyclic frequency'.

So, for y(t) = sin(t)...which is sin( 1.t ), you can see that the angular frequency 'w' is equal to 1 for this particular case. So w = 1. But, w is defined as 2.pi.f.
So w = 2.pi.f = 1

Rearranging the above gives cyclic frequency, f = 1/(2.pi), in units of Hertz, or 'cycles per second'. It means a cyclic frequency of 1 radian per second corresponds to a cyclic frequency of 1/(2.pi) Hertz. A 'cycle' means one single repetition of a portion of the waveform. If measured in units of 'seconds', 1 cycle will take a certain amount of time. And that certain amount of time (labelled capital "T") is called a 'period', or 'the period'.

The relation between the period T and the cyclic frequency f is simple..... it is: f = 1/T, or T = 1/f.
So, when angular frequency w (for this particular case) is equal to 1 radian per second, then we can easily figure out that the corresponding cyclic frequency f is equal to 1/(2.pi) Hertz. And the period T is 1/f, which is 2.pi seconds.

So, if you have a 50 Hertz sinusoidal signal that happens to be a 'sine' wave, then you could mathetically write it as y(t) = sin(2.pi.50.t)
And if you want to make this sine wave larger....just put a multiplying factor on the front of it... like...
y(t) = 3sin(2.pi.50.t), or 3sin(100.pi.t) .... or 3sin(314.159t)

One more thing. The 'sine' wave has a value of zero at time t = 0. And, as time increases, the 'sine' wave value gets larger and larger and will eventually reach a value of '1', before dropping back to zero again.... just google 'sine' wave, and you'll see. If you don't want a 'sine' wave, then you can always modify it.... by adding an offset to it.... like

y(t) = sin(w.t - 2.pi.b) ....'b' is a fractional number....and you could limit 'b' to a value between -1 and +1. For example... if 'b' is one-quarter, ie. b = 0.25, then

y(t) = sin( w.t - pi/2 )

The above is just some starting details for you about sinusoidal signals. Work towards understanding that first.

Hi Southpark

I appreciate you getting back to me. At this stage I can manage basic algebra, trig and I'm familiar with what a sine wave looks like. Unfortunately the rest of your response is pitched well and truly above my head possibly even tertiary level.

y(t) = sin(t)

I'm glad the guy in the above video isn't my teacher I'd be worried if I didn't understand what he was saying he'd hit me with that steel bar.

Cheers

Jase :frowning:

ilovetoflyfpv:
y(t) = sin(t)

hahaha! Let me check out that video. I'll take a look at that one tonight. Looking forward to seeing it. Thanks Jase.


[UPDATE] : Wow! It will be important to pay attention to him in class. Life may depend on it!

ilovetoflyfpv:
I don't understand what a pure sine wave is?

ilovetoflyfpv:
I don't understand what the pros/cons of adjusting the frequency?

Simple explanation: higher frequency => need lower RC values (and thus smaller components) to have the same filter effect => faster response on duty cycle change => and/or (if you do take the values higher) better filtering out of the PWM frequency.

And the DC = 0Hz. DC = Direct Current = Not changing = changing with 0Hz :smiley: And the DC part comes from the fact the PWM signal from the Arduino does not cross 0V. It's either 0V or 5V where as each sine crosses the 0V symmetrical. So think of a 50% duty cycle PWM, if you want to make it symmetrical that would be 50% of the time at -2,5V and 50% of the time at 2,5V. This makes it symmetrical and the voltage difference is still 5V. Now shift that whole signal by 2,5V DC up and you get the PWM of an Arduino, 50% of the time at 0V (-2,5V + 2,5V = 0V) and 50% of the time at 5V (2,5V + 2,5V = 5V). So it has a DC component of 2,5V. And that is what you expect because when you filter the PWM of the Arduino you expect a voltage of 2,5V when the duty cycle is 50% :wink:

And although it is a big deal of math, it does work in practice although it damn hard to sum an infinite amount of sines :stuck_out_tongue:

ilovetoflyfpv:
I'm wanting to generate an analog voltage for an On Screen Display.

On Screen Display? I can only think of that with my TV or monitor but I can't think of a link with voltage.

Jiggy-Ninja:
So? Everything in every engineering discipline involves approximate mathematical models.

Your wording..... 'approximate mathematical models'. Maybe you just mean - a system model that models the behaviour of an actual system. Some system models can model a real system perfectly. It just depends on "what" is being modeled.

Also, the approximation (I was referring to) excludes noise, and 'imperfections'. I'm talking about approximating a square-wave by summing together a few sinusoids.

Hi Gang

So a pure sine wave is a graphed unit circle?

Increasing frequency has the following benefits. It allows us to decrease the the values of our RC circuit thus reducing size, improved responsiveness and less ripple?

The DC component is the average of the duty cycle? I'm still having trouble understanding why then we set our cut-off frequency to 0Hz? Don't we need the voltage to toggle between 0V and 5V in order to achieve PWM?

On Screen Display (OSD)

I'm beginning to wonder whether the article that I linked to in my first post is not appropriate for my application. It deals primarily with AC signal while what I'm really interested in is a pulsed DC signal? I found the following article...

Arduinoā€™s AnalogWrite ā€“ Converting PWM to a Voltage

The focus seems to be more RC Time Constant and Cut-off Frequency. There is a link to an online calculator but I'm unsure how to use it?

Really appreciate the help.

Cheers

Jase :slight_smile:

A sine wave is the projection of a regular helix perpendicular to its axis.

Southpark:
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).

It's not clear why one would make this distinction. The time and frequency domain representations of a physical signal are mathematically equivalent. If one is physical the other is by definition.

ilovetoflyfpv:
So a pure sine wave is a graphed unit circle?

That's how they are related, yeah.

ilovetoflyfpv:
Increasing frequency has the following benefits. It allows us to decrease the the values of our RC circuit thus reducing size, improved responsiveness and less ripple?

Kind of yeah. If we increase the frequency by a factor 10 we can have the same ripple (but that ripple will still have the frequency of the PWM) if we decrease R x C (so multiplication of R and C) with a factor 10 as well. But we can also let RC stay the same and increase the frequency by 10 and have a ripple that's 10 times less. And you can mix and match. Because lower RC is faster response and smaller but higher ripple etc.

ilovetoflyfpv:
The DC component is the average of the duty cycle? I'm still having trouble understanding why then we set our cut-off frequency to 0Hz?

Ideally you would want the cut off to be at 0Hz but because it's given by Fc = 1 / (2PiRC) that would mean we need RC to be infinite which does not fit on most PCB's :stuck_out_tongue: So, the amount of ripple you can tolerate defines where to put it. If a ripple of 1% is fine then the cut off freqency needs to be 1% of the PWM frequency. So for 490Hz that would be at 4,9Hz which gives a RC of 0,032 which is pretty big (100k and 325nF) and 1% ripple is still "a lot".

Say we have a PWM of 62,5Hz and we allow a 1% ripple so cut off at 625Hz. That just gives a RC of 2,55*10-4 or with the same 100k just a 2,55nF capacitor will work. Or you can increase it to 25nF and just have 0,1% ripple :wink:

ilovetoflyfpv:
Don't we need the voltage to toggle between 0V and 5V in order to achieve PWM?

We still do, don't we? That's on the input of the filter and you want just plain DC on the output aka NO switching.

ilovetoflyfpv:
On Screen Display (OSD)

Ahhh, Quad copter FPV OSD.

ilovetoflyfpv:
I'm beginning to wonder whether the article that I linked to in my first post is not appropriate for my application. It deals primarily with AC signal while what I'm really interested in is a pulsed DC signal? I found the following article...

Where is the "pulsed" coming from?! You wanted DC didn't you?

ilovetoflyfpv:
Arduinoā€™s AnalogWrite ā€“ Converting PWM to a Voltage

Same first order low pass RC-filter. Just another way of explaining it.

MrMark:
It's not clear why one would make this distinction. The time and frequency domain representations of a physical signal are mathematically equivalent. If one is physical the other is by definition.

It is clear. Read this following post linked below thanks.

click here

And, you just said it, correctly. One is physical..... the real thing, such as .... I present you with the number 3. And this is the number 3..... plain and clear. Sure, you can mathematically decompose it in various ways, like 2.9 + 0.1, or 1.5 * 2, etc. Let's just (by analogy and by example) assume that '3' is the real deal..... physical. The rest are mathematical manipulations. So, if I present to you the number 3, then it is '3'. You normally don't go around teaching people that it IS "physically" some kind of infinite series thing, unless you want to do some kind of analysis or mathematical exercise, or something.

So, mathematically equivalent... yes.... or 'can be hypothetically expressed as', or 'can be modeled as'..... all ok. No problem.

But ..... "IS physically the same as" (ie. occurring in the background IS a bunch of things going on like 0.1 + 2.8 + 0.1) .... no. Not ok.

ilovetoflyfpv:
So a pure sine wave is a graphed unit circle?

The answer to that is .... no.

However, if an object is moving around a circle repeatedly, then then a plot of the vertical distance (or even the horizontal distance) versus time will have a sine-wave pattern. Another way to convey that is ..... consider a circle. A plot of the y-axis value (of a point) versus the angle of that point will result in a sine wave pattern for the plot. So, it could be considered as a plot of a value versus angle in one case. Or, if we follow an object that travels around a circle, it could be considered as a plot of a value versus time.

For constant speed (constant angular velocity) motion around a circular path...... the angle and the time are related by this formula..... ANGLE (in radians) = w.t
'w' is 'omega'.... units of radians per second.

The above formula is under the assumption that the object's initial position on the circle (at time t = 0) is at zero degrees (or zero radians).

See this image obtained from the internet....

sinewave.gif

It means, you can model (mathematically) a sinewave by using some mathematical formulas that express the time-changing vertical (or even horizontal) distance as a function of time. The origins of such a model is circular motion. The cyclic nature of the circular movement links nicely with the cyclic nature of the sinewave. It does not necessarily mean that any real (measured) sinewave originates from circular motion. Sometimes....maybe - such as angular measurements for a motor shaft.... but not always.

Jase.... for this PWM generator, what kind of input are you putting into this PWM generator? For example, do you just set an input value every once in a while, so that the pulse width of the signal remains the same for a relatively long time?

Or, are you changing the pulse widths of the PWM waveform at some relatively fast rate?

In any case, it sounds like it will be much better for you to go for a much higher PWM frequency. With higher PWM frequency (relative to 490 Hz), it can be more convenient to design an RC filter that gives you desirable results that you (or we) want. Desirable results mean ..... output DC voltage is relatively clean.... relatively low ripple. And also means - the response time is relatively quick --- like doesn't take forever for the output to reach the new DC value after you change the input.

ilovetoflyfpv:
The DC component is the average of the duty cycle? I'm still having trouble understanding why then we set our cut-off frequency to 0Hz? Don't we need the voltage to toggle between 0V and 5V in order to achieve PWM?

You don't need to set any cutoff frequency to 0 Hz.

The DC component is sometimes called 'average DC value'). If the voltage is finite, and never changes.... eg. 2 Volt..... then the average of this value over time is 2 Volt.

For some kind of periodic signal (where you know its period), a maths formula can be applied .... a 'time average formula'. This formula 'averages' the signal over 1 full cycle of the waveform. The result will be a value. And that value will be the 'DC average'.

For a PWM signal, with 2 levels of voltage..... eg, 0 V and 2 V...... if you have 50 percent duty cycle, the DC average will be half-way between those two levels.... which is 1 Volt., or 0.5 times 2V.

If you have 20 percent duty cycle, then the DC average will be 0.2 times 2V, which is 0.4 Volt.

And, suppose that the PWM waveform has levels of 0 V and 1 V instead. No problem.... the same rule applies.... 50 percent duty cycle would translate to a DC average value of 0.5 times 1V, which is 0.5 Volt.

And..... for 100 percent duty cycle.... we'd get 1 times 1V, which gives 1 Volt. 100 percent duty cycle means that the PWM signal is just a horizontal line, with a value of 1 Volt.

Do we dare speak of Butterworth, Bessel, Chebychev, elliptic etc?

Allan

allanhurst:
Do we dare speak of Butterworth, Bessel, Chebychev, elliptic etc?

Allan

I can't believe you dared to speak of those Allan! But now that you did. I believe.

Sorry. Not appropriate here. Multipole filters are a whole new ballgame.....

Allan

Hi Gang

Well I printed out the thread today and read it thoroughly. I was hoping that it would clarify things however itā€™s raised more questions.

  1. If I want to calculate the impedance of the circuit shouldnā€™t I be using the PWM frequency (490Hz) in order to calculate the reactance of the capacitor?

  2. The topic of Sine waves is debated numerous times most of which is pitched well above my understanding? I did like the diagram that Power_Broker included in post #13 illustrating the DC component of PWM signal along with the fundamental frequency and harmonics. It actually clarified the concept of fundamental and harmonic frequencies.

  3. How do I know whether the device Iā€™m feeding my filtered signal to is drawing current?

  4. Iā€™m still unsure about component selection. In post #29 septillion touches on the subject but I donā€™t quite follow. Wouldnā€™t I be interested in the acceptable ripple voltage rather than the ripple frequency? Could you expand on this?

  5. The PWM signal constantly changes based on how strong the Received Signal Strength Indicator (RSSI). I imagine I need to balance responsiveness and ripple?

  6. If I increase the frequency and reduce the resistor/capacitor size I gather that means the capacitor can charge/discharge quicker hence the better response?

  7. If I was to use DAC what would be a good starting point?

As always I really appreciate the help.

Cheers

Jase :slight_smile:

ilovetoflyfpv:
Hi Gang

Well I printed out the thread today and read it thoroughly. I was hoping that it would clarify things however itā€™s raised more questions.

Most of it is not necessary and will be over your head, so try not to get too bogged down in the details. This firestorm of posts was only triggered by someone deciding to pointlessly argue over a distinction without a difference. If you understand the big picture concept illustrated by Power_Broker's diagram, that's more than good enough. Fourier Transforms are a part of calculus, you don't need to concern yourself with the exact details of what frequency components are in a waveform.

  1. If I want to calculate the impedance of the circuit shouldnā€™t I be using the PWM frequency (490Hz) in order to calculate the reactance of the capacitor?

Impedance is a frequency-dependent value. That's how filters (like a low-pass) work: the different frequency components of a waveform encounter different impedances in the filter, causing the output to be changed and distorted.

For the output of the DC component (the one you care about most), a simple RC low pass filter will have an output impedance equal to R. The capacitor is irrelevant.

  1. How do I know whether the device Iā€™m feeding my filtered signal to is drawing current?

If it's a chip, the datasheet will have large tables of electrical characteristics. One of those is likely to be input bias currents or input impedance for the various inputs. If it's a more complex circuit receiving the signal (like an op amp circuit with feedback networks) then it depends on the circuitry attached to the input.

  1. Iā€™m still unsure about component selection. In post #29 septillion touches on the subject but I donā€™t quite follow. Wouldnā€™t I be interested in the acceptable ripple voltage rather than the ripple frequency? Could you expand on this?

Correct, but the ripple frequency will be the same as the frequency of the PWM signal. You need to know that frequency in order to create an appropriate low pass filter.

  1. The PWM signal constantly changes based on how strong the Received Signal Strength Indicator (RSSI). I imagine I need to balance responsiveness and ripple?

Correct.

  1. If I increase the frequency and reduce the resistor/capacitor size I gather that means the capacitor can charge/discharge quicker hence the better response?

Exactly correct.

  1. If I was to use DAC what would be a good starting point?

Start with the characteristics of the RSSI signal.

  1. What is its source? Is it an analog output, or a digital value read from some chip's register?
    1a) If it is analog, what are the minimum and maximum voltages?

  2. How quickly does this value change? How quickly do you need to respond to changes?

  3. What transformations (if any) are you performing to the signal value? I'm not referring to the analog -> PWM conversion, but changes in the actual signal value itself like multiplying or dividing it, adding or subtracting something, or filtering it in some way (not counting the PWM filter you're intending to apply).

  4. What is the receiving device? Since you're trying to LPF the PWM signal, it's obviously an analog input, but to what? For what purpose?

It's entirely possible that some cheap and easy SPI DAC like an MCP4811 will be good enough for your needs. Or if you don't mind discrete components, an R-2R ladder.

Or, if the source and receiver are both analog, take the Arduino out of the signal path entirely and use an op amp circuit.

A nice tutorial when one wants to convert a PWM into a voltage:

http://henrysbench.capnfatz.com/henrys-bench/arduino-projects-tips-and-more/arduino-lm358-op-amp-pwm-to-voltage-converter/