LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Extracting a particular sample and then subtracting from previous sample

Hi all,
        I ve got a small problem.I want to multiply 2 signals in the following manner:
 
Calculate the difference in amplitude(Y value) between 2 adjacent samples ie 0 and 1 and so on 
 
The Signal is being acquired real time, so I should be able to multiply the differences for all the samples.like difference  between 0 and 1 and then 1 and 2
 
The difference should be calculated only for the positive slope of the signal ie if the 2 nd samples y value is greater than that of the first then the difference should be calculated.Negative slope should be ignored and the multiplied sine wave should be displayed in a waveform chart.
 
I ve been trying this but I am unable to do it.This is kinda urgent,so any help would be appreciated.
 
I have no problem with the acquisition part.Only the getting the exact sample i want and calculating the difference.
 
I have attached my VI file.I am acquring 2 signals.I need to calculate the difference between the samples as I had described above for both the signals and then display each of the calculated signal.The calculated signal wont be continuous.
 
Thanks
 
0 Kudos
Message 1 of 17
(3,653 Views)
Problem Description(revised):Sorry abt the last one
 
Calculate the difference in amplitude(Y value) between 2 adjacent samples ie 0 and 1 and so on 
 
The Signal is being acquired real time, so I should be able to multiply the differences for all the samples.like difference  between Samples 0 and 1 and then Samples 1 and 2
 
The difference should be calculated only for the positive slope of the signal ie if the 2 nd samples y value is greater than that of the first then the difference should be calculated.Negative slope should be ignored and diferences should be displayed in a waveform chart.
 
I ve been trying this but I am unable to do it.This is kinda urgent,so any help would be appreciated.
 
I have no problem with the acquisition part.Only the getting the exact sample i want and calculating the difference.
 
I have attached my VI file.I am acquring 2 signals.I need to calculate the difference between the samples as I had described above for both the signals and then display each of the calculated signal.The calculated signal wont be continuous
0 Kudos
Message 2 of 17
(3,645 Views)
Duplicate post, refer to:
 
~~~~~~~~~~~~~~~~~~~~~~~~~~
"It’s the questions that drive us.”
~~~~~~~~~~~~~~~~~~~~~~~~~~
0 Kudos
Message 3 of 17
(3,630 Views)
Yeah I am the same guy...I tried to explain the problem more clearly and I have attached the VI I used
0 Kudos
Message 4 of 17
(3,626 Views)
Hi f1racer_82,
 
From reading your description of what you want to do, it looks to me like the part you are missing is getting the waveform components.  Waveforms (like the ones output by the AI Sample Channels VI) are composed of 3 items:
 
1. The initial time (t0)
2. The change in time between samples (dt)
3. An array of the actual values.
 
You can use the Get Waveform Components VI to unbundle a waveform and access each of these elements independently.  Once you are able to this, it seems to me like you will simply need to index the array of values and perform the subtractions you described.
 
I hope this helps!
Megan B.
National Instruments
0 Kudos
Message 5 of 17
(3,610 Views)
Hi Megan,
               Thanks a lot for your help.I will try it and let you know.
0 Kudos
Message 6 of 17
(3,598 Views)

Hi,

     I am able to get the Y values in an 1-D array but how do I subtract the second Y value I get from the first value?The values are on the same index 0.

0 Kudos
Message 7 of 17
(3,592 Views)
Take a look at the Value has changed ptbyt.vi. Maybe you could modify this vi to give you the sign of the slope and the difference betwen the two points.
0 Kudos
Message 8 of 17
(3,588 Views)

HI unclebump,

 Can you please tell me give me the link for ptbyt.vi?I tried searching the forums but cudnt find it.

Thanks

 

0 Kudos
Message 9 of 17
(3,575 Views)
Hi,
    I found that link but my version 7.0 doesnt have that.
 
Thanks
0 Kudos
Message 10 of 17
(3,574 Views)