LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Count number of times an analog input happens?

Hi.

 

I have some sensors that are returning 5v to my daq in a momentary switch format.  It will be a quick 'blip' of 5v and then return to 0v.

 

How can I programmatically count the number of times that analog input (SCXI-1102, for discussion purposes) 'sees' 5v?

 

I started playing with Advanced Threshold Peak Detector in this simple VI attached, but it doesn't 'count' in that it does indeed increment the display, but the display begins to count back down when you stop crossing the 4 threshold.

 

I've been away from Labview and in PLC's for a couple of years.  Is this the best scheme to count these pulses or should I be thinking of using another method, structure, or trigger?

 

Thanks so much.

___________________________________________________________________
Still confused after 8 years.
0 Kudos
Message 1 of 19
(3,828 Views)

You might want to consider just doing your own comparison.  If the value is greater than 4V AND the previous value was less than 4V, increment.count.png


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 19
(3,819 Views)

That's an interesting solution.

 

I'm searching examples for anything that looks remotely like this, with no luck.

 

Question...  If you wanted to have the option to reset that example you just posted, what would you do?  Like an option for pause and/or reset, while the main program is running?

___________________________________________________________________
Still confused after 8 years.
0 Kudos
Message 3 of 19
(3,815 Views)

Ralph@NES wrote:


 

I started playing with Advanced Threshold Peak Detector in this simple VI attached, but it doesn't 'count' in that it does indeed increment the display, but the display begins to count back down when you stop crossing the 4 threshold.

 



The function has a default sample lenght input value of 100. As you input data it will count up the peaks until you reach 100 samples, then it will indicate the number of peaks in the last 100 samples. That is why the number of peaks may start to go down. It's probably better not to use this function for continuous incoming data, it's purpose is more to analyze a finite set of data as the output of a spectrum analyzer sweep.

 

Ben64

0 Kudos
Message 4 of 19
(3,807 Views)

Ralph@NES wrote:

Question...  If you wanted to have the option to reset that example you just posted, what would you do?  Like an option for pause and/or reset, while the main program is running?


For a pause, I would add it to the AND logic going into the select.  For the reset, I would add another select - true = 0, false = count value.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 19
(3,797 Views)

Maybe I'm missing something, but when I run that example, if I just leave it set to, say, 4, it will continue to count up.  That's not exactly what I'm going for, I need one increment on the 'leading edge' so to speak of the signal.  So once per pulse.

___________________________________________________________________
Still confused after 8 years.
0 Kudos
Message 6 of 19
(3,778 Views)

Attached my version for comparison

___________________________________________________________________
Still confused after 8 years.
0 Kudos
Message 7 of 19
(3,777 Views)

I found a way to use a feedback node to give an instantaneous 'rising edge' action, and that seems to work.  Both of the booleans before the 'and' seem to go true.

 

The output of the 'and' never goes true, and it never increments, though.  It seems that, upon slowing execution of the loop, that both of the inputs are not true at the same time, one goes after the other.

 

Any way to time that so that they happen simultaneously and perform the increment?

 

Attached the revision.

___________________________________________________________________
Still confused after 8 years.
0 Kudos
Message 8 of 19
(3,774 Views)

Hi Ralph,

 

did you notice the small circle on the 2nd input of the AND in the example in message#2? It has a meaning and it's important for you.

Hint: use RightMouseClick on that input...

 

General hint: when recreating other people's example you should pay attention to every and all items Smiley Wink

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 9 of 19
(3,771 Views)

OK, I inverted that input and it sorta works now.  I say sorta because it's sporadic.  Sometimes it doesn't recognize the click.

___________________________________________________________________
Still confused after 8 years.
0 Kudos
Message 10 of 19
(3,768 Views)