LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Need to compute area under curve with help of cursor

Please refer to my attached VI and also the word document file. I need to measure the area under the curve of the waveform (pls refer to Word doc) using to sets of cursors. I currently have a problem with that as the values are not displayed at all or displaying an incorrect value. Can you please have a look at my VI and help me modify it so that it would calculate the area under the curves and display it in LabView.
Download All
0 Kudos
Message 1 of 8
(3,533 Views)
I don't have the required sub-vi's to test your program, however if you want the integral to be computed every time the cursors are moved I suggest the following: Use a shift register, expanding the left hand register so that it outputs the second to last run also. Wire a bundle or build an array of the cursor values and connect that to the right hand shift register. Wire the outputs of the double shift register to an equal function, and set it to compare aggergates. This will output a false if any of the cursors have been moved. Use this boolean as the controller for a case structure that contains that code you have already written. Sorry I can't comment on the integral function.
0 Kudos
Message 2 of 8
(3,533 Views)
HI,

thanks for your reply. However, I am a newbie to LabView and I am not sure of what you said. Can someone have a look at my file and perhaps give more comments? thanks
0 Kudos
Message 3 of 8
(3,533 Views)
Looking over your code again, I realize that your current program is sufficient for calculating the integral. However, you are incorrectly using the integral.vi, which is why you are getting strange numbers out of it.

I have attached a vi I just wrote that performs the function you want to a generated ramp pattern. You can copy and paste and then integrate this code into your program.

Note that as this is a numerical integration scheme, the result is going to have some error.

Hope this helps.
0 Kudos
Message 4 of 8
(3,533 Views)
S Nate dx,

Thank you so much for your help. However, I noticed in my readings that the baseline for my curve is not on zero x-axis. It is slightly below and I have some noise added in as well. Will this somehow affect my readings and will the error be small enough to be neglected?
The example you showed me was using a ramp signal input that has a constant f(x) function. Please refer to the attached file and you would notice that my readout is not a constant function. It comprises of two curves (one maximum and one minimum) that is roughly the same but it doesn't have f(x). Can you still find the area below the curve then?
I am really scratching my head over this matter. hope someone have some ideas.
0 Kudos
Message 5 of 8
(3,533 Views)
As far as the f(x) being constant, that does not matter. The integration scheme is a point-wise numerical scheme, it should integrate you data just fine.

The baseline not being 0 is another matter. I would suggest adding another horizontal cursor that you can place at the baseline, or you could take the average value that does not include the the 2 "blips" for a baseline (the 1st way is easier). You will have to correct for this non-zero baseline in the result of the integral.

I have modified and addached the integral vi I made before to do this. If this is still not right you can e-mail me at gtg650n@mail.gatech.edu
0 Kudos
Message 6 of 8
(3,533 Views)
Hi!

I haven't tried your latest example yet but I have integrated your previous integration.vi into my VI. I have attached the modified VI in this email for your reference.

I noticed that whenever I start to take values from the cursors (at the end of the acquisition) I get NaN for both integral values. What have I done wrong? Perhaps you can comment.

thank you
0 Kudos
Message 7 of 8
(3,533 Views)
Hi,

I have opened and played around with your updated integration example. I noticed an introduction of a new function called the ramp pattern.I also noticed that the values from that ramp (baseline) is taken into account for the integral. Can I also apply the same principle in my designs as my waveform is different from the example you are giving. I am still not having any luck with the earlier VI that I have attached. It is still showing NaN values. It will show a certain fixed value when i load up the vi but once the acquisition is complete and I move the cursors, the value remains at NaN. I noticed that the values became zero after passing through the 1st array subset. Please advice. Thank you!
0 Kudos
Message 8 of 8
(3,533 Views)