LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to produce a Logarithmic Sweep (Chirp) over a Frequency Band

Hello, thank you very much for your help so far. I hope your work is going well. I don't think you need too read the article anyway, there are just a few pages that highlight the preference for sweep method and how to implement it. Please can you look at the new thread I started below?

 

http://forums.ni.com/t5/LabVIEW/Transfer-Function-Impulse-Response-and-Impedance-of-a-DUT-to-a/td-p/...

 

Thank you. Right now, I need help with getting the FFT of an input sweep and FFT of the output voltage. Then I hope to get the ratio i.e. transfer function. Once again, as a newbie, I am unsure about where to start.

 

Thanks a lot,

 

Daniel

0 Kudos
Message 11 of 44
(4,725 Views)

Daniel,

 

There are VIs for FFT, Inverse FFT (Signal Processing >> Transforms), and Chirp Pattern (Signal Processing >> Signal Generation).  Those should get you started.  Note that the Chirp Pattern.vi uses frequency units of Samples/cycle and the FFT VIs work on arrays without any internal knowledge of the time or frequency intervals between samples. See the detailed help files for more information. So you need to do some bookkeeping to make things match up with your real frequency requirements.

 

Here is a little example VI using these VIs.  I put an elliptic filter in to simulate the transfer function of your DUT.

 

The Sweep Synthesis section of your paper (section 4) starting on page 35 show how to calculate the phase increments for the sweep.  Note that the Chirp Pattern.vi uses calcuations similar to equations (3) and (4) although you need to account for the normalized frequency units.

 

Lynn

0 Kudos
Message 12 of 44
(4,712 Views)

Thank you very much. Did you attach something? I don't see that anything is attached.

 

Thans a lot.

 

Daniel

0 Kudos
Message 13 of 44
(4,709 Views)

Daniel,

 

It looks like I forgot to attach it.  Try again.

 

Lynn

0 Kudos
Message 14 of 44
(4,705 Views)

I am very grateful. I looked at the VI you attached; thanks a lot. It got me started with my setup.

 

I am very interested in seeing what H(f) is at the different frequencies. I am having trouble figuring out the best way to map each H(f) value to a frequency. I wonder if I can use maybe a spreadsheet. One important thing is that the H(f) is complex. For now, my graphs aren't looking good but I believe I'll figure some of it out.

 

Thank you,

 

Daniel

0 Kudos
Message 15 of 44
(4,690 Views)

Hello, I just replied with my friend's account unknowingly. I have played around in MATLAB and I hope to achieve in LabVIEW some of the stuff I did in MATLAB. One important thing is that the input signal (chirp) should last a certain while and then instantly drop to zero (and remain at zero for a certain while). In other words, in MATLAB, I had the number of samples go from 1 to 2N while in fact it was ZERO from N to 2N (eg. input voltage could have a total of 8 samples while it have non-zero values only for the first 4).

 

If need be, I can attach my MATLAB code.

 

Thank you,

 

Daniel

0 Kudos
Message 16 of 44
(4,686 Views)

It is quite easy to pad the array with zeros.  Determine the length of the array (non-zero part).  Then initialize an array of zeros of the same length.  Use a Build Array primitive to combine the two arrays into one longer array.

 

The standard graph can only display real numbers.  You can use the Complex to Polar function and plot r and theta on the same graph or separately.  With appropriate scaling of the X-axis you should be able to get H(f).

 

Lynn

Complex Graph Padded.png

0 Kudos
Message 17 of 44
(4,682 Views)

Thanks a lot; you have been of tremendous help. Please tell me about samples/cycle; my f1 and f2 are 20 and 20k Hertz.

0 Kudos
Message 18 of 44
(4,672 Views)

I think we have found an error in the detailed help for the Chirp Pattern VI.  The normalized units should be cycles/sample not samples/cycle.

 

The Chirp Pattern VI was introduced in LV 8.0. The detailed help for that version specifies the normalized frequency in cycles/sample and the pattern frequency range as f1/fs to f2/fs where fs is the sample rate.  However, when you look at the units: (Cycles/Sample)/(Samples/second) = (Cycles*second)/(Samples^2)

 

In LV 10 The normalized frequencies are in units of samples/cycle and the pattern frequency range as f1*fs to f2*fs.

 

In both help files the yi values are specified by the same formula.

 

Let's look at the definitions: Real frequency (fr) is measured in units of Cycles/second (Hz). The sampling rate (fs) is specified in Samples/second. If we calculate a normalized frequency as fn = fr/fs, then we get the units of normalized frequency as (Cycles/second)/(Samples/second) = Cycles/Sample.  These are the units used in the LV 8 help.  If the Chirp Pattern VI uses normalized frequencies f1 and f2 , then the real frequencies fr1 and fr2 which correspond to them are fr1 and fr2 =  f1*fs and f2*fs.

 

So both the LV 8 and LV 10 help files are wrong, although in different ways.

 

Now, what  do you do?  First, you need to decide on a sampling rate, fs. Several factors affect the choice.  The Nyqist criterion requires that fs be greater than twice the highest frequency being generated. However, if you want something which looks and acts reasonably sinusoidal you will need many more than two samples per cycle. Choosing fs > 10* fmax is about as low as you would want to go. Finally the total sweep time multiplied by the sample rate (fs) gives the total number of samples required.  Memory allocations and buffer sizes may need to be considered.

 

As an example let's consider 50 samples/cycle at the highest frequency and a ten second sweep duration. This gives fs = 50 * 20000 = 1000000. The number of samples is 1e7.  The normalized frequencies become  f1 = 0.00002 and f2 = 0.02 cycles/sample.

 

I will start a new thread to report the documentation error.

 

Lynn

0 Kudos
Message 19 of 44
(4,658 Views)

Thank you. We have LV8 here. Does that mean I should type in f1/fs to f2/fs for the sweep to achieve the sweep from f1 to f2? This may be the reason my plots haven't made any sense so far.

 

Thank you,

 

Daniel

0 Kudos
Message 20 of 44
(4,636 Views)