LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Linear fit between two cursors from a signal from a NI-instruments via DAQ-Assistant

Solved!
Go to solution

Hi ! 


I'm currently having som problem with my labview code. I'm trying to make regression on a specific part of my graph. The graph consist of a signal gathered from a NI cDAQ-9178. Currently I can get the live data in a graph (Raw Signal) and then  "zoom in" to the part of the graph that im intrested in by two cursors and then display the results in a new graph (Adjusted Signal). Now a want to make regresion in the new graph. How can i do this the best way ? 

 

 

To be noted I'm a beginner of labview so my code maybe a bit off.

 

Best regards Maurlind

Download All
0 Kudos
Message 1 of 10
(2,834 Views)

Hi maurlind,

I have taken a look at your VI and modified it a bit. I have arranged so that you get a proper data flow and error handling. You can see it as a suggestion.

To test the program, I replaced the DAQ assistant with a Simulated Signal express VI. To test it, you can collect the signal (with logging) for a few seconds. Then press the "Stop DAQ" button. After this, you can analyze the data by moving the cursors. The "Adjusted signal" graph then shows the data window of interest together with the linear regression (fit). The equation for the fit is placed in the "Adjusted signal" graph.

 

I hope you will find some use for it ;).


Message 2 of 10
(2,670 Views)

Hi again!

 

With the simulated signal it works great. But with my aquiered signal it does not, somtimes the linearfit  dosen't work instead i get infinity between the x values. I think it is beacause i dont have my x-axis from 0,1,2,3,4....
Instead it is in date and time, like 14:45 2014-05-07. Dont know if you can change it to start from zero. Is there away to do so? Maybe an internal clock or external clock could work. 

 

I have attached a picture of the problem.

 

Best Regards Maurlind

0 Kudos
Message 3 of 10
(2,609 Views)

Hi maurlind,

 

Could you attach some logged data (e.g. the one you display in your screenshot) that I can import and test?


Message 4 of 10
(2,595 Views)

Hi again!

 

This is what i got from the logged data.

 

The attached screenshot shows that the regression line is way off what it is supposed to be. 

unfortunately the logged value dosen't show that much of information. Hope these file can be any good to solve my problem.

 

Thank you for taking time with my problem, once again!

 

Best regards Maurlind

Download All
0 Kudos
Message 5 of 10
(2,575 Views)

Hi maurlind,

 

I was talking about the plot you show in "Raw Signal". Please attach a file with the input data that can generate the "Raw Signal" plot. Your "logged data.txt" does not contain anything.

 

You can do this by adding e.g. a "Write to Measurement File" Express VI and draw the Raw Signal thread to it. The resulting file can enable me to simulate your signal and analyze the problem.


Message 6 of 10
(2,544 Views)

Hi !

 

I have attached a screenshot of the results represented by the aquired input data. The input data is attached as a text file.

Hope this works for you!

 

Best Regards Maurlind!

Download All
0 Kudos
Message 7 of 10
(2,502 Views)
Solution
Accepted by topic author maurlind

Hi maurlind,

 

I got it, the function that derived the linear fit couldn't handle that large numbers on the x-axis. I edited the VI so that the large number is suctracted for the fit, i.e. the array will now begin at zero time for the fit. It will not affect your plots though, only the algorithm :).

 

Try it now with the files I provided. The file "pm_mod2_Rawsignal test.vi" should be used with "test3.lvm" (your data). The file "pm_mod3_Rawsignal test.vi" is the same as "pm_mod2_Rawsignal test.vi", but it is arranged to work with the simulated data. The file "test3.lvm" is your data, but the file is slightly edited to work on my system.

 

Edit "pm_mod3_Rawsignal test.vi" to fit with your acquired signal as you did with the first file you got from me.


Message 8 of 10
(2,487 Views)

It works!

 

Thank you for all the help, I really appreciated it. Smiley Happy

 

Best Regards Maurlind

0 Kudos
Message 9 of 10
(2,392 Views)

Hi maurlind,

 

No problem!

 

PS. don't forget the kudo button if you found it helpful 😉


Message 10 of 10
(2,385 Views)