LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

waveform comparison

Hi...I was hoping someone can take a look at my code and see what mistake I am making.  I am trying to make a waveform comparion between two waveforms.  I thought I have it setup correctly but I keep getting a true when I expect a false.  I bring in four waveforms that has been indexed together.  I split them using a index array.  I make the comparison and then either continue my loop or end it if is true.  I know it should be false since I am watching my scope..but it always returns true.  Do I have a mistake somewhere?

 

Chad

0 Kudos
Message 1 of 11
(3,359 Views)

 


@Chad_UofR wrote:

...or end it if is true....


If what is true? If the waveform is within range of the other? If so, then you want to change the operation of In Range to "Compare Aggregates" (right-click on it). Then you don't need the Invert or the Or Array Elements (which were both wrong in the first place anyway, since you'd want just And Array Elements to see if all elements are True).

 

Also, you do not need to wire values to the Index Array if the indices you want are sequential. Please read the LabVIEW Help on the Index Array function.

0 Kudos
Message 2 of 11
(3,339 Views)

Ok...I think I am close to understanding.  I assume the index array splits my 8x2000 array into a 2x2000 array since my time scale is 2000 points and x(1) and y(2).  So a column for x and then for y.  I want to only compare the first two channels.  So I have one element as my trigger (channel 1).  Then my second element (channel 2).  I then multiply channel 2 by and upper and lower bound.  I then input this into the range and coerce function.  If waveform 2 (channel 2) is within 25% of waveform 1 (channel 1) then give True.  If not give False.  Is this correct?

 

 

0 Kudos
Message 3 of 11
(3,331 Views)

Index Array knows nothing about timescales. For a 1D array Index Array will retun a single element of the same datatype as the array datatype. For a 2D array Index Array will return a row or column. You don't have an 8x2000 array (a 2D array). You have a 1D array of waveforms and are pulling off the first and second waveforms. Thus your "element" in this case is a single waveform, not another array.

 

In your case the output of the In Range And Coerce function can be either an array of Booleans or a single Boolean, depending on the comparison mode. Your basic problem was Boolean logic. To see if waveform2 is in range then you want to AND all of the array elements to yield a true/false. Alternatively, as I indicated you can set the comparison mode to compare aggregates and get a single Boolean true/false directly. Inverting and using Or Array Elements is not the same thing. It's not even correct.

0 Kudos
Message 4 of 11
(3,323 Views)

Okay I understand the "Compare Aggregates" to give a single boolean.  Ans this will work.  However, in testing I am still not getting a True when I give two waveforms that are close.  When it pulls waveform 1 and 2 it is a 1D array of waveforms.  How do I extract the y values of that waveform.  Is what I have wrong? 

0 Kudos
Message 5 of 11
(3,317 Views)

I am pretty sure my problem is what is going on with "get waveform components".  Is using the y-values wronf for this?  I cannot think of anything else that causing my problem.

0 Kudos
Message 6 of 11
(3,310 Views)

You're doing the opposite of what you were doing before and what you said you wanted to compare. You said you wanted to see if waveform 2 was within waveform 1 +/ 25%. Thus you min/max should be based on waveform 1, not waveform 2. Your latest code is doing precisely the opposite. It's checking to see if waveform 1 is within waveform 2 +/- 25%. Not the same thing.

0 Kudos
Message 7 of 11
(3,305 Views)

Actually it is not important which one I use.  I just need to see when they close to one another.  I am triggering of channel 1 and then making a comparison.  I guess my question is what does the "get atrribute y-value" do.  I see that the range and coerce only compare a single point.  I thought it would multiply my entire waveform.  I think it does not.  I am trying max and min values to compare my waveforms.  My waveforms only have one peak.

0 Kudos
Message 8 of 11
(3,300 Views)

 


@Chad_UofR wrote:

I guess my question is what does the "get atrribute y-value" do. 


 

It returns the array of values in the waveform. Did you try the LabVIEW Help?

 

 


I see that the range and coerce only compare a single point.  I thought it would multiply my entire waveform.  I think it does not.

 

It does so. Why would you think it does not? Try it with a simple array of values.

 

 


I am trying max and min values to compare my waveforms.  My waveforms only have one peak.

 

I have no idea what this means. I see no min/max values anywhere in your code.

 

 

See attached example.

0 Kudos
Message 9 of 11
(3,298 Views)

Thank you for the very detailed example.  I am going to use your exact code.  Because when I was doing it the way I posted I would get a saved wavefunction as shown in the file I attached.  Thank you for being patient withb me.  I am very new to labview and I am using both the manual and the forum for help.

0 Kudos
Message 10 of 11
(3,289 Views)