Author Topic: How to Bode Plot from Sampled Data?  (Read 38510 times)

0 Members and 1 Guest are viewing this topic.

Offline MechatrommerTopic starter

  • Super Contributor
  • ***
  • Posts: 11714
  • Country: my
  • reassessing directives...
How to Bode Plot from Sampled Data?
« on: March 24, 2011, 04:07:45 pm »
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 :(
Nature: Evolution and the Illusion of Randomness (Stephen L. Talbott): Its now indisputable that... organisms “expertise” contextualizes its genome, and its nonsense to say that these powers are under the control of the genome being contextualized - Barbara McClintock
 

Alex

  • Guest
Re: How to Bode Plot from Sampled Data?
« Reply #1 on: March 24, 2011, 05:00:39 pm »
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.
 

Offline allanw

  • Frequent Contributor
  • **
  • Posts: 343
    • Electronoblog
Re: How to Bode Plot from Sampled Data?
« Reply #2 on: March 24, 2011, 06:09:12 pm »
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 stupid :P ignore
 

Offline MechatrommerTopic starter

  • Super Contributor
  • ***
  • Posts: 11714
  • Country: my
  • reassessing directives...
Re: How to Bode Plot from Sampled Data?
« Reply #3 on: March 24, 2011, 11:13:29 pm »
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.
really? 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!
Nature: Evolution and the Illusion of Randomness (Stephen L. Talbott): Its now indisputable that... organisms “expertise” contextualizes its genome, and its nonsense to say that these powers are under the control of the genome being contextualized - Barbara McClintock
 

Alex

  • Guest
Re: How to Bode Plot from Sampled Data?
« Reply #4 on: March 24, 2011, 11:25:18 pm »
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 scope http://www.vellemanusa.com/us/enu/product/view/?id=524708 can do plots automatically for you but it is very limited.
 

Offline scrat

  • Frequent Contributor
  • **
  • Posts: 608
  • Country: it
Re: How to Bode Plot from Sampled Data?
« Reply #5 on: March 24, 2011, 11:36:43 pm »
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.
One machine can do the work of fifty ordinary men. No machine can do the work of one extraordinary man. - Elbert Hubbard
 

Offline MechatrommerTopic starter

  • Super Contributor
  • ***
  • Posts: 11714
  • Country: my
  • reassessing directives...
Re: How to Bode Plot from Sampled Data?
« Reply #6 on: March 24, 2011, 11:42:10 pm »
than achmed for the link. somehow i downloaded it earlier but dont know how i miss it. maybe H function blur my eye :P. @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.
« Last Edit: March 24, 2011, 11:47:42 pm by Mechatrommer »
Nature: Evolution and the Illusion of Randomness (Stephen L. Talbott): Its now indisputable that... organisms “expertise” contextualizes its genome, and its nonsense to say that these powers are under the control of the genome being contextualized - Barbara McClintock
 

Alex

  • Guest
Re: How to Bode Plot from Sampled Data?
« Reply #7 on: March 24, 2011, 11:50:16 pm »
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.
 

Offline scrat

  • Frequent Contributor
  • **
  • Posts: 608
  • Country: it
Re: How to Bode Plot from Sampled Data?
« Reply #8 on: March 25, 2011, 12:03:29 am »
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.

Maybe 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...
« Last Edit: March 25, 2011, 12:15:05 am by scrat »
One machine can do the work of fifty ordinary men. No machine can do the work of one extraordinary man. - Elbert Hubbard
 

Offline Smokey

  • Super Contributor
  • ***
  • Posts: 3216
  • Country: us
  • Not An Expert
Re: How to Bode Plot from Sampled Data?
« Reply #9 on: November 10, 2015, 02:14:28 am »
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... :)
 

Online IconicPCB

  • Super Contributor
  • ***
  • Posts: 1570
  • Country: au
Re: How to Bode Plot from Sampled Data?
« Reply #10 on: November 10, 2015, 05:18:40 am »
Pay an engineer to do it for You.
 

Offline Smokey

  • Super Contributor
  • ***
  • Posts: 3216
  • Country: us
  • Not An Expert
Re: How to Bode Plot from Sampled Data?
« Reply #11 on: November 10, 2015, 08:39:30 am »
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...!!!
 

Offline CatalinaWOW

  • Super Contributor
  • ***
  • Posts: 5658
  • Country: us
Re: How to Bode Plot from Sampled Data?
« Reply #12 on: November 11, 2015, 04:34:02 am »
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... :)

There 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.
 

Offline AlfBaz

  • Super Contributor
  • ***
  • Posts: 2187
  • Country: au
Re: How to Bode Plot from Sampled Data?
« Reply #13 on: November 11, 2015, 04:53:11 am »
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... :)
Yes 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 labview
It 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


 
 

Offline MechatrommerTopic starter

  • Super Contributor
  • ***
  • Posts: 11714
  • Country: my
  • reassessing directives...
Re: How to Bode Plot from Sampled Data?
« Reply #14 on: November 11, 2015, 07:09:25 am »
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... :)
i 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.
Nature: Evolution and the Illusion of Randomness (Stephen L. Talbott): Its now indisputable that... organisms “expertise” contextualizes its genome, and its nonsense to say that these powers are under the control of the genome being contextualized - Barbara McClintock
 

Offline hamdi.tn

  • Frequent Contributor
  • **
  • Posts: 627
  • Country: tn
Re: How to Bode Plot from Sampled Data?
« Reply #15 on: November 11, 2015, 07:52:25 am »
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.
 

Online IconicPCB

  • Super Contributor
  • ***
  • Posts: 1570
  • Country: au
Re: How to Bode Plot from Sampled Data?
« Reply #16 on: November 11, 2015, 08:28:03 am »
Once a bode plot is available it is a fairly straight forward graphical exercise to determine poles and zeros and hence the transfer function.

 

Offline Smokey

  • Super Contributor
  • ***
  • Posts: 3216
  • Country: us
  • Not An Expert
Re: How to Bode Plot from Sampled Data?
« Reply #17 on: December 01, 2015, 02:58:47 am »
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
 

Offline Smokey

  • Super Contributor
  • ***
  • Posts: 3216
  • Country: us
  • Not An Expert
« Last Edit: January 08, 2025, 11:40:01 pm by Smokey »
 
The following users thanked this post: Mechatrommer

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 3426
  • Country: gb
Re: How to Bode Plot from Sampled Data?
« Reply #19 on: January 09, 2025, 02:02:21 pm »
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.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf