LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Waveform Rectifier or Thresholding to Form Squarewaves

Solved!
Go to solution

Hi all,
I just started using Labview so please bear with me.
I want to convert an waveform generated from an analog input into an equivalent digital/square waveform with only two Y values by setting a threshold value. I was trying to index through the original waveform's array of Y values and check that value against the set threshold value. If the value is less than the threshold value then change the value to constant 0 otherwise change the value to a constant.

 

I have been having trouble generating the square waveform that I was looking for.

I'm not sure what loops to use (while, for, or nested). I have a while loop set up since I am expecting a continuous stream of analog input data to be converted. 

Is there a similar vi out there that I could refer to?

 

Thanks! 

0 Kudos
Message 1 of 4
(2,336 Views)
Solution
Accepted by topic author Ghoster

It would be done something like this:

 

Example.png

Tim
GHSP
Message 2 of 4
(2,332 Views)

Thanks so much for you fast reply! 
This helped a lot. I just have one more quick question: 
Instead of the sine pattern generator, I used the DAQ Assistant. 
I attached an image of the result I got when I set the threshold value to 5V.  
The problem with the results was that the resulting square waveform took a bit of time to switch to 1 or 0. (was not a perfect square)
Is there something I'm missing to fix this problem? 

0 Kudos
Message 3 of 4
(2,324 Views)

It might have something to do with how many samples that you are sending to the loop for the threshold measurement. If you are doing some sort of averageing then that could also be part of the problem. I would have to have some data to run with the code to better help out.

Tim
GHSP
0 Kudos
Message 4 of 4
(2,318 Views)