LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Curve Fitting

Extremely new to Labview.  I'm actually a co-op at my company.  I have been able to work my way through things up to this point,  but do to lack of training(which will never be provided) I have encountered a problem.  I'm trying to use the curve fitting function to curve fit a signal from a DAQ Assistant.  First off we have Labview 7.0 and the hardware is a SCXI-1000 chasis with a SCXI-1520 module.  I have the DAQ Assistant set up for the load cell and my goal is to curve fit the voltage signal from the load cell and then write a .lvm file with the fitted data.  I've looked through the help for the curve fit function, but still can't seem to get it to work.  The best I got was my vi would start and then stop automatically in about 1 second or so.  I can do everything other than the curve fitting.

 

Thanks in advace for the help.

0 Kudos
Message 1 of 28
(3,703 Views)
My mistake.  It's actually LV 7.1 not 7.0.  Can anyone help please?
0 Kudos
Message 2 of 28
(3,683 Views)

Let's try to separate the problems.

 

1.  It sounds as though you can acquire a signal, but only one time before the program stops.  Is this correct?  This may not have anything to do with the curve fitting.

 

2.  Do you have a good mathematical model for how the signal should behave?  This is what you will be fitting the data to.

 

3.  What happens when you try to curve fit?  Do you get an error message?  If so, what is the error code?  Does the fitted curve not look like the data?  In what ways? Please show some actual data along with an image of what the fit should look like.

 

4. Does the file write part work? 

 

Please post your VI as you have it so far.  It is much easier to troubleshoot a VI than a paragraph.  Take some typical data.  Then go to Edit >> Make Current Values Default.  Save the VI.  Then post the VI you just saved.

 

Lynn 

0 Kudos
Message 3 of 28
(3,682 Views)

What kind of fit do you try to perform?

Please post code/screenshot of the piece where you're stuck.

 

Felix

0 Kudos
Message 4 of 28
(3,679 Views)

Everything works until I add the curve fit part.  I am attempting to perform a 6th order polynomial fit.  I have attached screen shots of the working vi, the not working vi, and an excel plot of the data.

Download All
0 Kudos
Message 5 of 28
(3,670 Views)

Ok, we need some more info. Can you post you Express Vi configuration. Or even better, get rid of all that Express-things and use the 'General Polynomial Fit.vi'. (Located under Analyze -> Mathematics -> Curve Fitting in 7.1). Do you get any error codes?

BTW: Looks like it is a gaussian profile, so why not use that function to fit is?

 

Felix

0 Kudos
Message 6 of 28
(3,666 Views)
I can try to use the "General Polynomial Fit.vi" however again I am inexperienced, so I would need an example or something to figure out how to use it in my vi.  I do not get any error codes when I run what I had.  I can run the vi, but it almost immediately stops on its own.  I just attempted to wire the "General Polynomial Fit.vi" in place of the express vi and it did the same thing.  Again with no error codes.
0 Kudos
Message 7 of 28
(3,661 Views)

For the math VIs you only have an I32 error code. In the Time & Dialog Function palette you find a vi to convert that to a LV error cluster. To the right of your loop, place a general error handler.

 

To help us solving your problem, you could do the following: Create a subVi from your Fit Vi (Select VI, Menu: Edit -> Create SubVI). Run your program. Go to the SubVi and select Edit -> Make Current Values Default. Post that SubVI to this thread, then we can run it with the data on our own PC's.

 

Felix

0 Kudos
Message 8 of 28
(3,658 Views)
I attached a print screen of what I tried to do with the "General Polynomial Fit.vi".  As far as the Gaussian Fit, it only looks like that due to the trigger I have set up.  Basically I'm trying to get a curve for which I can then differentiate in order to find the peak on the plot.  I guess this would bring me to another question.  I found a vi which is a "peak detecting" function(Peak Detector.vi).  Would this be better to use?  If so, how do I go about using it?
0 Kudos
Message 9 of 28
(3,657 Views)

On your screenshot, I clearly see that you have not defined the polynomial order (which should be 6 as you say). Also, you only gave Y-values, no corresponding X values (guess that is the issue for everything). There is an example shipping with that Vi to get you more help. Go to the Help Window (Ctrl+H) and Click 'Click here for more help'. On the bottom of that page you will find an option to find/browse the examples.

 

To the general question of peak detection. You could go as simple as just to look for the maximum in your data array. If you have no noise, that is ok. But as the signal contains some noise, you're better of using a fit (but you must have some physical model of the process to know which fit to use!). The fit coefficient you will wire into an find maxima vi (I don't have the name in my mind), which mathematically will give you the correct location of the 'peak'.

It really depends on the physics and less on LV, but the people on this forum are experts on these domains as well.

 

Felix

0 Kudos
Message 10 of 28
(3,653 Views)