LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Area under curve with cursors doesn't work

I need to integrate the area beneath two uneven curves. One is a maximum and the other is a minimum curve. I have tried several methods but I keep gettting NaN when I adjust the cursors around.
It is also to be noted that my graph readout is slightly below the x-axis (around -0.014 volts units) and I do get some noise. Please refer to the attached files. Any ideas anyone?
Download All
0 Kudos
Message 1 of 9
(3,490 Views)
Hi,

You use autoindexing on the 2d array, when it enters the while loop. This
doesn't seem correct. Try to get signal 1 and signal 2 with the Array Index
function. There is no difference in integrating two signals and then
subtracting the results, and subtracting the signals and then integrate the
result (I think)...

Perhaps the attachment helps.

Regards,

Wiebe.



"jonathanchye" wrote in message
news:5065000000080000008DEC0000-1079395200000@exchange.ni.com...
> I need to integrate the area beneath two uneven curves. One is a
> maximum and the other is a minimum curve. I have tried several methods
> but I keep gettting NaN when I adjust the cursors around.
> It is also to be noted that my graph readout is slightly below the
> x-axis (arou
nd -0.014 volts units) and I do get some noise. Please
> refer to the attached files. Any ideas anyone?



[Attachment Intergrate.vi, see below]
0 Kudos
Message 2 of 9
(3,490 Views)
A few suggestions:
1) I find it easier to use the Index property of the cursor rather than the X.Position for things like this(Cursor must be locked to plot).

2)If your cursors "pass" each other you can get negative length values wired to array subset. I prefer to use max/min on the index pairs to prevent this.

3)You might try using another cursor to remove the bias in the signal, or a statistical approach (Mode comes to mind) to automatically remove it.

I wrote a VI that shows some of these ideas. Please let me know if this helps.
0 Kudos
Message 3 of 9
(3,490 Views)
Hi!

I can't open your file because I am using LAbView 7.0. Sorry I didn't meantion it earlier! 🙂
0 Kudos
Message 4 of 9
(3,490 Views)
Hi,

I have modified my VI but I am afraid I am still getting NaN. I tried changing the constant value for the first array (please refer to attached word document) to 1 but still I am getting NaN. I am really lost here as logically it should return a value corresponding to the values returned by cursor. I really need some help in this as I am totally lost. Any ideas?
0 Kudos
Message 5 of 9
(3,490 Views)
Hi,

See the attachment. I had to delete a lot, just to get it running.

It seems to me you have a combination of problems (if it was one just
problem, it would have been easy).

1) the indexing in the while loop. Note that the constant in the indexing
can be wired to the first entry (row) to get an entire row, or to the second
to get an entire colomn.

2) The time is mixed up. The contant outside the structure (x = 1000) is
multiplied by 1000 in the chart. But when the cursor is used, this factor is
not considered. For that reason, the indexes are not correct. Try to put
some probes on what you put in the index and length. If they don't match,
you'll not get any results.

I got it working, but I don't know if the timing is correct. At l
east you
should be able to get on with it... You could use the sine wave to verify
the result.

Regards,

Wiebe.



"jonathanchye" wrote in message
news:506500000005000000B7B90100-1079395200000@exchange.ni.com...
> Hi,
>
> I have modified my VI but I am afraid I am still getting NaN. I tried
> changing the constant value for the first array (please refer to
> attached word document) to 1 but still I am getting NaN. I am really
> lost here as logically it should return a value corresponding to the
> values returned by cursor. I really need some help in this as I am
> totally lost. Any ideas?



[Attachment integrate_with_cursor.vi, see below]
0 Kudos
Message 6 of 9
(3,490 Views)
Hi,

Thanks for your reply. I will try it out soon. I don't understand what you said with the time factor. I just need to convert the time units back from milliseconds to seconds to get an appropriate area readings. As far as I understand, the integral of the area under the curve will give the area under curve.

I will post my latest findings after I run the test. Thanks!
0 Kudos
Message 7 of 9
(3,490 Views)
Hi,

I have applied your suggestion and integrated it into my VI. I finally got a live reading for the first integral output. However, the second one always shows zero now instead of NaN. I have checked the connections and they seem to be ok. However, I have merged the input signal for dT with the scaling factor for the timebase that you have suggested. Please check the attached VI to see if this is affecting the output for the 2nd integral readings. Thank you!!
Download All
0 Kudos
Message 8 of 9
(3,490 Views)
Hi,

Perhaps I screwed up the timing myself. Anyway, make sure it's correct by
using probes. Especially the array used to calculate the integral is easy to
probe (if it's empty, somethings wrong).

Regards,

Wiebe.

"jonathanchye" wrote in message
news:506500000005000000C4B90100-1079395200000@exchange.ni.com...
> Hi,
>
> Thanks for your reply. I will try it out soon. I don't understand what
> you said with the time factor. I just need to convert the time units
> back from milliseconds to seconds to get an appropriate area readings.
> As far as I understand, the integral of the area under the curve will
> give the area under curve.
>
> I will post my latest findings after I run the test. Thanks!
0 Kudos
Message 9 of 9
(3,490 Views)