LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

compare waveform with array

I have a waveform and I want to compare it with an array. I cannot make it work. Please help!

Attached is the program

0 Kudos
Message 1 of 15
(3,910 Views)

How is it not working?  I don't see where you are even attempting a comparison.

0 Kudos
Message 2 of 15
(3,896 Views)

You have two for loops in your program.

 

The one on top builds your array.

 

The one on bottom accepts that array, auto-indexed, and the mean from your incoming data.  Then it compares every value in the array against the mean.  If it's successful, the LED would only light up for 100ms.

 

What are you actually trying to do?  I can't imagine that's your desired intent.

0 Kudos
Message 3 of 15
(3,870 Views)

@natasftw wrote:

You have two for loops in your program.

 

The one on top builds your array.

 

The one on bottom accepts that array, auto-indexed, and the mean from your incoming data.  Then it compares every value in the array against the mean.  If it's successful, the LED would only light up for 100ms.

 

What are you actually trying to do?  I can't imagine that's your desired intent.


Hi natasfw!

 

But it doesnt work. The LED does not not light up.

 

What I want is to make the LED light up at intervals my array has set.

 

0 Kudos
Message 4 of 15
(3,847 Views)

If you want to light up the LED at intervals, why are you comparing it to the mean of the waveform?  The mean isn't going to change.  It's calculated once, as an input, to the for loop.  That single value is compared against each individual value in the array.  If the values in the array aren't exactly equal, the boolean shouldn't light up.

 

Drop a probe on the two wires inside the bottom for loop.  I'd be willing to wager they're never equal.

0 Kudos
Message 5 of 15
(3,841 Views)
0 Kudos
Message 6 of 15
(3,838 Views)

@natasftw wrote:

If you want to light up the LED at intervals, why are you comparing it to the mean of the waveform?  The mean isn't going to change.  It's calculated once, as an input, to the for loop.  That single value is compared against each individual value in the array.  If the values in the array aren't exactly equal, the boolean shouldn't light up.

 

Drop a probe on the two wires inside the bottom for loop.  I'd be willing to wager they're never equal.


hi natasftw!

 

My intention is this. I have an analog signal coming in which measures the distance. So the mean of the simulated sine signal should be comparable to this data.

Then I will set a spacing which will tell me when to light up my LED.

 

 

0 Kudos
Message 7 of 15
(3,837 Views)

@Munna232 wrote:

Don't Compare Floating point Numbers directly.

 

Check this.. you will get some idea.

 

http://www.ni.com/white-paper/7612/en/

http://digital.ni.com/public.nsf/allkb/B01682241DD825948625665100663F61

http://digital.ni.com/public.nsf/allkb/49D72E8658F6AEE48625758A00710BB4


Thank you Munna232!

 

Yes i realized that and I changed it. I got a good reference VI from here .

 

 

0 Kudos
Message 8 of 15
(3,831 Views)

If you're looking to debug, any constant would suffice for simulating a measurement.  Why go to such lengths to create a constant when numeric constant already exists?

 

And yes, you don't want to compare floating point exactly.  Even before we worry about that, though, it doesn't seem you understand the rest of what is happening with that loop.  If you haven't already made changes to handle float comparisons, you might consider using integer types to understand the comparisons using a simple numeric constant.  From there, it'll be easier to expand to float logic.  From there, you can modify your constant input to be your actual measurements.

0 Kudos
Message 9 of 15
(3,821 Views)

@natasftw wrote:

If you're looking to debug, any constant would suffice for simulating a measurement.  Why go to such lengths to create a constant when numeric constant already exists?

 

And yes, you don't want to compare floating point exactly.  Even before we worry about that, though, it doesn't seem you understand the rest of what is happening with that loop.  If you haven't already made changes to handle float comparisons, you might consider using integer types to understand the comparisons using a simple numeric constant.  From there, it'll be easier to expand to float logic.  From there, you can modify your constant input to be your actual measurements.


Hi natasftw!

 

This is the main program i created and I am looking for solutions to make that interval work.

 

0 Kudos
Message 10 of 15
(3,813 Views)