# Creating a Filter Using LTSpice

#### arhzz1

Joined Oct 21, 2020
22
Hello!

Just want to say that this is my very first time using LTSpice (I installed it 20 minutes ago),and I know that my questions are most likely trivial to people like you,but I'd like to learn so any guidance or help will be much appriciated.Now to the task

A pulse-width modulated square-wave signal should be filtered so that at output of the
Filter the mean value of the signal is present. The fundamental frequency is fPWM = 10 kHz.
This corresponds to a period of TPWM = 1 / fPWM = 100 µs.

1.Change the resistance and capacitance value so that the capacitor voltage
the maximum and minimum voltage value should be distinguished at the capacitance by a maximum of 100 mV
To do this, also adjust the simulation time. Which component do we need to use?

2.What happens if you change the tone in the voltage source and thus the duty cycle
(Duty cycle) of the PWM changes. Describe your observation.

3.Increase the filter effect by connecting another RC element between the voltage source and the resistor. Plot the voltage curve over both
Capacitors. What are you observing

Now for part 1. I tried simply finding how to build a generic filter in LTspice. I have done that like this (see attachment) but now I am not sure how to check if the capacitor voltage can no longer follow the input voltage.If I go to run and click on the capacitor I am getting the current (I) flowing through the capacitor.And to get get the value of the input voltage I have no Idea how to do.

Any help is appreciated! Thank you

#### Attachments

• 31.4 KB Views: 10

#### ericgibbs

Joined Jan 29, 2010
13,613
hi arhzz1,
E

#### arhzz1

Joined Oct 21, 2020
22
Sure thing;

#### Attachments

• 740 bytes Views: 5

#### crutschow

Joined Mar 14, 2008
27,709
You filter time-constant is way too low to filter that signal.
Do you understand how an RC filter works and what its corner frequency is?

Last edited:

#### arhzz1

Joined Oct 21, 2020
22
Uh no not really.If you have some good literature I would look into it

#### ericgibbs

Joined Jan 29, 2010
13,613
hi a,
This is an AC analysis.
Check the corner frequency.
E

#### Attachments

• 747 bytes Views: 3

#### crutschow

Joined Mar 14, 2008
27,709
Uh no not really.If you have some good literature I would look into it

#### Papabravo

Joined Feb 24, 2006
16,775
Uh no not really.If you have some good literature I would look into it
The voltage on the capacitor is an exponential function. Exponential functions can be characterized in terms of a time constant for the circuit. In this case the time constant is the product of R and C. This product will have units of time and can be use to represent how long it will take a voltage to rise or decay. It also represents where the corner frequency will be in the AC analysis. At frequencies less than the corner frequency signals will pass through the filter with no attenuation. At frequencies above the corner they will be attenuated at 20 dB per decade. In your case:
$50\; \Omega \times 100\;nF\;=\;5\;\mu sec$
$\frac{1}{5\;\mu sec}\;=\;200\;kHz$
Which you can see from the AC analysis plot where the attenuation is -1 dB and where it stars dropping off rapidly.

#### crutschow

Joined Mar 14, 2008
27,709
At frequencies less than the corner frequency signals will pass through the filter with no attenuation. At frequencies above the corner they will be attenuated at 20 dB per decade. In your case:

Normally the filter corner frequency is defined as the -3dB point, which is 1 / (2pi*R*C) or 31.8KHz in this case.
Which you can see from the AC analysis plot where the attenuation is -1 dB and where it stars dropping off rapidly.
You slipped a digit.
That's closer to 20kHz than 200KHz.

#### arhzz1

Joined Oct 21, 2020
22
Okay so my corner frequncy is 20kHz. Now what does that exactly mean? I'd assume I need this to determine the values of R and C to do part 1 of the task,but how exactly?

#### ericgibbs

Joined Jan 29, 2010
13,613
hi arh,
Post #9, check the equation
Normally the filter corner frequency is defined as the -3dB point, which is 1 / (2pi*R*C) or 31.8KHz in this case.

Transpose and solve for 31.8kHz, re-adjust the R C values to give the mean value for the PWM frequency

E

#### arhzz1

Joined Oct 21, 2020
22
Ohh I think I get it now,out of that we can get what the values of R and C need to be,after we solve for 31,8kHz.Okay it makes perfect sense,now I just need to figure out how to solve it,I'll give it my best shot.

#### ericgibbs

Joined Jan 29, 2010
13,613
hi,
Use LTS in AC analysis to check your calculations, '' Filter the mean value of the signal is present. ''

The

#### crutschow

Joined Mar 14, 2008
27,709
You need a corner frequency low enough to smooth the PMM pulse into a DC value with some small ripple voltage.
31.8kHz is too high for that purpose with the 10kHz PWM frequency you have.

#### ericgibbs

Joined Jan 29, 2010
13,613
hi Carl,
The original question is phrased as:
A pulse-width modulated square-wave signal should be filtered so that at output of the
Filter the mean value of the signal is present.

I read that in a different way to your idea, what you think.?

E

#### crutschow

Joined Mar 14, 2008
27,709
hi Carl,
The original question is phrased as:
A pulse-width modulated square-wave signal should be filtered so that at output of the
Filter the mean value of the signal is present.

I read that in a different way to your idea, what you think.?
I read it to mean you filter the PWM signal to get the mean DC value.
How did you interpret it?

#### ericgibbs

Joined Jan 29, 2010
13,613
Last edited:

#### crutschow

Joined Mar 14, 2008
27,709
I read it as Mean value, ie: 1.65V , [ 3.3V PWM] as would appear across a motor or LED load, at a 50% nominal drive.?
Is that different from what I said: filter to get the mean (average) value of the PWM signal?

#### arhzz1

Joined Oct 21, 2020
22
Okay but does the method of comming to the values of R and C change? Or do I still have to the calculations the way I would do them with the interpretation that Eric had?

#### Papabravo

Joined Feb 24, 2006
16,775
Normally the filter corner frequency is defined as the -3dB point, which is 1 / (2pi*R*C) or 31.8KHz in this case.
You slipped a digit.
That's closer to 20kHz than 200KHz.
Right. I had the frequency in radians which is where I mostly work. The radian frequency is correct and equivalent to the frequency in Hz. Sorry for the mixup. I should be more careful.