02-22-2011 06:28 AM
I seem to have a rather odd problem. I just can't figure out why isn't a certain calculation (refractive index) working properly.
Background info: I measured a high purity silicon plate using an instrument (THz-TDS), suffice it to say that the formulae for calculating refractive index from my raw data is very well established and published. But when I implement this formulae in Labview and run it, I don't get the expected result for
silicon (the published refractive index for high purity silicon is around 3.45), instead I get values around 1.
Any ideas or explanations on what I'm doing wrong are appreciated.
Attached files:
3 VI's where one is the Main. On the Main VI just load the two *.dat files provided and type 0.00198 for sample (silicon) thickness and it should run.
Attached is also the formulae in *.jpeg format.
and a *.doc showing the correct ref. index graph for silicon. Unfortunately I don't have the matlab code that this was originally done from.
Thanks again
Kas
02-22-2011 09:34 AM
Hi Kas,
I took a look at your code, and made a function for comparing the two arrays which is output from the Time to FFT conv.VI as shown:
The output was true, meaning that the two arrays are identical. As you substract these two from each other you get a zero.
This zero "haunts" you for the rest of the code, untill the end where you use the "+1" function just before you output the data in a graph. This explains the output of one.
My guess is that the two *.dat files which you have in the folder contains the same data, hence canceling each other out when substracting them.
If this is not the case, then there could be a problem within the Time to FFT conv.VI
Regards,
Kristoffer Iversen
Application Engineer
National Instruments Denmark
02-22-2011 10:50 AM
Thanks for the reply.
Concerning the two suggestions, all the "time to FFT conv.VI" is convert the Time Domain data to Frequency Domain. as extra pieces, I just add the correct DC coponent, where I also Divide FFT Mags by "n" due to Labview routine, (see p3-3 in function defs).
I actually tried without all this extra stuff and went directly from fft to polar form to collect the phase, but not much difference at all.
As for the files being similar, the values on silicon file are alot less than the background one, for the calculations however I only use the phase difference between the two.
The thing that's making me climb up a wall is that I know the test measurment was correct, since when you divide the "real" part of sample with that of reference, you get the absorption curve (lambeths law), and it provides the correct result. I also know that the formula is correct, since its a published piece of work that everyone in THz-TDS (Terahertz Time Domain Spectroscopy) uses. But when I try to just simply combine it in labview, it doesn't work.
I don't care if its not that accurate at the beginning, since the code can be improved, so long as it at least works.
5 days now and no luck. Never knew that something this simple can be so troublesome.
Kas
02-22-2011 01:49 PM
Maybe you can implement your formulas as formula nodes?
02-22-2011 02:23 PM
I actually tried that but with no luck.
There is one thing I'm curious.
there is a line code in MatLab called: phas1=unwrap(angle(z_face1),pi).
Is that the same this as "theta" from the polar form of FFT?
I made few phone calls and managed to get the MatLab code that calculated ref. index. Attached is the code.
He didn't seem to have implemented the formulae as he should've. But he claimed he had various other samples measured and got the correct answer with this routine.
Again, I tried implementing the same routine but no luck.
is it possible to convert this MatLab into LabView code in a more efficient manner. I might have made a mistake translating from one language to another.
Thanks again
Kas
02-22-2011 03:08 PM
Hi again,
The issue seems to be within the decimal seperator of the *.dat file.
I converted the file into an *.txt deleted the header and replace the decimal seperator from . (punctation) to , (comma) and the graph outputs the following.
Could this be a solution to your problem?
Regards,
Kristoffer Iversen
Application Engineer
National Instruments Denmark
02-22-2011 03:25 PM
No, the graph should look like the one in *.doc. The one you posted is basically the one I keep getting. i.e. if you look on the "y-axis" the graph centers around 1. But it should be around 3.45 instead, as shown in silicon.doc graph. The "silicon.doc" was done using the MatLab code I mentioned. And it seem to provide the correct value with my dataset as well.
I thought decimal seperator is always in . (punctuation) and not , (comma).
Thanks
Kas
02-22-2011 04:21 PM
@zerotolerance wrote:
There is one thing I'm curious.
there is a line code in MatLab called: phas1=unwrap(angle(z_face1),pi).
Is that the same this as "theta" from the polar form of FFT?
No. You need to use the Unwrap Phase.vi from the Signal Processing -> Signal Operation palette.
02-23-2011 01:32 PM
Nice one Darin. That unwrap function did the trick, and thinking about it, it makes sense since FFT provides phase between pi and -pi.
Attached is the updates version of the program and I get the same answer as the published data. However, I have to do "1-" in the end instead of "+1" as the formulae states.
Any other tricks?
Thanks
Kas
P.S. Darin, you came to my rescue once again. Keep up the good work.
11-04-2011 03:39 AM
Hi, I am a bit new to Labview. I am also doing Thz transmission spectroscopy. I did not understand why you put "1-" instead of "1+"? because in the formula it is "1+". Will you help me developing code to calculate absorption coefficient along with refractive index?