LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

led state detection (OFF, blinking or ON )

Hello,

I have actually a problem for the detection of a led state.

I give you a little draft with some explications:

 

I made a detector with a photosensitive sensor to check the led state. After filtration and labview treatment I have a numeric signal ( 0 if led is OFF and 1 if led is lighting).

LedState.JPG

 

So, when I detect the first time led is ON I save the time of my computer in variable "1".

The next time I detect that led is ON, I save the time of my computer in variable "2" and I rewrite the next time in the same variable until led is ON (not blinking).

So when I detect led is ON (not blinking) I can know how many time I have between the first blinking and led state ON.

 

My probleme is how to detect  if led is blinking or ON ? I can easily explain how to do but not programming my world.

So, if led is blinking it's ON during 0,4s and OFF during 0,4s. If led is ON, it's ON during 0,8s without interuption.

 

Please have you an idea to do that ?

0 Kudos
Message 1 of 7
(6,611 Views)

If you understand what sampling rate means, you will be able to answer your question.

Practically you want to measure how long the LED is ON or OFF. If you have a sampling rate for example like 100 mseconds, you can count how many iterations of your DAQ loop reports ON or OFF state. If the state of the LED changes after 4 counts approximately, it is blinking. If the count is higher, the state is ON or OFF.

 

You should share your code, and the hardware you use for data acquisition. So people can give more precise advise...There are different approaches, depending on whether you use a DAQ device timed from Windows (non real time, so the fastest rate lets say is around 10 msec), or a DAQ HW with internal clock (so you can get faster and more accurate sampling)...

0 Kudos
Message 2 of 7
(6,593 Views)

Thanks for your answer. I think about the same thing as you but the problem is i need to create an array and I am not sure than I can chek this array at the same time is building.

For each led I want to create 3 "state" booleans (ON, blinking and OFF).

 

I will make this operation and give you result.

In the meantime I give you my .vi for leds detection (there is 4 leds):

Led_detection.JPG

I will use the NI 6341.

 

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

From your description, the width of a "blinking" pulse is 0.4 seconds, so the LED blinks at 1.25 Hz.  Let's make the numbers "rounder" and say that the LED blinks at 1 Hz, meaning it is on for half a second, off for half a second, on, off, etc.

 

If you take one sample of the LED, you can tell if it is On, or Off, but not if it is Blinking.  What does it mean "to blink"?  How do you distinguish a "Blink" from a simple "On/Off" transition?  [Hint -- draw a picture of the two events -- what differs?]

 

Now ask yourself, what is the minimum sampling rate that you need (or the maximum time between samples) to insure that you don't miss a Blink?

 

Now you are in a position to solve your problem.  Sample at the "ideal" sampling rate determined in the previous step.  If "this sample = last sample", then you know you are not blinking, so it is On or Off (and how do you know which one?  that should be an easy question).  Otherwise, if this sample <> last sample, it is either a "transition" or possibly a "Blink".  How do you tell?  Well, just as you "remembered" the last sample (do you know how to put "memory" into a While loop?), you can "remember" whether this Sample marks a Transition or not.  If This Sample is a Transition, and Last Sample was a Transition, we are Blinking, otherwise we are not.

 

Now translate all of this into a simple LabVIEW While loop, running at the optimal Sampling Rate.  Take a Sample, compare with last Sample to see if Transition, compare this Transition with last Transition to see if Blinking.  If Blinking, light up Blinking indicator, otherwise light up On or Off indicator.

 

Make things neat.  Keep your wires as straight as possible.  Use the Error Line to sequence operations.

 

Bob Schor

0 Kudos
Message 4 of 7
(6,555 Views)

Thanks for your quick answer.

I will try to translate this in labview.

 

About explanations about blinking or not blinking you can look my first post where I explain the difference between a led ON, OFF or blinking.

0 Kudos
Message 5 of 7
(6,539 Views)

Since a blink is just a short on pulse both a blink and an on will be a blink, but when your desired time lapses a blink is THEN recognized as an on state. You simply need to turn on blink and transition your "datapoint" from blink to on when your time is achieved. If it transitions off before the on time lapses it stays a blink. Then when you turn off you wait for the next on transition start over.

Glad to answer questions. Thanks for any KUDOS or marked solutions 😉
0 Kudos
Message 6 of 7
(6,520 Views)

Be careful -- unless you are a Very Skilled LabVIEW Programmer and can Predict the Future with your code, you can not do what your diagram says.  When the LED goes from Off to Blinking, you cannot know it is in the "Blinking" state or merely the "On" state until it goes off 0.4 seconds later.  Similarly, when it goes from Blinking to On, you can't know that until 0.4 seconds later when it does not go off.  

 

Bob Schor

0 Kudos
Message 7 of 7
(6,503 Views)