LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Changing the x-axis variable and delta x in write to spreadsheet function

When this VI writes the data to spreadsheet it varies delta X based the frequency being generated.  I need to be able to control the starting and ending frequencies and the change in frequency between data points before running the VI.  I have tried "horizontal config", using a loop with the "collector" sub-VI, and "extract portion of data" and none of which have changed delta X.  Also, the spreadsheet says the x-axis is time, while the graph that the same data gives is in frequency.  I don't know how to change what the "write to spreadsheet" thinks the axis is. 
 
Thank you!
0 Kudos
Message 1 of 10
(4,351 Views)

I've been looking into your posting and I have a few questions to help me understand better what is going on with your program:

1)  Are you saying that the program is currently varying the start, stop, and delta X based on the frequencies being generated? And instead you want to be able to specify which frequency you start collecting at, which frequency stop collecting at, and the space between each frequency you write to file?  Do I have that right?

2)  The graph on the VI you sent has "time" on the X axis.  Your post said it has "frequency."  To which graph were you referring? 

3)  On your block diagram, the t(0) of your incoming waveform is connected to the "dt" of the Build Waveform.vi.  Was that intentional?

Your answers will help me better find solutions to your questions.  Additionally, I would recommend not using the "Write to LabVIEW Measurement" VI in your application, and instead use the actual Write to Spreadsheet.vi, or any other VI that writes data to a file.  That way you will have the flexibility to create a header that makes sense and can decide what values you write.  By using a more flexible write VI you should be able to decide which samples and at what delta X you write to file and display.

Regards,

Todd S.

Todd S.
LabVIEW Community Manager
National Instruments
0 Kudos
Message 2 of 10
(4,334 Views)
In an earlier posting, I showed him how to convert the data from the scope to a waveform datatype. In the jpg I posted, delta t of the scope was wired to dt of the Build Waveform. He's got it miswired now. If I had included t(0) and wired it to t0 of the Build Waveform, he might not have gotten confused.
0 Kudos
Message 3 of 10
(4,327 Views)

Todd,

Thanks for your help.  Here are answers to your questions:

1)  Yes, the delta X is varying based on what input I am using and what sort of frequency range that input has.  I want to be able to set this to a smaller portion of the frequency as I am looking at sound propagation at particular frequencies.  I would also like to be able to control delta X, or at least have it always be sufficiently small (maybe 50Hz or less).

2)  The first graph is of amplitude vs. time.  The second graph is of amplitude vs. frequency (because it is after the FFT analysis).

3) I believe I correctly fixed the miswiring of dt in the build waveform.  I don't know how I crisscrossed that. 

I have also changed to the "write to spreadsheet.vi" as you recommended. I now am getting a row of data with 256 points in it.  This data file is the correct frequency of the spectrum (it correlates with the 2nd graph).  The ending frequency is at 10^8 Hz, which means delta x is ~4x10^5 Hz which is too large.

Thanks for your help.  Hopefully this will answer some of your questions.  I've attached the updated .vi and can post the excel file if you would like to see it.

-Jay

0 Kudos
Message 4 of 10
(4,306 Views)
Jay,
 
All of the delta x stuff is handled automatically in your application the way it is implemented now. The df of your frequency plot is derived from the dt of your time plot according to the standard FFT alrogithm, df = 1/(n*dt), where n is the number of points. You can read more about FFT here if you're curious. So if you're wanting to resample data in the frequency domain (change the delta x on your frequency plot), then you will need to resample it in the time domain since df is a derived value. I am not sure why you want want to resample the data, since your dt is currently directly transferred from the TXTDS Read VI, but if you would like to apply a new dt to the data, simply delete the wire to your dt input on the Build Waveform VI and connect your own value.
 
Kind Regards,
E. Sulzer
Applications Engineer
National Instruments
0 Kudos
Message 5 of 10
(4,295 Views)
Jay,
 
In an afterthought, it occurred to me that I may have misunderstood your question and it may be that you are just wanting to extract a portion of the FFT transformed data. If that is the case, then you can just use the Array Subset VI to extract the portion of the data in which you are interested. You would need to use the f0 and df values to determine the index of the first value in your subset and the number of elements in that subset.
 
Kind Regards,
E. Sulzer
Applications Engineer
National Instruments
0 Kudos
Message 6 of 10
(4,293 Views)
E. Sulzer,
   
Thank you for your help. 
 
I think the description below may help you understand my problem more.
 
The VI is doing all of the following correctly:  Capturing the signal, performing the FFT, and putting the FFT amplitude v. frequency data on the graph.  What it is not doing correctly, is writing good data to the text file.  I need Labview to take the data from this graph (of amplitude v. frequency) and give me that amplitude and frequency data in an excel file.  With this, I can find signal loss in particular frequency intervals given that df is sufficiently small (less than 100Hz).  With the VI as it is, it produces an excel file with a row of 0s.  Looking at my block diagram, can you see why I am not getting the data in the file that I need?  I have tried the "write to spreadsheet file" VI as well as the "write to excel spreadsheet" VI with nothing working correctly. 
 
The file is attached in my earlier post.
 
Thank you,
Jay
0 Kudos
Message 7 of 10
(4,271 Views)
Try changing the format specifier of Write to Spreadsheet File from %.3f to %f. The %.3f limits the numbers writen to 3 decimal places.
0 Kudos
Message 8 of 10
(4,267 Views)
Okay, great, I changed the format to %.3f.  Three non-zero data points are in the file.  These show the peak at the single frequency (3kHz) I was generating!  The df=100Hz and there are 256 cells of data. 
 
I next hooked up the pulse generator, which is needed for the experiments (the pulse generator delivers a burst across a full range of frequencies through a transducer)  Because this encompassed a much larger range of frequencies (and cannot be adjusted) and because the data is being written only to 256 cells, df increased to about 400kHz as the maximum frequency on the graph was 1E8. 
 
Is there some way we can have the FFT ignore or throw out frequency values over 25kHz so the 256 cells can hold all of the data at df=100Hz?  Or any other ideas?  Hopefully, the situation makes sense, let me know if you need clarification. 
 
Thank you,
J
0 Kudos
Message 9 of 10
(4,256 Views)
As I said in my previous post, the df of your frequency plot is derived from the dt of your time plot according to the standard FFT alrogithm, df = 1/(n*dt), where n is the number of points. If the number of samples is the same, the only reason for an increased df is a decreased (finer resolution) dt. If you would like to decrease your df to 100Hz and maintain a number of samples of 256 in the frequency domain, then you will need to increase the number of samples acquired in the time domain and then resample the signal before sending it to the FFT. By my calculations with the numbers you gave, you will need to aquire 4,000 times the number of samples in the time domain and then extract every 4,000th sample in the array to compile a resampled signal of 256 points with a dt of ~39us.
 
Kind Regards,
E. Sulzer
Applications Engineer
National Instruments
0 Kudos
Message 10 of 10
(4,239 Views)