LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Turning on LEDs for period of time

Solved!
Go to solution

Hello,

 

I am trying to write a code that will turn on a LED if a condition is met for 5 seconds.  Let's say I'm evaluating the slope of a curve.  If the slope of the curve remains greater than or equal to 1 for 5 seconds, then the LED should turn on.  I was initially thinking that I could use a tick count or the elapsed time express VI, where if my slope became greater than 1, then the timer would start.  If the slope fell below 1 before the 5 second mark was met, then the timer would be reset back to 0 and start up the next time the slope became greater than 1.  Please Help!!!

 

Thanks! 

0 Kudos
Message 1 of 11
(3,729 Views)

What hardware are you using...

0 Kudos
Message 2 of 11
(3,726 Views)

No hardware yet.  The LEDs are located on the Front Panel.  I am using Labview 2012.

0 Kudos
Message 3 of 11
(3,722 Views)
Solution
Accepted by topic author foolysubmerged

@foolysubmerged wrote:

Hello,

 

I am trying to write a code that will turn on a LED if a condition is met for 5 seconds.  Let's say I'm evaluating the slope of a curve.  If the slope of the curve remains greater than or equal to 1 for 5 seconds, then the LED should turn on.  I was initially thinking that I could use a tick count or the elapsed time express VI, where if my slope became greater than 1, then the timer would start.  If the slope fell below 1 before the 5 second mark was met, then the timer would be reset back to 0 and start up the next time the slope became greater than 1.  Please Help!!!

 

Thanks! 


Using the elapsed timer express VI is a good solution. Use the reset input whenever the slope falls out of spec.

Message 4 of 11
(3,719 Views)

Hey BillMe,

 

I did attempt to use the Elapsed Time VI to do this however when I did try it, the timer never actually reset.  When I run my code, I can start the timer by making the slope of my curve to become greater than 1.  And if I keep the slope greater than 1 for 5 seconds, an LED that is connected to the "Time has Elasped" terminal of the Elapsed Time VI will turn on.  However, if I start my program and make the slope go greater than 1 for 2 seconds and then allow it to fall back below 1, then the Elapsed Time VI should reset.  But during this scenario, it starts the timer and then if the slope increases past 1 again at a later time, it starts the timer at a much later time than at zero.  It seems as if the timer never really stopped.

 

Thanks for the response! 

0 Kudos
Message 5 of 11
(3,711 Views)

You need to hold the reset true while the slope is less than 1, release it when it is greater than one. When you release it, the timer will start from 5 seconds again and start counting down. Is that what you want?

 

Can you post your code?

0 Kudos
Message 6 of 11
(3,705 Views)

BillMe,

 

I have attached a picture of my program below.  The problem I am having now, is that the program says the target time has been reached when it clearly has not.  I have the target time set to 5 seconds, however it only reaches 3.4 seconds before it says that the time has been reached.  Any suggestions???

DetectionAnalysis.jpg

0 Kudos
Message 7 of 11
(3,700 Views)

Hey,

 

It looks like I did get it working with the Elapsed Time VI.  I don't know what I was doing wrong earlier.  Probably had something to do with my ignorance =P.  Thanks for the Help!!!

0 Kudos
Message 8 of 11
(3,698 Views)

Ok, so first of all, how can you do a curve fit and then start a timer based on all the data points all at once? There has to be some time interval between points so the timer has a chance to reset and count down. What was the time period over which your data was acquired? I'm assuming it was many seconds. So you need a loop that iterates at that same sample rate.

 

Also, don't wire the "Set Start Time", that's not needed. You only need to toggle the RESET for your two cases of slope.

 

Is this the actual VI or is there stuff missing?

0 Kudos
Message 9 of 11
(3,696 Views)

BillMe,

 

I output the slope from the curve fit.  This value updates with each iteration of a loop.  So whenever that slope becomes less than my constraint slope, the timer is reset.  I have allowed an accumulation of 20 data points for which I perform the initial linear fit on.  So it gets the slope of the initial fit and then performs a new fit for every new data point that is recorded.

0 Kudos
Message 10 of 11
(3,689 Views)