Go Down

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

Power_Broker

Thanks for sticking with me. I'm not the sharpest tool in the shed but I'm willing to work hard.
Whoa there, I wouldn't sell yourself short. This is pretty advanced stuff for mid-leveled high school and you seem to be doing a good job so far. I didn't know how electronics or basic signal processing worked myself until somewhere around sophomore year of college (electrical engineering major).


What is x(t)?
What is X(w)?
x(t) is the signal in the time domain. This is what you would see if you were looking at the signal on an oscilloscope. On the x(t) graph, the x-axis represents a change in time.

X(w) is the SAME signal, but in the frequency domain. This is what you would see if you were looking at an FFT of the signal. On the X(w) graph, the x-axis represents a change in frequency. This explicitly shows which frequency components are present in your signal.

Both graphs provide the same exact information about the signal, but in different ways. For instance, it would be like saying that the US President lives at 1600 Pennsylvania Ave and also saying that he lives at 38.8977° N, 77.0365° W (Lat - Long). Both pieces of information are correct, they just have a different form. Much like x(t) and X(w) both give the same information about the signal, just in different form.


What are the red arrows? Are they trying to keep up with the PWM signal?
The red arrows show the presence of harmonics in the signal. They are called Dirac Delta Impulses, but you don't need to worry about that. The important thing is that they show you which frequencies are most prevalent in your signal. At w=0, we can see there is a red arrow, showing that there is a DC component to the signal. Moving along the x-axis we run into the next red arrow. This occurs at the first positive harmonic (we'll pick w = 10rad/sec since no numbers are given on the graph). We can also see another red arrow at w = -10rad/sec. This pair of red arrows indicates a cosine with a magnitude of twice the height of one the arrows. You will find similar pairs of red arrows at the second (w=20rad/sec), third (w=30rad/sec), and fourth (w=40rad/sec) harmonics, up to infinity. The only difference between all of the pairs are their heights - which shows how prevalent the cosines are compared to others. More height means they play a larger role in shaping the signal.

Once you filter the signal, the x(t) graph will become a constant and the X(w) graph will have only one arrow at w=0rad/sec.


What are the name of these graphs?
You can find similar graphs by searching "Fourier Series".


Is the Fourier Series illustration highlighting the different frequencies that comprise a fundamental frequency at a specific period in time?
Yes and no. It does illustrate the different frequencies of the signal, but is NOT for a specific moment in time. It is for the entire periodic signal from t = -infinity to t = infinity. Also, be careful to note that the fundamental frequency isn't comprised of anything; it just is.


What is the process for selecting the resistor and capacitor? I'm thinking I start with a resistor that doesn't overdrive the PWM pin (at 490Hz the capacitor will have a very low capacitive reactance). I then start 'playing' with different capacitor values that give good responsiveness and nominal ripple?
That question is best answered by research and trial and error. I suggest looking here first. Good luck!

As for "playing" with different values, I'd suggest doing that with a circuit simulator first such as LTSpice IV.
"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

ilovetoflyfpv


septillion

Didn't go through it all but just to answer this:
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.
But let me start with, unless you want to learn some pretty advanced Electrical Engineering, don't bother to much with the why. Just take the formulas for granted.

1) Yes, but then you only calculate the impedance for a sine that frequency. And in case of making a voltage from PWM it's easier to not do it the impedance why but the "filtering" way. So for a low pass RC0 filter (first order) is simply the voltage will decrease by 10 fold every time the freqency increases a 10 fold of the cut of frequency.

2) I don't really understand why a sine (at least the basic form) is a hard thing...

3)Datasheets datasheets datasheet. Or if you don't have a spec for it do the second best thing, measure it :)

4) Ripple fundamental frequency is just the PWM you use. And more often then not the circuitry is more worried about less ripple then it is about the ripple frequency. Because the more you reduce the ripple amplitude the more it just looks like noise. So for here, just use a higher frequency then normal, 3kHz and up will already make filtering easier.

5) Yes, what is the fastest change you think you will see?

6) Yep, lower C is less charge to discharge (or charge) => quicker, and less resistance = higher currents => quicker (dis)charge.

Another way of looking at it, your changing of the PWM also is a frequency part (how quick/often you change it) and the bigger the RC, the lower the cut off frequency and the more you also start to dampen your actions.

7) I would say getting pain killers... That is just another can of worms. I expect a voltage measuring input of the FPV OSD to not load the signal much so a RC-filter is just fine and simple.

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
https://github.com/septillion-git/FadeLed

ilovetoflyfpv

Hi Gang

Well I took the plunge today and downloaded LTspice. I ran two simulations (see attached). It definitely illustrates responsiveness vs ripple. I tested the 10kΩ/10µF combination in my aircraft and it worked. I'm guessing the On Screen Display (OSD) can cope with a certain degree of ripple. I'm curious to see what this is to maximise the responsiveness. Should I be decreasing the resistor value or the capacitor value or both? Specifically what are the pros and cons?

Cheers

Jase :) 

septillion

10k is a reasonable resistor value (not extremely low or high) so I would go for the cap. You can then switch to small ceramic caps in the nF range.

And did you also increase the PWM frequency as suggested?
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
https://github.com/septillion-git/FadeLed

Power_Broker

#50
Jun 17, 2017, 07:34 pm Last Edit: Jun 17, 2017, 07:35 pm by Power_Broker
Test_1 looks like the better choice. The big problem with test_2 is that you're using a 2,200uF capacitor, which seems ridiculous.

My suggestion is to use a 10uF capacitor and change your resistor value to find the right response time you need.

You should also look into adding input and output buffers to your filter.
"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

Jiggy-Ninja

The frequency domain theories are fantastic for analysing waveforms, and for designing/building devices to produce waveforms or modify waveforms etc.
Which is exactly what's being done in this thread.
Quote
But the measured voltage waveform at the PWM pin of an arduino is not the result of a bunch of sinusoidal signals putting on a display for you.
The physical method used to generate the signal is irrelevant. This is about the abstract properties of the signal itself.
Quote
There is a distinction. There is a difference.
Even accepting that claim, it is completely irrelevant to the topic at hand.

ilovetoflyfpv, don't get too bogged down in the details. For a simple thing like this, picking a cutoff frequency 10-20 times less than the PWM frequency is good enough. The exact value isn't hugely important, just that it's low enough. Then you can use the formula 1/( 2 * PI * RC) to calculate the RC value you need. Then find a pair of reasonable values for the resistor and capacitor so that when you multiple the values together you get about the RC value you calculated.

If the filter you create responds too slowly to be useful, there are ways to increase the PWM frequency to let you use a lower RC value.

That's it.

ilovetoflyfpv

Hi Gang

Sorry for taking so long to respond. I'm planning on using an ATtiny25 for this project so I'm not exactly sure how to increase the PWM frequency?

I stumbled across another video in the interim that I found quite useful.

Electricity - Filters

Cheers

Jase :)

Jiggy-Ninja

Hi Gang

Sorry for taking so long to respond. I'm planning on using an ATtiny25 for this project so I'm not exactly sure how to increase the PWM frequency?

I stumbled across another video in the interim that I found quite useful.

Electricity - Filters

Cheers

Jase :)
Timer prescaler. Check the datasheet for the appropriate registers to change. It'll also help you learn why only certain pins can be used as PWM pins. (Hint: look for OC__ in the pin diagrams).

septillion

I don't now if there is an easy library for it but you can always open op the datasheet to see which registers to set. And just Google a bit about it, it's not that different then an Uno to do. Al least the principle is the same.
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
https://github.com/septillion-git/FadeLed

ilovetoflyfpv

Hi Gang

Thanks for the replies. Registers make me break out in a cold sweat. They remind me of crack codes for games. A combination of letters and numbers that make no sense whatsoever but when applied in the correct sequence do something magic.

Cheers

Jase :)

Jiggy-Ninja

Hi Gang

Thanks for the replies. Registers make me break out in a cold sweat. They remind me of crack codes for games. A combination of letters and numbers that make no sense whatsoever but when applied in the correct sequence do something magic.

Cheers

Jase :)
They shouldn't. Registers are just variables that affect the microcontrollers hardware. There is an extensive amount of documentation in the datasheet about the identities and effects of all of the peripheral registers.

septillion

Unlike with cracks the register values is exactly explained in the datasheet ;) Although it looks "random" you can track it back exactly to what it means.
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
https://github.com/septillion-git/FadeLed

aarg

They shouldn't. Registers are just variables that affect the microcontrollers hardware. There is an extensive amount of documentation in the datasheet about the identities and effects of all of the peripheral registers.
But... they interact. So you have to be familiar with all the possible interactions to avoid difficulties.
  ... with a transistor and a large sum of money to spend ...
Please don't PM me with technical questions. Post them in the forum.

Jiggy-Ninja

But... they interact. So you have to be familiar with all the possible interactions to avoid difficulties.
If you set them up to interact they will. If not, most of the modules are pretty independent of each other. Changing the ADMUX register isn't going to screw up any part of Timer2's operation, for example. It's nowhere near as bad as you're worried about.

And what are you afraid is going to happen if you mess up? If your sketch doesn't work properly, change something and load a new one. Registers are in RAM memory, any changes you make are cleared out after a reset so nothing you do will interfere with the bootloader. That level of worry is appropriate for fuses, not registers. Fuses are much harder to change (requiring a programming device) than registers precisely because they are more dangerous.

The bigger concern is if you have two bits of code trying to access the same resource, like if Tone and Servo both try to use Timer2. Then things get screwy. But that's a problem with libraries that hide away their access to the different peripheral resources. If you're setting them up yourself, you know exactly which bit of hardware is devoted to which task, so it won't be a problem.

Go Up