Low pass filter for PWM - Page 1
Forum section: electronics / beginners

author: mayor
author_rank: Regular Contributor
timestamp: May 30, 2014, 01:09:44 am
content: I built a second order passive filter to create a "DAC" with PWM. I've experimented with different frequencies, and R and C values. Right now, I have 10K/1u, 10K/1u. I intend to feed the resulting voltage into an opamp (essentially used as a difference amplifier with 10x gain), and wondered whether the spikes I observe would be an issue, and if so, if anyone had a suggestion to attenuate the spikes (see attached images).Corollary question: these are from a Rigol 1074Z, with "Normal" acquisition (displays larger spikes) and with "High Res" acquisition (smaller spikes). The manual doesn't clearly explain what either does, and the difference is significant. Note that I am not entirely sure the PWM signal itself has the overshoot displayed in the "normal" version, either.Thanks for any pointers!

author: han
author_rank: Frequent Contributor
timestamp: May 30, 2014, 02:19:46 am
content: The spike probably from the supply to the PWM circuit with out sufficient capacitor..Could you probe the VCC and GND from supply nearest to PWM?

author: han
author_rank: Frequent Contributor
timestamp: May 30, 2014, 02:22:08 am
content: High res, is can be simplify as getting more resolution from noisy 8 bit DAC with oversampling (averanging),so definitely sharp spike will be displayed attenuated

author: IanB
author_rank: Super Contributor
timestamp: May 30, 2014, 02:30:20 am
content: Quote from: mayor on May 30, 2014, 01:09:44 amThe way you have shown your traces you don't have enough horizontal resolution to see the details of what those spikes look like. Try expanding the horizontal time base to about 2 µs/div instead of 20 µs/div and see what you actually have there.

author: mayor
author_rank: Regular Contributor
timestamp: May 30, 2014, 03:06:13 am
content: Quote from: han on May 30, 2014, 02:22:08 amHmmm, really? Then it's a pretty bad feature! Note that there also IS an "average" acquisition mode, which I expected attenuation from. So, not too sure what the difference is, save that the number of samples might be less on "high res".

author: mayor
author_rank: Regular Contributor
timestamp: May 30, 2014, 03:08:04 am
content: Quote from: han on May 30, 2014, 02:19:46 amSupply isn't particularly clean (real noisy over about 20mV). This is from USB power on a MSP430 Launchpad. I imagine TI's design's not too bad with regards to filtering. I can investigate further.

author: mayor
author_rank: Regular Contributor
timestamp: May 30, 2014, 03:10:05 am
content: Quote from: IanB on May 30, 2014, 02:30:20 amDoes this help? That's at 22KHz. I think the breadboard wires might be picking up a lot of crap, but I saw the overshoot measured straight from the launchpad's pin.

author: IanB
author_rank: Super Contributor
timestamp: May 30, 2014, 03:19:42 am
content: Something there doesn't look right. If the blue trace is the input signal and the yellow trace is the output signal, how can the output go down when the input goes up?

author: mayor
author_rank: Regular Contributor
timestamp: May 30, 2014, 03:35:06 am
content: Quote from: IanB on May 30, 2014, 03:19:42 amI dunno! But it looks like the spikes on the output are directly tied to the PWM overshoot, doesn't it?

author: TerminalJack505
author_rank: Super Contributor
timestamp: May 30, 2014, 03:37:02 am
content: Be sure to use the low inductance ground attachment. What you are seeing might be caused by the long wire on the ground clip.

author: IanB
author_rank: Super Contributor
timestamp: May 30, 2014, 03:55:03 am
content: Here's a simulation, FYI: (25 kHz, 50% duty cycle)Going by the apparent time constants of the system, whatever spikes you are seeing on the output look like noise or measurement artifacts.

author: AlfBaz
author_rank: Super Contributor
timestamp: May 30, 2014, 04:09:56 am
content: If I'm reading his scope pics correctly the rise time looks about 10ns not 1us. Secondly your sim needs a transmission line. In spice the voltage appears everywhere simultaneously which isn't the case here.At 10ns it doesn't take a whole lot of inductance in your hook up wires to cause those spikes. I'd suggest minimising connection lengths and possibly using an imput buffer to your filter where you can adjust the input impedance in an attempt to match it with the driver

author: IanB
author_rank: Super Contributor
timestamp: May 30, 2014, 04:25:34 am
content: Quote from: AlfBaz on May 30, 2014, 04:09:56 amOK, I didn't pay too much attention to the actual rise time. So 10 ns, yes, that's what the scope trace looks like.But even if there is some ringing on the input side of the filter, it still looks like the filter would block such high frequency components and stop them getting through to the output?

author: AlfBaz
author_rank: Super Contributor
timestamp: May 30, 2014, 04:54:59 am
content: Quote from: IanB on May 30, 2014, 04:25:34 amGood question, perhaps the impedance of the return path (inductive) is higher than the second cap

author: AlfBaz
author_rank: Super Contributor
timestamp: May 30, 2014, 04:47:57 pm
content: I ran into this problem some time ago as well and never looked into it any further as this stuff is way above my head. In spite my short-comings I thought I'd dig a little deeper...I "invented" the transmission line model so it's probably incorrect. Most discrete tline models show the caps and load connected directly to ground. These models did not exhibit the behaviour posted above so I decided to see what happens if you introduce inductance in the return wire (ie the shield)I don't know what the inductance of the shield is compared to the core but assumed inductance figures thrown around on the net might include both. Because of this I used a param for the core and another for the shield inductors so I could play with different ratiosThe values for inductance and capacitance I plucked from the net for RG58C/U... 101pF/m, 252nH/m and apparently 198m/us wave velocity, which, if I worked it out right, is a delay of around 5ns for 1m of RG58. The simulation shows anywhere between 3 and 6ns depending where on the edge you measure.RTerm is a dodgy attempt at impedance matching and at 50ohms and above seems to null out the spikes at the end of the tline, curiously however, they re-appear massively on the LPF's output.ltspice cct attached, just change txt to ascHere's the circuitPWM voltage at the sourceWave form immediately exiting the transmission lineOutput of the Low Pass Filter

author: AlfBaz
author_rank: Super Contributor
timestamp: May 30, 2014, 05:20:09 pm
content: It appears that this type of cct with these sorts of rise/fall times would ideally be prototyped dead bug style on a blank copper clad board.According to some online calculators for wire self inductance even a 10mm long 1mm diameter wire of 6nH will cause glitches to appear on the LPF's output in the above sim

author: IanB
author_rank: Super Contributor
timestamp: May 30, 2014, 07:00:05 pm
content: Quote from: AlfBaz on May 30, 2014, 05:20:09 pmI think your example illustrates why people recommend so strongly to have a good solid ground plane and to tie components tightly to it. In your simulated example the filter is "floating" on the end of the transmission line and has no strong ground reference to anchor it. In reality I am sure one would construct the filter right next to the PWM signal with the shortest possible distance between them.When I have a bit of time I will experiment with your simulation and try a few variations around it.

author: mayor
author_rank: Regular Contributor
timestamp: May 31, 2014, 01:36:55 am
content: I was leaning towards blaming the breadboard and wires for stray inductances. I got a hint of that when I probed VCC and saw the PWM pattern there, too.I also double checked with an analog scope (I read in a thread here that there might have been overshoot issues on square waves on the Rigol), and I am getting the same readings, so it's not an instrument issue.Thanks for taking some time on this. I guess I'll have to slap together a pcb to confirm this assumption.

author: IanB
author_rank: Super Contributor
timestamp: May 31, 2014, 02:27:27 am
content: Quote from: AlfBaz on May 30, 2014, 05:20:09 pmOK, I looked closely at the simulation with the transmission line. I don't think the output glitches are actually there. The key thing is to remember that voltages are differences between two points, not absolute values. In this case, we need the output voltage from the filter, which appears across capacitor C6. When I plot that voltage, no glitches!

author: IanB
author_rank: Super Contributor
timestamp: May 31, 2014, 02:32:07 am
content: Quote from: mayor on May 31, 2014, 01:36:55 amPossibly, maybe, or possibly not. It might be a measurement issue, or an experimental technique issue.Even if using a lash up on a breadboard, I am not convinced that you ought to be seeing any spikes. Spikes are ringing caused by high frequency components in the signal interacting with circuit resonances. After a low pass filter, there ought not to be any high frequency components. It's a low pass filter--it should filter out the spikes!

author: AlfBaz
author_rank: Super Contributor
timestamp: May 31, 2014, 02:52:18 am
content: Quote from: IanB on May 31, 2014, 02:27:27 amAh yes of course! Well spottedSo it may depend on where and how you are attaching you ground lead.Shouldn't take long to set up the jig I had when trying this a few months back and run some real life tests but its Saturday morning and the missus has lots of jobs for me

author: mayor
author_rank: Regular Contributor
timestamp: May 31, 2014, 10:05:10 am
content: Quote from: IanB on May 31, 2014, 02:32:07 amThat may be so, but I think the artefacts are induced through the entire circuit bythe unfilteredpwm signal itself (ie, also after the filter). I can actually see them when I probe VCC. After a lot of googling, I think "ground bounce" can explain it, including why the pre and post filter voltages go in opposite directions in the first part of the spikes.

author: David Hess
author_rank: Super Contributor
timestamp: May 31, 2014, 12:36:51 pm
content: Quote from: mayor on May 30, 2014, 03:06:13 amAverage mode averages successive waveform acquisitions after decimation. High resolution mode averages adjacent samples during decimation to produce the waveform acquisition record which has the effect of poorly low pass filtering the input signal. I am used to periodically checking (or just using) peak detection mode to verify that that the currently preferred acquisition mode is not lying about the signal peaks.Oscilloscopes that support long record lengths have an additional complication in that they have to process the acquisition record for display effectively decimating a second time but you will have to ask Rigol or test it to find out if this is an issue.