LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

led control

Hi, I'm new to LabVIEW and I'm having a little problem with it. I have one LED and four switches. What I need is when I turn on switch 1, the LED light up for 1 second, when I turn on switch 2 the LED light up for 2 seconds, when I turn on switch 3 the LED light up for 3 seconds, and when I turn on switch 4 the LED light up for 4 seconds. Also, the LED should light up for either 1,2,3, or 4 seconds accordingly even if I turned the switch on for more than 4 seconds or off immediately. I used a case structure to do this but I don't know how to make the LED stay on for the appropriate time. I was thinking about use the elapsed time but I don't know how to wire it. Any help would be appreciated and thanks in advance.

 

-Sunny

 

Download All
0 Kudos
Message 1 of 11
(4,550 Views)

Hi,


Check the attached VI.  I think this must be the solution..

 

Regards,

 

Nitzz

(Kudos are always WelcomeSmiley Wink)

0 Kudos
Message 2 of 11
(4,540 Views)

You will need to provide some clarification:

  • Are the switches supposed to be mutually exclusive?
  • You currently have the mechanical action set to "Switch When Pressed". I would think you'd want something that acts more like a pushbutton, i.e., a latching action. If so, does pressing the button again reset the "timer", or is the press ignored?
  • What happens if the user presses the 4-second switch, and then immediately presses the 2-second switch (assuming a latching operation)? Does the LED stay on for 6 seconds? Or, is the press of the 2-second switch to be ignored?

More importantly, what is the purpose of this program? Is this homework? 'Cause it certainly looks like it, as I've seen this question before. And it was homework. Not saying it is. But it certainly looks like it.

0 Kudos
Message 3 of 11
(4,535 Views)

 


@NitzZ wrote:

Hi,


Check the attached VI.  I think this must be the solution..


It would be, if you like forcing a user to wait 4 seconds before they can stop a program. What happens if the time is supposed to be 20 seconds? Do you think someone is going to like sitting there for 20 seconds before a program stops?

 

0 Kudos
Message 4 of 11
(4,533 Views)

 


@NitzZ wrote:
Hi, I'm new to LabVIEW and I'm having a little problem with it.

Try this, but make sure you understand every little bit of it. You are not very clear with the specifications, so modify as needed. 

 


@NitzZ wrote:

Check the attached VI.  I think this must be the solution..


 

What's up with all the value property nodes? Why don't you use local variables instead???

 

Message 5 of 11
(4,530 Views)

Hi,

 

Thank you altenback and smercurio for the review...

 

@altenbach : Actually I was told by me seniors that local variables use more memory than property node value. So I started doing this. If you don't mind, can you tell me what is the difference between both and which is the ideal one..

 

@smercurio : I am sorry, I didn't think about it. Yes you are right about making user wait. That is wrong on my part. Any suggestions?

 

Regards,


Nitzz

0 Kudos
Message 6 of 11
(4,526 Views)

 


Nitzz wrote:

@altenbach : Actually I was told by me seniors that local variables use more memory than property node value. So I started doing this. If you don't mind, can you tell me what is the difference between both and which is the ideal one..


 

Well have your "seniors" read e.g. point number 6 in this post.

 

(Memory is irrelevant for scalars anyway ... )

0 Kudos
Message 7 of 11
(4,523 Views)

@altenbach :  Thank you for the quick reply and the thread link.. I will go through it and get more information about locals and property node values..


Regards,


Nitzz

0 Kudos
Message 8 of 11
(4,519 Views)

Thanks a lot for all the help.

 

The switches are not mutually exclusive. If there's an action going on, then anything pressed before the end of that action should be ignored. So if the LED should light up for 4 seconds, then no matter what happened within those 4 seconds, the LED is always on for 4 seconds and then off, the time does not add up.

 

This is a model I'm going to use for my project. What I'm really doing is using 4 sensors to control 1 motor. So basically depending on which sensor triggered, the motor should run for the time that is set for that sensor (moving an object for certain distance). If another sensor is triggered before the motor stops, that trigger is ignored. I believe this LED example would be very similar to what I need as I'm still waiting for my NI USB-6008 to arrive.

0 Kudos
Message 9 of 11
(4,508 Views)

What you can do is place the code of the button event (except the button terminals) in a case structure so it only executes if the timeout is -1.

 

If the timeout is not -1, keep the LED lit and reduce the timeout value accordingly. You need to keep track of the tick count in a seperate shift register and dynamically recalculate the remaining timeout.

 

Here is an old example (from the end of this old discussion) that could gove you some ideas about that last point.

 

0 Kudos
Message 10 of 11
(4,488 Views)