Bode Plot Question - phase response of passive LP filter seems odd... - Page 1
Forum section: electronics / beginners

author: puterboy
author_rank: Regular Contributor
timestamp: September 30, 2022, 08:05:13 pm
content: I was testing out the Bode Plot functionality on my Siglent 1104x-e scope using a passive RC LP and then a passive RC HP filter.The amplitude response seemed spot on (at least to the tolerances of the components).However, the phase response seemed odd.1. In the LP filter version (first attachment), the phase response hits -45deg about 3kHZ beyond the corner frequency of ~10kHz2. Most strangely, for the LP filter, the phase response hits a negative minimum of about -65deg at about 55kHz and then increases back to 0deg! (rather than decreasing to -90deg)3. The HP filter (second attachment) looks mostly right, although here it hits the -45deg mark about 3kHz before the corner frequency.#2 is the hardest for me to understand/explain.Any ideas???Thanks!

author: Benta
author_rank: Super Contributor
timestamp: September 30, 2022, 08:16:01 pm
content: I'd say your probes are the problem.

author: puterboy
author_rank: Regular Contributor
timestamp: September 30, 2022, 09:15:00 pm
content: I should also note that the corner frequency of the LP configuration is about 10.3K while the corner frequency for the HP configuration (with the same resistor and capacitor) is about 3KHz higher.Also, interestingly in both the HP and LP situations the 45deg phase point occurs at -4dB rather than the expected -3dB corner frequency.

author: puterboy
author_rank: Regular Contributor
timestamp: September 30, 2022, 09:17:12 pm
content: Quote from: Benta on September 30, 2022, 08:16:01 pmCan you explain how that would happen?Are you thinking stray resistances & capacitances would make this effectively into something more complex than a single stage passive RC filter?I wouldn't have expected that to happen at relatively low corner frequencies like 10kHz given that this a 100MHz scope with decent probes.I cold understand some slight phase shifting but the phase inversion in the LP filter case just doesn't make sense to me...

author: David Hess
author_rank: Super Contributor
timestamp: September 30, 2022, 09:52:38 pm
content: I would set the oscilloscope up to make the phase and amplitude measurements automatically and do a manual sweep to find the exact -3dB and 45 degree points. This will confirm if there is something off about the automatic bode plotting function.

author: Benta
author_rank: Super Contributor
timestamp: September 30, 2022, 09:55:08 pm
content: Until you show us WHAT your're measuring, all bets are off. Schematic? Values? Scope settings?

author: macboy
author_rank: Super Contributor
timestamp: October 01, 2022, 02:30:18 pm
content: At first glance, I'd say that the "strange" phase response of the low pass actually matches quite well with the magnitude response. Note that it does not continue to slope downward but tilts back up. I can't explain why the filter is leveling off, but the phase response is on par.

author: Benta
author_rank: Super Contributor
timestamp: October 01, 2022, 04:59:54 pm
content: Quote from: macboy on October 01, 2022, 02:30:18 pmNo it doesn't. an RC LP phase response should asymptotically approach 90 degrees lag. There's a leading element in there somewhere.

author: macboy
author_rank: Super Contributor
timestamp: October 01, 2022, 05:44:56 pm
content: Quote from: Benta on October 01, 2022, 04:59:54 pmI'm not arguing with that fact. It should do that. Clearly in that graph, that isn't what is happening. The unexpected magnitude response has an equally unexpected but matching phase response.

author: puterboy
author_rank: Regular Contributor
timestamp: October 02, 2022, 12:13:12 am
content: Quote from: Benta on September 30, 2022, 09:55:08 pmSimple RC circuit. R=~158 ohms, C=0.1uFSiglent Scope in Bode plot mode.

author: mawyatt
author_rank: Super Contributor
timestamp: October 02, 2022, 12:55:06 am
content: What type of cap? Have you measured it at various frequencies within the Bode range?Best,

author: puterboy
author_rank: Regular Contributor
timestamp: October 02, 2022, 12:57:57 pm
content: Quote from: mawyatt on October 02, 2022, 12:55:06 amcorElectrolytic cap.I got the same strange phase change when I increased R by factor of 10 moving the corner frequency to 1kHz.I am using a Siglent SDS1104-e scope with it's standard probes and a Fygen 6900 signal generator.At a 1kHz corner frequency, I would think that even the cheapest test equipment and probes would perform reasonably.

author: mag_therm
author_rank: Frequent Contributor
timestamp: October 02, 2022, 02:14:13 pm
content: Do a hand calculation of mag and phi at about 200 kHz. That will show the problem with DUT,Looks like you have about 9 Ohm ( Real,) in the numerator of the voltage divider's transfer function.That would be series R in capacitor leg under your probe.If using electro as you mention, it would need to be a good one, and polarized with DC, properly isolating DC from the probes.Better to use a polyester cap for this test.

author: Bud
author_rank: Super Contributor
timestamp: October 02, 2022, 05:18:25 pm
content: I've never seen a 0.1uF electrolytic capacitor in my life....

author: mag_therm
author_rank: Frequent Contributor
timestamp: October 02, 2022, 06:07:59 pm
content: Quote from: Bud on October 02, 2022, 05:18:25 pmHere are (5) from 3 sources.Tan delta fairly high too, but not enough to cause the problemhttps://www.newark.com/c/passive-components/capacitors/aluminium-electrolytic-capacitors/smd-aluminium-electrolytic-capacitors?capacitance=0.1uf

author: puterboy
author_rank: Regular Contributor
timestamp: October 02, 2022, 08:13:07 pm
content: Quote from: David Hess on September 30, 2022, 09:52:38 pmI did as suggested with values of R and C as measured by my DVM to give a PREDICTED corner frequency of 1kHz.The MEASURED corner frequency where the (average) amplitude was down by 3dB was 1.06kHz -- which is certainly within tolerance range of my DVM measurements of the component values.At the measured corner frequency the (average) phase difference was -40.18degThe measured phase difference hit -45deg at 1.28kHz at which point the amplitude was down by 3.8dBAnd as I sweep higher, the phase decreases to a minimum of about -80deg at around 15-20kHz and then starts increasing again (as per my original post).Attached is an updated bode plot of the same setup with the ~1kHz corner frequency -- which is very consistent with the measured values from my manual sweep.The only thing I can think of is that the filtered signal is a bit noisy as the frequency increases and the amplitude decreases and perhaps this leads to erroneous phase measurementsThe second attachment shows the two sin waves at 100kHz when the output signal amplitude is down 38dB (130mv vs. 10V input) and the phase is now increased to -62deg (whereas it should be close to -90).While there is noise in the output signal which could effect the phase calculation, the stdev of the phase difference is only 6.77deg so I wouldn't think that would account for the difference between -62deg and -90deg.And given that the corner frequency is just 1kHz (and my scope and probes have at least 100mHz BW), it's hard to believe that this is a limitation of the measuring hardware...So this still remains a mystery for me!

author: macboy
author_rank: Super Contributor
timestamp: October 02, 2022, 09:12:27 pm
content: Quote from: Bud on October 02, 2022, 05:18:25 pmHere...This one measures 5.76 ohm ESR at 100kHz, compared to 0.42 ohm for some random green film cap, also 0.1 uF.

author: jasonRF
author_rank: Regular Contributor
timestamp: October 03, 2022, 12:06:32 am
content: I recommend you plot the theoretical Bode plot, using a model of the capacitor that includes the series resistance. The measurements may be exactly what you should expect them to be. If you don't already know how to do that, then this could be a good learning opportunity. If you don't want to learn the math, you could at least plot these in a spice package such as LTSpice.Anyway, I just did a quick and dirty experiement with a low-pass filter from a 33-Ohm resistor and 4.7 uF capacitor. It also shows deviations from what you might expect for the Bode plot if the resistor and capacitor were ideal, but we will see that a model that includes the ESR of the capacitor will predict the measurements pretty well.Case 1: 4.7 uF electrolytic capacitor (Xicon, 35V, purchased at Radio Shack a decade ago I would guess) with measured (using a cheap transistor-checker) capacitance of 4.32 uF and ESR 2.6 Ohms. The first image is the measured Bode plot (from a Picoscope) where I am applying no DC bias across the capacitor.Applying a 1V DC bias (using 0.1V peak-to-peak AC) did change things a little, but not dramatically, as shown in the second image.Now, the theory (including the ESR) says I should measure the following phase shown in the third image.This is close enough to the measurement that I would say the measurement is expected.EDIT: if you want to understand qualitatively what is going on, consider what happens when the frequency is high enough that the ESR of the capacitor is much larger than its reactance. At these high frequencies, a resistor of value ESR is a reasonable model for the electrolytic capacitor. So the simple voltage divider equation should give you the gain at high frequencies (and is why the measurements look like they will asymptote to a fixed gain, instead of continuing to fall off at 20 dB / decade). Likewise, the phase should be close to zero. Of course, as the frequency gets higher, other effects (inductance of component leads, capacitance of the resistor, etc) may also play a role.Case 2: a 4.7 uF film capacitor (a Panasonic metalized polyester 100V job that is quite large!). The fourth image shows the measured Bode plotCloser to the ideal theory, since the ESR is apparently lower. The cheap tester says this film cap has an ESR of 0.3 Ohms (spec on the cap is < 0.34 Ohms at 1 kHz), but a theoretical plot with 0.05 Ohms is closer to the measurements. I think I believe the scope more than the tester, though. The last plot is the theoretical phase assuming 0.05 Ohm ESR.[ Specified attachment is not available ]JasonPS: sorry fo the mess with the images. I tried to make them inline (first with thumbnails) but am not the best user of this forum! Also, I didn't bother to show the theoretical amplitude Bode plots; they also are consistent with the measurements.

author: puterboy
author_rank: Regular Contributor
timestamp: October 03, 2022, 05:34:04 am
content: Quote from: jasonRF on October 03, 2022, 12:06:32 amThanks! And I think you nailed it!Your explanation and experimental confirmation are very helpful with your graphs almost perfectly duplicating what I was finding. I would imagine the ESR of my electrolytic cap is rather high as it came from a cheap no-name Chinese assortment.Just thinking off the top-of-my-head this would probably also explain why the distortion is so much more prominent in the LP rather than HP configuration since in the HP configuration the ESR would just show up as added output impedance from the signal generator.BTW, I am very familiar with the math of Bode plots in particular and frequency-domain transforms in particular (I have even edited books, given lectures and written papers on signal processing) -- but it's been decades and it's been a good almost 40 years since I played with Bode plots in the lab -- done the old fashioned way with analog scopes and WWII vintage signal generators...I will play around with LTSpice (it's been a while) as well as try the same experiment with a ceramic cap which should have much lower ESR.

author: puterboy
author_rank: Regular Contributor
timestamp: October 03, 2022, 05:38:20 am
content: And indeed using a ceramic 0.1uF capacitor gives a much cleaner and near ideal single-stage passive LP filter Bode plot.- At the -3dB frequency, the phase angle is -43.5deg (which is pretty close to -45)- The amplitude falloff is pretty close to linear (when plotted on a log frequency scale)- The phase decreases monotonically in a sigmoid like curve, asymptotically to -90degAttached is the revised Bode diagram.Again thanks to @JasonRF for providing the detailed explanation and experimental evidence!

author: puterboy
author_rank: Regular Contributor
timestamp: October 03, 2022, 01:24:34 pm
content: And here for completeness is the HP filter version with the ceramic 0.1uF cap.

author: jasonRF
author_rank: Regular Contributor
timestamp: October 03, 2022, 04:06:45 pm
content: Glad you sorted it out. By the way, mag_therm was indicating the same issue in their post above. I neglected to point that out in my post.I still recommend plotting the theoretical response, and playing with how the ESR effects the transfer function. You could also add small resistors in series with your ceramic cap to measure the effect.Cheers, jason

author: puterboy
author_rank: Regular Contributor
timestamp: October 03, 2022, 11:46:52 pm
content: Thanks to both you and mag_therm!!!

author: rstofer
author_rank: Super Contributor
timestamp: October 04, 2022, 12:04:00 am
content: For those following along at home, here is the MATALB code for the Bode' Plot of a simple low pass filter using a 10k resistor and 0.1 ufd capacitor. MATLAB is smart enough to center the -3dB point in the center of the graph.Code:close allclearvarss = tf('s')R = 1.0*10^4; % 10k resistorC = 0.1*10^-6; % 0.1 ufd capacitorH = 1/(1+s*(R*C));opts = bodeoptions('cstprefs');opts.PhaseVisible = 'on';bodeplot(H, opts );grid on; zoom on;Octave hasn't implemented the Bode' Plot functionality. Bummer! Octave is free and MATLAB is not.Octave uses different function names, see below.

author: jasonRF
author_rank: Regular Contributor
timestamp: October 04, 2022, 12:22:44 pm
content: Thanks for posting that code! I use Matlab every day at work and didn't realize it had built-in Bode plots - although I don't do electronics for a living so perhaps that is why.Anyway, I think posting a snippet of code is a great idea, so here is a little code to generate the Bode plot of the low-pass filter including the ESR of the capacitor. It should work in both Octave and Matlab. Not as clean as using built-in Matlab functions, but I only have Octave at home. The actual calculation is just a couple of lines, but making a reasonable-looking plot takes a few more.Code:% plot transfer function of simple RC low-pass filter% inputsfmin = 10; %minimum frequency to plotfmax = 100e3; %maximum frequency to plotR = 33; % resistorC = 4.32e-6; % capacitanceResr = 2.6; % effective series resistance of capacitor% calculationf = logspace(log10(fmin), log10(fmax), 101); % frequenciesZc = Resr + 1./(2j*pi*f*C); % complex impedance of capacitorh = Zc ./ (R + Zc); % voltage divider for transfer function% plotfigure% plot gain in top panelsubplot(211);semilogx(f, 20*log10(abs(h)), 'linewidth', 2);set(gca, 'fontsize', 12, 'fontweight', 'bold');ylabel('Gain (dB)');xlabel('Frequency (Hz)');title({'Low-Pass Filter Bode Plot', ...[num2str(R),' Ohm R; ', num2str(C*1e6),' uF C with ', ...num2str(Resr),' Ohm ESR']});grid% plot phase in bottom panelsubplot(212);semilogx(f, angle(h)*180/pi, 'linewidth', 2);set(gca, 'fontsize', 12, 'fontweight', 'bold');ylabel('Phase (deg)');xlabel('Frequency (Hz)');gridCheers!jason

author: RoGeorge
author_rank: Super Contributor
timestamp: October 04, 2022, 01:35:26 pm
content: Quote from: rstofer on October 04, 2022, 12:04:00 amOctave has Bode plots, too.In Octave it's called "bode" what in Matlab is "bodeplot". Octave's "bode" is from the package "control" and has to be loaded before using, and of course installed in case it wasn't installed already. Also, "bodeoptions" is something specific to matlab, to load user's preferred lookout for charts.TL;DR, to install Octave in Ubuntu 22.04 LTS I did this:Code:# add octave repository and update the list of available softwaresudo apt-add-repository ppa:octave/stablesudo apt-get update# install Octave, then install the most needed Octave packages, "control" (octave-control) is one of themsudo apt-get install octavesudo apt-get install octave-control octave-image octave-io octave-optim octave-signal octave-statistics# the install commands I've just run are from https://wiki.octave.org/Octave_for_Debian_systemsThe Bode plot script you posted, but for Octave:Code:pkg load control;close allclearvarss = tf('s')R = 1.0*10^4; % 10k resistorC = 0.1*10^-6; % 0.1 ufd capacitorH = 1/(1+s*(R*C));bode(H);grid on; zoom on;

author: RoGeorge
author_rank: Super Contributor
timestamp: October 04, 2022, 02:04:27 pm
content: Quote from: jasonRF on October 03, 2022, 12:06:32 amThe inline feature doesn't work on this forum. To insert inline pics, you have to post the message first (with its pics as attachements at the end), then edit your message again to add links to the now already posted images.After hitting "Publish", go to your own post and click on one of the thumbnails to enlarge it. Once enlarged the pic, right click and "Copy Image Link" get the image URL.Then edit your just published post, and paste the copied URL inside the text, but you have to put the URL between the img tags (press the binocular "Insert Image" icon from the edit-post icons-bar, then paste the image URL between the img tags). In text edit mode, it should look like this:instead ofCode:Now, the theory (including the ESR) says I should measure the following phase shown in the third image.[attachimg=3]This is close enough to the measurement that I would say the measurement is expected.should becomeCode:Now, the theory (including the ESR) says I should measure the following phase shown in the third image.https://www.eevblog.com/forum/beginners/bode-plot-question-phase-response-of-passive-lp-filter-seems-odd/?action=dlattach;attach=1605499;imageThis is close enough to the measurement that I would say the measurement is expected.and it will display like this:Quote from: jasonRF on October 03, 2022, 12:06:32 amBy the way, thanks for the plots and the detailed explanation+measurements you posted, I found that very useful.

author: rstofer
author_rank: Super Contributor
timestamp: October 04, 2022, 03:20:37 pm
content: Quote from: RoGeorge on October 04, 2022, 01:35:26 pmI kept getting 'not implemented errors' and gave up too soon! Old age and a short attention span...I prefer to use MATLAB but I prefer to post Octave code. I usually test the code on both platforms just to insure compatibility and, in this case, the 'pkg load control' statement is not compatible with MATLAB. Just comment it out, no big deal.Thanks for the fix!

author: rstofer
author_rank: Super Contributor
timestamp: October 05, 2022, 12:43:23 am
content: Quote from: jasonRF on October 04, 2022, 12:22:44 pmUsing the built-in MATLAB functions can cause incompatibility with Octave. I try to avoid that and I failed. Turns out I had a Bode' plot in my Octave folder and overlooked it.I use every opportunity to post code snippets or other plots/graphic images. I think it adds a lot to the conversation.

author: ledtester
author_rank: Super Contributor
timestamp: October 05, 2022, 02:19:29 pm
content: Quote from: RoGeorge on October 04, 2022, 01:35:26 pmFWIW, I was able to run this code athttps://octave-online.net/-- a free online Octave IDE.Just paste the code into the "Octave Command Prompt" at the bottom of the page.Clicking on the "graph" icon allows you to save the plots as either a png or svg.