10-12-2014 10:34 AM
I have a waveform and I want to compare it with an array. I cannot make it work. Please help!
Attached is the program
10-12-2014 11:28 AM
How is it not working? I don't see where you are even attempting a comparison.
10-12-2014 03:12 PM
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.
10-12-2014 07:50 PM
@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.
10-12-2014 08:02 PM
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.
10-12-2014 08:09 PM
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
10-12-2014 08:11 PM
@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.
10-12-2014 08:14 PM
@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 .
10-12-2014 08:30 PM
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.
10-12-2014 08:37 PM
@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.