LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a simple way to build a blink detector VI?

Hi, all,

I'm trying to implement a VI that detects that a boolean input  is changing state at least twice within one second. (If the input represents nonzero current through a LED, the output should be true when the LED is blinking.)

This VI will be used as a sub-VI of other VI's, so it can't contain infinite loops. (I have a design working that uses an infinite WHILE loop and "Delay Values" Express VIs, but it blocks when called as a sub-VI, so I can't use it. See attachment.)

I've tried using collectors and delays, but am having a hard time with complaints about dt being negative, different, etc. when I try to wire delayed signals into comparators.

Does anyone here have an idea for a simple design that will do what's needed?

Thanks,
- Steve.

0 Kudos
Message 1 of 16
(3,449 Views)
A VI can be an infinite loop and still be used as a subVI without blocking the parent VI if it's used properly. For instance, you would have it in a loop that runs parallel to the rest of your code. An alternative is to launch this VI dynamically. Then, it would just sit on the side while your main VI chugs along happily. You would need to pass in a control reference so this monitoring VI knows which control to monitor.

I don't have time right now to look at your VI in detail but at first glance it seems a bit more complicated than it needs to be just to see if something is blinking at least twice a second.
0 Kudos
Message 2 of 16
(3,433 Views)
here is an example.
________________________________________________________

Use the rating system, otherwise its useless; and please don't forget to tip your waiters!
using LV 2010 SP 1, Windows 7
________________________________________________________
0 Kudos
Message 3 of 16
(3,431 Views)
Here is a better version that actually is in subvi form...
Input a boolean value, and monitor the output...simple enough...
 
________________________________________________________

Use the rating system, otherwise its useless; and please don't forget to tip your waiters!
using LV 2010 SP 1, Windows 7
________________________________________________________
0 Kudos
Message 4 of 16
(3,417 Views)
Here's the vi I used to test it...just in case you needed it...
________________________________________________________

Use the rating system, otherwise its useless; and please don't forget to tip your waiters!
using LV 2010 SP 1, Windows 7
________________________________________________________
0 Kudos
Message 5 of 16
(3,415 Views)
Thanks -- I'm trying to learn this stuff in a hurry and I don't think I have the execution model locked down. Much better solution.

- Steve.

0 Kudos
Message 6 of 16
(3,403 Views)
P.S. I tried to put a manual switch in place of the generated signal, and it doesn't seem to work reliably -- I can toggle the heck out of the switch, and the blinking indicator only occasionally goes on. Could this be some subtle difference in when things run? (It seems that way.)

Thanks,
- Steve.
0 Kudos
Message 7 of 16
(3,382 Views)
I checked it out. At first I was noticing what you were (when no delay is used)... however I put a custom probe on there with pause if true condition on the output boolean and saw that it was working just fine. Basically if you have no pause in there the boolean was switching on then off again so fast that you couldn't see it. If you slow the loop down you can notice it better....but it's working...
________________________________________________________

Use the rating system, otherwise its useless; and please don't forget to tip your waiters!
using LV 2010 SP 1, Windows 7
________________________________________________________
0 Kudos
Message 8 of 16
(3,364 Views)
Again, thanks for all your help, TW. There must be something I'm still not understanding here, though -- I'd expect that the LED would stay on for at least half a second. -S.
0 Kudos
Message 9 of 16
(3,351 Views)
As it is written the vi's output indicator will output a new value anytime the vi is called (based on the conditions of the boolean passed to it).
________________________________________________________

Use the rating system, otherwise its useless; and please don't forget to tip your waiters!
using LV 2010 SP 1, Windows 7
________________________________________________________
0 Kudos
Message 10 of 16
(3,345 Views)