How to Bode Plot from Sampled Data? - Page 1
Forum section: electronics / beginners

author: Mechatrommer
author_rank: Super Contributor
timestamp: March 24, 2011, 04:07:45 pm
content: i've been googling about bode plot in the net, and all are talking about transfer functions which makes me dizzy. let say i'm in a situation where i have a blackbox circuit, all i can do is inject a signal (input) and measure the output. from that alone how do i plot a bode chart? how do i create a transfer function for the black box? well, i dont care about the transfer function. all i need is try to plot bode from sampled/digitized data (input and output) alone without interfering with the transfer function. i still have no light from the net

author: Unknown
author_rank: Unknown
timestamp: March 24, 2011, 05:00:39 pm
content: Frist decide on a range of frequencies you want your plot to cover and input signal amplitude.Calculate the input/output gain in dB (attenuation is negative) against the applied frequency at the input. Use an oscilloscope with a sinewave and sweep across your desired frequency limits.Measure the phase shift versus applied frequency on a scope and plot that using the same x axis (frequency) as above.Really, if you examine a Bode it should become obvious on how to do it.

author: allanw
author_rank: Frequent Contributor
timestamp: March 24, 2011, 06:09:12 pm
content: A bode plot is just a regular transfer function plot (output vs input), except the x and y-axes are log scale.edit: Oops sorry, I'm stupidignore

author: Mechatrommer
author_rank: Super Contributor
timestamp: March 24, 2011, 11:13:29 pm
content: Quote from: Alex on March 24, 2011, 05:00:39 pmreally? sound interesting and simple. yes i read that bode plot is just gain vs freq and phase vs freq (in log). so i just determine and gain/attennuation and phase shift from the input vs output, and plot from there? right? determining attenuation sounds simple, how about the phase? how to calculate it? ok, i will study further on this. no mess with H function ehh?. thanx!

author: Unknown
author_rank: Unknown
timestamp: March 24, 2011, 11:25:18 pm
content: Yeah, its straightforward. To measure the phase the easiest way that comes to mind is to connect input to Ch1 output to Ch2 of a scope and see how many degrees the waveforms are off by. Come to think of it, you can measure attenuation and phase shift at the same time.This scopehttp://www.vellemanusa.com/us/enu/product/view/?id=524708can do plots automatically for you but it is very limited.

author: scrat
author_rank: Frequent Contributor
timestamp: March 24, 2011, 11:36:43 pm
content: To know the frequency response of a system you first have to provide a stimulus that covers (as Alex says) the frequency range you are interested in, since if the system is linear (or almost linear, and if it is not the frequency response concept is not applicable) it will respond with the same frequency you are injecting into it.The ideal signal to provide for testing would be a Dirac delta (which contains all frequencies with the same amplitude), but we know infinite is not possible to achieve, unfortunately.Some of the usual signals used for testing a system are the frequency sweep (a "sine" wave linearly or logarithmically changing in time from one frequency to another, so that freq=k*t or freq=k*log(t) ) and step.The sweep is used because it contains almost uniformly distributed all the frequencies in its range, and because it allows to obtain a graphical "bode" plot just using an oscilloscope and looking at the output wave envelope.The step is used in control systems, where you want to see how the system behaves in response to a change (transient) and in its steady-state (DC).If you apply a sweep to a system, and record both sampled input and output, to obtain a bode plot there are at least two ways. The simplest is looking at the envelope of the output divided by the envelope of the input (but this last should be almost constant), all represented in logarithmic scale (both time and amplitude). The other, more accurate, is to calculate the Fourier transform of both input and output, and then show their complex ratio (for each frequency value). Fourier transform gives the advantage of calculating phase, too.

author: Mechatrommer
author_rank: Super Contributor
timestamp: March 24, 2011, 11:42:10 pm
content: than achmed for the link. somehow i downloaded it earlier but dont know how i miss it. maybe H function blur my eye. @Alex, phase determination i meant is by software or some algorithm, not by human visual, sorry it was not clear. i'm thinking of using my rigol and hantek 3x25 as the plotter (as suggested from another forum).thanx scrat for the advice. fourier transform is something that i just learnt, will analyze more about it thanx.

author: Unknown
author_rank: Unknown
timestamp: March 24, 2011, 11:50:16 pm
content: I would do it by eye on a scope screen or with the automated measurement if you are using the Rigol DSO. Really, more accuracy is pointless and meaningless.By the way, if you are making an analog filter say or something you have designed you can throw it on a SPICE simulator such as TINA, LTSPICE, Mindi etc etc which will throw a bode plot back at you with a few clicks.

author: scrat
author_rank: Frequent Contributor
timestamp: March 25, 2011, 12:03:29 am
content: Quote from: Alex on March 24, 2011, 11:50:16 pmMaybe you're right about not needed accuracy... The sweep and post processing is just the fastest way I can see (provided you have a function generator).Since Shafri is working on PC processing for the Rigol, that's why I'll say once more something about post processing.From the sampled data it's easy to measure frequency (or take the data from the scope's counter) and calculate the amplitude-phase for that particular harmonic (just calculate one sine-cosine couple of the Fourier series).This kind of measurement can be very accurate, since it automatically rejects noise and averages the phase shift, but also very quick. If you are already using a PC tool for the scope, integrating this feature could let you take a bode plot even from a single capture of a square wave input and the related output.@shafri: BTW, could you please post a wfm capture from the Rigol, showing at lest 10 periods of a square wave input and the ouput of a system which you'd like to get the bode plot? I'd like just to try writing something...

author: Smokey
author_rank: Super Contributor
timestamp: November 10, 2015, 02:14:28 am
content: Has anyone written an analyzer yet to take a dual trace data capture from a scope consisting of a continuous frequency sweep from a function generator input and the output of a system, calculate phase and amplitude, and plot the bode plot?I hate it when one of these problems sounds all straightforward but you know it will take hours and hours of coding to actually implement. Please tell me someone already did this..... please...

author: IconicPCB
author_rank: Super Contributor
timestamp: November 10, 2015, 05:18:40 am
content: Pay an engineer to do it for You.

author: Smokey
author_rank: Super Contributor
timestamp: November 10, 2015, 08:39:30 am
content: Opening bid.... one dollar.....anyone...anyone???Don't make me keep threatening to try to write code again... I'll do it.. I'm not joking...!!!

author: CatalinaWOW
author_rank: Super Contributor
timestamp: November 11, 2015, 04:34:02 am
content: Quote from: Smokey on November 10, 2015, 02:14:28 amThere are lots of instruments that do this, including free software using the sound card on the pc. Many of the USB scopes include this function. I haven't paid any attention so don't know if anyone has put anything out there which will grab arbitrary data from an arbitrary scope and do the math. Lots of parameters to think about so I kind of doubt it.If you feed pseudo random white noise (or real white noise if you have a source for that) into the circuit, use the scope to record the response and export it to a text file it is only a few minutes work to import the data to Excel and do the FFT there (using the Engineering tools add-in that comes with Excel, but is not automatically installed). Since white noise has a constant amplitude at all frequencies the transform of the circuit output is the transfer funtion of the circuit. Even if you haven't done it before it shouldn't take more than a couple of hours to learn and pretty up the output graphs. Do be sure to think about sample rate and span first to make sure that the data you collect gives you the frequency range and resolution you require.There are details (band limiting, time and amplitude quantization effects and so on) which won't be a problem in many cases, but which you should take time to understand if you plan to do a lot of this. Oversampling is the brute force answer to all of the problems.

author: AlfBaz
author_rank: Super Contributor
timestamp: November 11, 2015, 04:53:11 am
content: Quote from: Smokey on November 10, 2015, 02:14:28 amYes I have done it with a lecroy scope and a wavetek sig gen and aside from it being a bit slow it works well. Unfortunately <ducks from the incoming abuse> its all in labviewIt gets a bit ugly as you have to increase volts and seconds per division on the scope as the amplitude drops and the timebase gets to large. These "adjustments" cause the glitches seen below

author: Mechatrommer
author_rank: Super Contributor
timestamp: November 11, 2015, 07:09:25 am
content: Quote from: Smokey on November 10, 2015, 02:14:28 ami made the bode plotter by controlling hantek DDS3x25 connected to DUT to Rigol DS1052E (DS1000E series) and then the signal back to the plotter. if you have both insrument for the purpose, then feel glad to inform me for download link. otherwise it will be pointless...edit: that above is for automated sweep and log/plotting mode... for manual or interval plotting mode, you can use any FG but the signal capture must be from DS1000E series to PC USB... so if you have at least DS1000E series scope, you can use this tool in manual or interval mode.

author: hamdi.tn
author_rank: Frequent Contributor
timestamp: November 11, 2015, 07:52:25 am
content: To do that it's always better to have a signal analyzer , but a scope will do perfectly.I did it once to draw bode for a simple filter, swap frequency generator (for me was a uC generating input signal ) and a scope.I think Matlab include a system identification toolbox, so you may be able to calculate the transfer function using frequency response.

author: IconicPCB
author_rank: Super Contributor
timestamp: November 11, 2015, 08:28:03 am
content: Once a bode plot is available it is a fairly straight forward graphical exercise to determine poles and zeros and hence the transfer function.

author: Smokey
author_rank: Super Contributor
timestamp: December 01, 2015, 02:58:47 am
content: Got back to working on this again. Just found an awesome paper from Stanford Research about exactly the technique I'm looking to implement. To bad their SR1 hardware starts at $9400USD.http://www.thinksrs.com/downloads/PDFs/ApplicationNotes/SR1_SweptSine.pdf

author: Smokey
author_rank: Super Contributor
timestamp: January 08, 2025, 11:34:34 pm
content: just to close the loop...https://www.eevblog.com/forum/projects/bode-plot-from-swept-sine-input-and-scope-captured-data/and another thread talking about the same stuff:https://www.eevblog.com/forum/testgear/bode-plot-for-scope-owners-that-do-not-have-that-option/

author: mikerj
author_rank: Super Contributor
timestamp: January 09, 2025, 02:02:21 pm
content: If you have the data in a suitable file format (e.f. CSV) you can use Excel to perform an FFT which you can then plot however you want.