05-24-2012 03:36 PM
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.
05-24-2012 04:01 PM
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.
05-24-2012 04:06 PM - edited 05-24-2012 04:07 PM
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?
05-24-2012 04:20 PM
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
05-24-2012 06:09 PM
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.
05-25-2012 06:22 AM
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.
05-25-2012 06:23 AM
Attached my version for comparison
05-25-2012 07:23 AM - edited 05-25-2012 07:31 AM
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.
05-25-2012 07:30 AM - edited 05-25-2012 07:31 AM
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
05-25-2012 07:37 AM
OK, I inverted that input and it sorta works now. I say sorta because it's sporadic. Sometimes it doesn't recognize the click.