11-07-2009 09:29 PM
Hello all,
I have a code that is tracing data from a Optical Spectrum Analyzer when certain conditions are met. (fft.VI) The data collected is a reflectance spectrum of a sensor.State 3 is the state that is collecting the data.
I want to make some data processing on the collected data. I attached a sample data set that is obtained by the code.
What I want is converting the power array from dbm scale to mW scale (I have done that), filtering the data with a bandpass filter (the expected frequency of the array starts from 100e-6 and goes up to 200e-6), normalizing data and finding the frequency of the spectrum. I found the necessary VIs and wired everthing but it gave some meaningless results.
Why do you think is wrong in the code? (the expected frequency should be around 130e-6 but according to the code it is 9.645)
Thank you
11-08-2009 01:10 AM
Looks like you just started out, because there are some very strange constructs that either make little sense or are done way too complicated.
( e.g. FFT.vi: State 1: The while loop consumes all CPU doing practically nothing. It needs a small wait. ["collect data?"_AND_ "true"] is the same as ["collect data?"]. You can delete the "boolean AND" and the TRUE diagram constant, they make no difference. State 3: don't operate on entire paths as strings, because you will break platform independence. Use path constants and "build path" and operate only on filenames as strings. You should create some data dependency to ensure that resetting the history data occurs before the loops start. Why is the number of elements a hidden control that is zero instead of 30? Use a diagram constant! The subVI "get last 30 elements could be done with a simple "rotate array" and "replace array element", all that code is way too complicated. etc. etc....)
First of all, whe you attach multiple VIs, please tell us what the name of the toplevel VI is to make our life easier. It's not obvious at first.
Back to your original question. You are feeding a plain 1D array to the FFT, so there is no dt information, this also means that the df of the transform will need to be calculated based on the correct dt that you need to obtain from elsewhere. Once you have df, you can set the x-axis of the transform accordingly (xo, dx). (more information)
11-08-2009 08:24 PM
I could not quite get what you have said. Could you please be more specific? Should I define a sampling frequency for FFT?
Also, what does "shift" and "FFT size" mean at FFT.VI.
Thanks
11-08-2009 11:12 PM
deniz wrote:Should I define a sampling frequency for FFT?
I assume you know dt. This allows you to calculate df as described in the above link: df=1/(N*dt).
This then allows you cna relate the array index to the corresponding frequency for each point in the transform.
deniz wrote:
Also, what does "shift" and "FFT size" mean at FFT.VI.
You can right-click on any function and call up the help pages. In the case of FFT, you would get this information, descibing all inputs and outputs in detail. Is there anything not clear?
11-08-2009 11:33 PM
Thanks for the response
I still could not understand why I would need to use dt. Should I use a VI other than FFT.VI
11-09-2009 12:03 AM
deniz wrote:I still could not understand why I would need to use dt. Should I use a VI other than FFT.VI
No, the plain FFT is fine. All you give to the function is a 1D array of amplitudes. There is no time information and the transform will thus be the same, even if the points in the original are spaced nanoseconds or years apart.
The transfor is a complex 1D array and each array element corresponds to a certain frequency. Obviously, the frequencies need to be scaled according to dt. Agreed?