LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

pulse counter Square wave

Hi All

 

Ive got a square wave ive captured from a sensor see attached VI. The square was is 5Hz for 4 seconds so should have 40 transitions or 20 cycles. I want to count the transitoins from the captured data. I cannot seem to figure out how to do this. The transition VI doesnt seem to work. Reason i want to count the transitions is because sometimes it may only have less than 40 transitions and i want to flag up if the transitions do not equal 40.

 

Any help on this would be great as im scratching my head. 

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

Hi JWinstanley,

 

I have had a look at your code, and believe that the issue is that the Peak Detection function seems to be detecting every peak of every bit of noise. If you use the graph palette to zoom right in on one of the high ledges on Waveform Graph Output, you will see how noisy it is. Also, you are only counting the number of peaks, which would in essence be every time the signal went "high", but not every single transition, if this makes sense.

 

I have adaptded your code a bit - used the amplitudes of each of the peak found (output from the Peak Detection function) found the difference between adjacent amplitudes, and also found the difference between maximum and minimum amplitude. I have put in some code to say if the difference is greater than 95% of the max-min difference, add that value to an array to be counted.

 

This means that the only changes in peak values that will be counted, are those that are over 95% of the total peak-peak change.

 

I understand that this is a bit long winded, but as it is a "post processing" piece of code, I am hoping this is not an issue.

 

I think that this is a reasonable work-around for you, and I believe that the reason your original code did not work as expected is to do with the "half-width" used in the Filter subVI and the width input to the Peak Detection function.

 

Hope this helps you on your way,

Amy

Amy K
Applications Engineer
National Instruments UK & Ireland
Message 2 of 7
(4,009 Views)

unable to open abouve vi can anyone please convert it into labview 2012?

please

0 Kudos
Message 3 of 7
(3,682 Views)

please

0 Kudos
Message 4 of 7
(3,644 Views)

Hi

 

This should now be saved for LV2012

I hope it works for you, let me know if it does not! 

 

Cheers!

 

 

Message 5 of 7
(3,634 Views)

HI CPT-NI,

 

THANK YOU SO MUCH...!!!!

0 Kudos
Message 6 of 7
(3,623 Views)

Got it! thanks!

0 Kudos
Message 7 of 7
(3,618 Views)