LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I integrate a signal using labview?

I am trying to integrate a signal using labview, and it does not do what I want it to do.  I find the peak, then use the location of the peak to find t1 and t2, then integrate over that interval.  It integrates when I do not add my desired equation, but when I do it always outputs zero.  Attatched is my VI, below is my desired integral equation.

 

[1/(t2-t1)*integrated signal]^(2.5)*(t2-t1)

0 Kudos
Message 1 of 9
(9,999 Views)

Howdy jjacobs,

 

I took a look at your code and since I don't have your equipment, I couldn't replicated the functionality.  However, I'm curious how the code does not perform as you'd like it to.  Here are some questions to help narrow this down:

  1. Does the VI acquire the data correctly?
  2. Are you able to find the peak correctly?
  3. Can you use a known simulation signal to run your integration to see if it works properly?
  4. Have you considered using the MathScript node to perform the integration?  Can you test this? 

Also, I'm not quite sure of what you mean when you say "It integrates when I do not add my desired equation, but when I do it always outputs zero."  An example of using the integration VI can be found in the Program Files\labview\examples\analysis\statxmpl.llb folder.  Thanks, I look forward to hearing back from you!

Sincerely,

Chris G in AE
0 Kudos
Message 2 of 9
(9,947 Views)

Hi Chris,

1.The VI does acquire data the right way.  

2. The peak detection works erratically.  When the peaks are sufficiently larger than my threshold, it starts to integrate.  If it were a small peak, it would pass through my vi without being detected

3. I have used a sinusoid wave to test my integral, and it reutrned zero, which is what I expected.  Based on this, I believe it is working correctly.

4.  I have tried mathscript, but not integrating within mathscript.  What I have been doing is integrating the signal with integral x(t), then passing it to mathscript.  The output of that mathscript with this equation :

I=(A^2.5);

where A is the input, and I is the output.  This always gives me zero.  That is what I meant by the desired equation thing.

 

Thanks!

0 Kudos
Message 3 of 9
(9,920 Views)

Hey JJ,

 

Thanks for the response!  From your answers, it seems your problem is in the MathScript node since your signal is integrating properly.  Have you considered replacing the node with the Power of X VI located in the Mathematics » Elementary and Special Functions »  Exponential Functions palette?  This will allow you to feed your integrated array directly into the VI and raise each element to a power of 2.5.  It seems like this is what you are trying to do with the MathScript node from looking at your code.  Please post back with the results.  Thanks!

 

 

Message Edited by Chris G in AE on 04-16-2009 12:12 PM
Sincerely,

Chris G in AE
0 Kudos
Message 4 of 9
(9,895 Views)

Hello Guys,

 

I'm simply trying to integrate peaks.  I opened the Quadrature Integrand.vi with your instructions.  The first VI is labeled "data" in the block diagram.  How do you connect data from an X, Y graph to this VI?  I tried using an example block diagram where I was able to get a signal but the wire connecting did not talk to "data" VI (.NET Refnum issue).  My end goal is to be able to integrate the area of a peak- X axis time Y-axis amplitude.  Thank you for all your help.

 

Blessings,

Phil 

0 Kudos
Message 5 of 9
(8,543 Views)

You could always use the Trapezoid Rule to approximate the integral.  I assume you have an array of data, you know where the peak is, and you know the lower and upper limits (of X) over which you want to integrate.  Now all you need is the sampling interval, dt ("delta-t").  Simply add the Y values from the lower to the upper limit, multiply by dt, and there's your integral!  Note that LabVIEW can return you an array subset (one function), can sum the (sub-)array (one function), and can divide by dt, so with three LabVIEW functions, the Y values, the lower and upper limit, and dt, you have your integral.

 

BS

0 Kudos
Message 6 of 9
(8,527 Views)

Hello Bob,

 

Thank you for the information about integration!  I was looking to see if there was a to select a peak for automatic integration, but it looks as though using these 3 functions may be the way to go.  I'm actually still trying to output an X, Y graph from the LabView 2014 example-"ULx Cont Acq&Chart Samples-SW Timed.vi".  Wire connections are fine, just not getting a signal.  It allows me to output the signal as Wavegraph but having difficulty displaying the changes in the analog signal with the X, Y graph which I assumed was needed to have an accurate baseline for integration (may be wrong).  Is it even possible to output an X, Y graph using this example?

0 Kudos
Message 7 of 9
(8,522 Views)
The xy graph of just a display and does nothing for an accurate baseline. Your acquisition type of SW Timed means the time between samples is subject to jitter. Use a hardware timed acquisition for an accurate dt. This would be displayed in a normal graph.
0 Kudos
Message 8 of 9
(8,506 Views)

Thank you Dennis!  That was quite helpful and so is this youtube for constructing "while" and "for" loops.  https://www.youtube.com/watch?v=GBhJk5Tnshc

I'll post later when I have played around with these suggestions.

 

Blessings,

Phil

0 Kudos
Message 9 of 9
(8,478 Views)