annuler
Affichage des résultats de 
Rechercher plutôt 
Vouliez-vous dire : 

Turning on LEDs for period of time

Résolu !
Accéder à la 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 Compliments
Message 1 sur 11
4 867 Visites

What hardware are you using...

0 Compliments
Message 2 sur 11
4 864 Visites

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

0 Compliments
Message 3 sur 11
4 860 Visites
Solution
Accepté par l'auteur du sujet 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 sur 11
4 857 Visites

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 Compliments
Message 5 sur 11
4 849 Visites

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 Compliments
Message 6 sur 11
4 843 Visites

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 Compliments
Message 7 sur 11
4 838 Visites

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 Compliments
Message 8 sur 11
4 836 Visites

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 Compliments
Message 9 sur 11
4 834 Visites

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 Compliments
Message 10 sur 11
4 827 Visites