LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to switch booleans whithin a loop to 0 when stop is hit

Solved!
Go to solution

I am trying to write a program than can send digital signal to an external oscilloscope. I am using NI-USB-6008. The program runs but when I hit "STOP" button (while the On/Off signal's boolean switch is on) the oscilloscope still shows an ON signal.

The problem: How to switch the boolean to Off immediately when I press STOP?

I tried using "Clear Task" and "joining the STOP button with the boolean switch but nothing change. Please find attached my program.

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

ORing the stop button will obviously not work since you would be sending a True from the button.

 

Simply do another DAQmx Write before the clear task.

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

You could do something as follows (note the invert circles)

 

 

0 Kudos
Message 3 of 11
(3,676 Views)
Solution
Accepted by topic author kthouz

 since you are looking at error status in the loop conditional logic I would recommend putting a second write outside the loop to garantee the write happens when exiting on error. Additionally, add an error handler after the clear task .

 

 


"Should be" isn't "Is" -Jay
0 Kudos
Message 4 of 11
(3,667 Views)

@Jeff Bohrer wrote:

since you are looking at error status in the loop conditional logic I would recommend putting a second write outside the loop to garantee the write happens when exiting on error. Additionally, add an error handler after the clear task .


Depending on what the error was, the last write might fail inside or outside the loop, so there is no real difference to my suggestion.

You would also need to clear the error before the last write outside else it would not do much anyway..

Message 5 of 11
(3,659 Views)

@altenbach wrote:

@Jeff Bohrer wrote:

since you are looking at error status in the loop conditional logic I would recommend putting a second write outside the loop to garantee the write happens when exiting on error. Additionally, add an error handler after the clear task .


Depending on what the error was, the last write might fail inside or outside the loop,   Exactly- and the most compelling reason to add an error handler

so there is no real difference to my suggestion.  Except the user is notified of the error and that the hardware may not be in the expected state Smiley WinkSmiley Surprised

You would also need to clear the error before the last write outside else it would not do much anyway..Pssst it was or more correctly the write outside was not passed the error out from the loop and a merge errors is used to pass on the error information


 


"Should be" isn't "Is" -Jay
0 Kudos
Message 6 of 11
(3,653 Views)

Fortunately, automatic error handling is enabled by default... so the clear task will bark anyway. 😄

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

@altenbach wrote:

Fortunately, automatic error handling is enabled by default... so the clear task will bark anyway. 😄


Oh- I've dissabled error handling in my LabVIEW.ini so long ago that I forgot.  Didn't everyone?Smiley Very Happy


"Should be" isn't "Is" -Jay
0 Kudos
Message 8 of 11
(3,643 Views)

I don't really care to leave it enabled, because my code never produces any error anyway... :o:D

Message 9 of 11
(3,637 Views)

Thanks a lot. Actually, I am new to LabView, would you suggest me any book with enough tutorials and exercises that can help me?

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