LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Input : Push Button As a toggle switch

hello,

I am using Push button in a spring effect.

I want to control a LED with this input.

If Once I press that button output should be on on LED and second time press,It should OFF and so on....

Please give me logic 4 it...

Thank you.

0 Kudos
Message 1 of 11
(12,796 Views)

Please find the modified VI for ur solution.Hope this helps

 

Kudos are welcomed.:-)

Message 2 of 11
(12,786 Views)

Hi,

   Take a look at this.im sure it will help

-------------------------------------------------------------
kudos welcome
0 Kudos
Message 3 of 11
(12,784 Views)

Dear  omprakash,

 

I believe this is not full proof way, beacuse when LED local variable is FALSE & inpyt is TRUE, the LED will be TRUE & the same value will bepassed to its local variable.

 

Now if switch remains TRUE & LED is TRUE so LED will get OFF.

This condition will arrive when the processor is loaded & execution gets slow. Always avoid this.

0 Kudos
Message 4 of 11
(12,777 Views)

Hi kekin,

        Nice one.common thing is we both used local variableSmiley Wink

-------------------------------------------------------------
kudos welcome
0 Kudos
Message 5 of 11
(12,776 Views)

Hi kekin,

               Im not getting in particular what you are trying to say.

              please give some real time example or a vi

-------------------------------------------------------------
kudos welcome
0 Kudos
Message 6 of 11
(12,772 Views)

Your code will work only if LOCAL VARIABLE gets updated before the switch goes from TRUE to FALSE.

 

If LOCAL VARIABLE does not get updated before the input switches to FALSE then ur code will not work. You  have dependecy here & this error can happen randomely at any time.

 

F-->False , T-->True &  LV-->Local variable of LED.

For example, initially: 

1.LED=F , LV=F & INPUT=F.

2.PRESS INPUT

3.INPUT=T & LV=F so LED=T

4.Now if LV is not updated first then.

5.INPUT=F & LV=F so LED=F.LED will never turn ON.

 

This can happen.Hence your code will work only if LOCAL VARIABLE gets updated before the switch goes from TRUE to FALSE.

 

Kudos are welcomed.:-)

 

Hence I have edited your code to make it FULL PROOF.

 

 

Download All
0 Kudos
Message 7 of 11
(12,759 Views)

Here for writing to localvariable LED it takes time.Iagree
But in my vi im only reading from output LED
i.e
Here as the output changes local variable will change with it.
Because both share the same memory space.

-------------------------------------------------------------
kudos welcome
0 Kudos
Message 8 of 11
(12,747 Views)

Dear Omprakash,

 

If you search on LOCAL VARIABLE, then u will find that each local variable (whether READ or WRITE/ CONTROL or INDICATOR) is assigned seperate location & is updated after some time.

Local variables always chage after the CONTROl or INDICATOR changes.

 

Fastest is CONTROL & INDICATOR

Next is Local variables &

Slowest are Property Nodes.

 

Read following article to clear ur CONCEPTS:

 

http://digital.ni.com/public.nsf/allkb/2EE5662479871C058625753F005C2352

http://digital.ni.com/public.nsf/allkb/37002ACC84B961CA86256D9C00760EE2

 

and last but not least:

http://zone.ni.com/reference/en-XX/help/371361F-01/lvhowto/localvarcannotreusedatamem/

 

Hope this clears my POINT.

I cannot explain more on that.

 

 

Message 9 of 11
(12,743 Views)

Dear OP: ghj

 

Reqest to accept any one as solution depending upon ur choice & close the thread.

 

Kudos are welcomed.:-)

0 Kudos
Message 10 of 11
(12,739 Views)