LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Frequency sweep with peak frequency

Hi guys, I need some help here. I´m using a NI 9215 to do a frequency sweep from 30 to 90 Hz.

So far so good. Now I need a resulting resonance frequency at highest voltage.

 

I tried a max peak frequency VI but couldn´t get it to work.

Any idea what to do?

 

mfg, Andi

 

ok, here is my sweep.vi for better understanding

 

 

Message Edited by andinew on 08-11-2009 04:14 AM
Download All
0 Kudos
Message 1 of 9
(7,249 Views)
Hi Andi,

one thought first off: looking at your "create_log_frequencies.vi", I realized that it generates linear frequency hops, not logarithmic ones...

But on to your question: to find the frequency with the highest amplitude (this will be your resonace, I guess), you will have to look at the entire signal - your "sweep.vi" code iterates the measurement and interpretation five times per second, independantly of the speed of the sine sweep.

My advice would be to generate one waveform containing the whole sweep run, and writing this sweep block for block with a constant sample rate onto the output. You could then read back the response with blocks of the same size as your output, do the single tone measurement on this block and store the resulting frequency and amplitude in an array preserved trough a shift register or simply into two auto-indexing tunnels. The latter is okay as you don't need a "while loop" in the measurement loop (you know how long the analog output loop runs - why not use this information to configure a "for loop").

After your analog input "for loop" has finished, search your amplitude array for the maximum - then use the found element's index to index the frequencies array and return the corresponding resonance frequency.


A good starting point could be the example I wrote a couple of month ago: it runs continuously the same "sweep" (you'd have to adjust the waveform, I know) and reads back the stimulus and the response (wire the output to your probe and parallely to ai0, your response signal will be connected to ai1). You can then insert tone measurements etc.  at the marked section...

When trying to open the example, you will be prompted to find a VI called "_Get Terminal Name....vi" - you can find this VI at the following location: C:\Programme\National Instruments\LabVIEW 8.5\examples\DAQmx\_Utility\_Utility.llb



As an afterthought: the "phase difference" you are calculating between every other sample of the analog measurement array is a bit confusing: if oyu need the phase difference between the original signal and the stimulus response, you will need to wire the stimulus to a second input and compare the phases of the two separate signals...



Best regards,
Sebastian
Message Edited by SFK on 08-12-2009 04:12 PM
0 Kudos
Message 2 of 9
(7,210 Views)

Thanks Sebastian, I just came back and read your reply.

Ok thanks for your advice, I´ll try it out and post my results the next days.

mfg,Andi

0 Kudos
Message 3 of 9
(7,179 Views)

So, I studied your VI some time, but I have a few questions.

 

Im using a for-loop to create my sweep signal, is it possible to create my output signal like this (output.vi) ?

http://forums.ni.com/ni/board/message?board.id=170&message.id=430352&requireLogin=False

 

Your idea to use a for loop to read my input is nice. but where should I put my start and stop task VIs? Do I need to put em inside a loop or is it ok to run em just once outside my for-loop?

 

Last question is, I put a method together to search for my resonance frequency, but I couldnt figure out the parameters for my Index Array.

Is this method ok,or do you know a better way to do it?  SchleifeLesen.vi

 

If you like  to talk deutsch, please tell me

 

cya,andi

 

Download All
0 Kudos
Message 4 of 9
(7,157 Views)

Hi Andi,

 

you can use a FOR LOOP and build a waveform bit by bit all right - you might want to use the [i] output instead of the[N] output though. Also, please observe that without a manual phase correction in each step, you will get ugly glithes in the waveform, as depicted in the following screenshot:

 

sweepgen.gif

The placement of the "Start Task" and "Stop Task" VIs is quite okay, no need to place them into a loop if you only need one run of your VI.

To your last question: your peak amplitude search still needs improvement: as you currently have discrete frequency steps, simply multiplying the maximum amplitude index with the sample count will not do the trick. Depending on the stimulus signal (is the sample count per frequency constant, or do you output a constant number of periods per frequency), you would firstly have to generate a list with all frequency<->sample number pairs, and then match the found sample index with that list...

 

Btw: the "index array" function does not necessarily require index parameters - by default, it indexes the rows of a 2D array - which is exactly what you need. If you want to make sure, you can wire the constants "0" and "1" like this:

2Darray.gif

 

Best regards,

Sebastian

Message 5 of 9
(7,148 Views)

haha, youre right, wiring the N output wasnt the smartest idea.:smileyvery-happy:

 

Hmm, do I need "reset signal" in my signal generation? If I leave it out, there are no phase hops in my final signal.

 

Couldnt I  just use your transformation from data to waveform and use the "Extract single tone information.vi" like in the picture?

I  must admit, I have no idea, how to build a list,or do you mean another array? 

 

Ah, ok now I get it with arrays,thanks.

 

cya,andi

Download All
0 Kudos
Message 6 of 9
(7,133 Views)

Hallo Andi,

 

wenn Du die "Extract Single Tone"-Funktion auf das gesamte aufgenommene Sweep-Band anwendest, kann alles mögliche herauskommen - sinnvoller ist es deshalb, das Antwortsignal Schritt für Schritt zu analysieren.

 

Du erzeugst doch ein Stimulus-Signal mit bekannter Form: n Samples lang Frequenz 1, dann weitere m Samples die Frequenz 2, und so weiter...

 

Wenn Du ai und ao miteinander synchronisiert hast, weißt Du doch auch, welche erfassten Samples zu welchem Frequenz-Stimulus gehören - dementsprechend kannst Du doch mit der "Array SubSet"-Funktion immer einen Teil aus dem Waveform-Y-Array ausschneiden und separat auf eine "Extract Single Tone"-Funktion geben. Die detektierte Amplitude speicherst Du in einem neuen Array, und suchst daraus dann später das Maximum - dann hast Du den Index der erzeugen Frequenz, die an deiner Resonanzfrequenz am nächsten dran war...

 

Gruß,

Sebastian

0 Kudos
Message 7 of 9
(7,085 Views)

Danke für die Tips, aber jetzt hab ich entnervt aufgegeben.

Habe alles in einer Sequenz einzeln zusammengestellt und ohne Array realisiert.

Das einzige Problem ist noch bei der Phasendifferenz, daß ich seltene Sprünge habe, aber sonst klappt alles ganz gut.

Wenn einer Interesse an dem Programm hat, Bitte schön: 

 

Für Verbesserungen hab  ich jederzeit  ein offenes Ohr 🙂

0 Kudos
Message 8 of 9
(7,030 Views)

Ups, i forgot the main program

 

 

0 Kudos
Message 9 of 9
(7,029 Views)