LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Boolean comparison of analog wave form output

Solved!
Go to solution
Highlighted

Hi all,

 

What I am trying to do is compare the output of a waveform from the wave generator to a certain value to trigger some event. However, despite using comparison values that are known to be in the waveform for sure, the boolean comparison never yields true. I am guessing it has something to do with the signal generation speed and the boolean not seeing every value output in the signal.

 

Do you all know of the correct or better way to accomplish this task?

 

Thanks

0 Kudos
Message 1 of 7
(1,257 Views)

Without seeing your code it is hard to say for sure, but I suspect that the problem is the issue of equality comparison of floating point numbers. If just one of the 64 bits in the binary representation of a DBL differs from the value being compared, the result is False. 

 

Two options: (1) Use a range of values and the In Range & Coerce function or (2) use Greater Than or Equal along with some logic to locate the first transition in the data set.

 

Lynn

0 Kudos
Message 2 of 7
(1,250 Views)

Thanks Lynn,

I see what you're saying. The dynamic signal from the generator had already been converted to a double, but it may need further manipulation. As for the using the In Range and Greater than or Equal to function, I've tried that and is where I stand right now to get the program working. The only problem with that is when you adjust frequnecy or amplitude you also have to adjust the thresholds for the those two functions accordingly. This is because at different wave parameters the outputs also change somewhat. 

Could the comparison possibly not work because of sampling rate? (1000 samples/sec, for 100 samples in the wave generator).

0 Kudos
Message 3 of 7
(1,236 Views)

No. The sampling rate has nothing to do with the comparison. Please post your VI with typicla values for the data saved as default. That way we can see what you are doing and provide suggestions to resolve the issue.

 

Lynn

0 Kudos
Message 4 of 7
(1,223 Views)

Sorry about that, 

The original VI is not with me at the moment. However, I am attaching a simple VI that represents the corresponding part in the main VI. This should contain the scope of the problem.

0 Kudos
Message 5 of 7
(1,221 Views)
Solution
Accepted by topic author msia15

The evil Dynamic Data Type (DDT) strikes again! The output of the Express VI which generates the simulated signal is Dynamic Data Type. This obscures the structure of the underlying data. The conversion you chose was to a single scalar. The simulated signal contains 100 samples. Which one does the conversion select? The first, I think, or maybe, the last. It does not tell you. But what are the chances that the one of one hundred which you compare was actually the one you wanted? You really want to compare all of them.

 

Rather than use the Express VI with all its problems, I prefer to use something like Basic Function Generator.vi from the Signal Processing >> Waveform Generation palette. Its output is the Waveform data type, which is a cluster of an array of doubles Y, dt = the sampling interval, and t0 = the start time. 

 

I extract the array of samples and compare all of them to zero. Then search the boolean array for a True value. 

 

Comparison.png

 

Note also that for non-integer values of frequency the minimum value in the Y array may not be zero even though the amplitude and offset are the same.

 

Lynn

0 Kudos
Message 6 of 7
(1,213 Views)

Thanks for your example, johnsold. It was a good base to solve this task from.

0 Kudos
Message 7 of 7
(1,201 Views)