From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQ Assistant Curve fitting .

Hello, 

 

I am trying the monitor data from my DAQ device, the signal is oscillating with a Damped-Sinusoidal rule: x(t) = A.Exp(-µt).Sinus(wt+phi) • 
So, I want to fit the Real-Data using this equation but I dont really know how. 
The VI attached read real waveforms from my DAQ-Assistant, and when I stop monitoring by buttom STOP, the waveform must be fitted using the equation of x(t).  
So how can i fit this data using the equation x(t) ?
The goal of fitting is to return the Amplitude A !
And another question, I would like to save the waveform in .CSV file but when I saved, I only see in the CSV file the Voltage values ( Y ) and #### in the time values ( X ). 
So how can I save both of X times and Y voltage in .csv file ?
 
The attached VI is enough simple to help me. 
Thanks for helping. 

0 Kudos
Message 1 of 15
(3,218 Views)

Please run the VI until you have some typical data shown on the LVDT graph, select Edit >> Make Current Values Default, then save. Post that VI. This will put one set of data into the graph where it will be available for us to see what is happening. Posting a measurement file would also work.

 

Note that the way you have your program set up, it will be the next acquistion after you press STOP which gets analyzed.

 

Usually #### simply indicates that the column width in the spreadsheet where you are viewing the data is too narrow to display the entire value. It may also represent a format difference but I would expect that to throw an error when the spreadsheet program tries to open the file.  What does the file look like when you open it with a text editor?

 

Lynn

0 Kudos
Message 2 of 15
(3,166 Views)

Hello, 

This is the new VI attached with a sample experimental curve, and cleaned too. 
The second attachement is a sample of .excel file from the experimental curve (Problem of saving .excel file solved, thank you). 

Before labVIEW, I was fitting curves using MATLAB and this takes me times, now, I would like to fit the curve and get the a0 ( Amplitude which I look for) just when I stop the program.

When I stop the program, it is supposed to fit the curve but I dont know how that Fit function works. 
Would you like to help, Thank you again.  

Download All
0 Kudos
Message 3 of 15
(3,064 Views)

Your new VI does not seem to have any data in it. Unfortunately charts do not keep data as default. Try replacing the chart with a graph or post one of the data files.

 

Lynn

0 Kudos
Message 4 of 15
(2,991 Views)

Hello, 

I tried to save data as you told me but I dont know why it is not saving, I just attached the data which I saved into an excel file, Anyway, the attached VI is a very simplified one, It read data from an lvdt and after pushing stop button, I want to fit the data with the equation mentionned before and output me the Amplitude a0 and the fitted data. 
I dont know how to use the Fit Curve VI either plotting the data graph with its fitted function. 
the VI is simple, would you like to help please ? 
Thanks . 

Download All
0 Kudos
Message 5 of 15
(2,948 Views)

OK. I will take a look at it.

 

One thing which is immediately obvious is that the model does not match the data! You need at least one additional parameter. When I plot your data I see a significant offset from the X-axis and your model equation does not have any such offset.

 

Damped sine.png

 

Note that the mean value appears to be approaching 3.5 to 4.0, not zero.

 

One thing I learned from altenbach, who is probably the most expert participant on the Forums on curve fitting, is to always plot the data so you can see what is going on.

 

Lynn

0 Kudos
Message 6 of 15
(2,938 Views)

It fits quite well with an appropriate model.

 

I prefer to use the Nonlinear Curve Fit.vi rather than the Express VI. It requires a bit of extra work but usually gives good results.

 

Lynn

0 Kudos
Message 7 of 15
(2,931 Views)

Here is a version with the model equation in the Express VI fixed.

 

Lynn

0 Kudos
Message 8 of 15
(2,928 Views)

Hello;

 

Thanks a lot for your VI, It works perfectly, and helped me

 

But, when I run my VI with logging from the LVDT for real measurement ; there is no fitting, there no saved data either when I push the stop buttom.
I atteched the new sample .
Could you help please
Thanks again for your help I appreciate.

0 Kudos
Message 9 of 15
(2,890 Views)

I do not have the DAQ Assistant, so I cannot see what it is doing. The Saved Data graph has only two points. If you are only collecting a small number of points on each iteration of the while loop, you will need to accumulate the data in some way, such as a shift register. The file you posted yesterday had 1000 points.

 

You may want to look at the Producer/Consumer Design Pattern. It would allow you to keep the program running and do repeated analyses and saves in one run. This will not solve your immediate problem but may be useful in the future.

 

Lynn

0 Kudos
Message 10 of 15
(2,864 Views)