LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to generate interrupt in Lab View

Hi,
   I want to make vi which should execute for every one second stopping current execution and return back to the stopped vi after completing the job i.e. i want to have to interrupt of every one second. Can we do this in Lab View, please help me in this regards.
 
 
Regards
Shivakumar Singh
0 Kudos
Message 1 of 5
(3,454 Views)
There are some synchronization tools in LV, but they are pretty advanced, and you need to be careful not to lock yourself out. You can find these in the Advanced>>Synchronization palette. You can do this more simply by having a VI which will be a lock. You lock it in one place (place a wait function inside it and wire 1000 into it to lock the VI or 0 as default) and then every other VI needing it will have to wait until the first VI finishes using it.
 
As to the more important question - why do you want to do this? This goes against the parallel nature of LV. You should basically only hold execution on things when having a shared resource or things that need precise synchronizing. Other than that LV can handle the execution itself if you assign priorities to different parts of your program and place wait functions in your loops so they release the CPU.

___________________
Try to take over the world!
0 Kudos
Message 2 of 5
(3,447 Views)
Hi,
    Thanks for your kind reply. I want this because, my vi will communicate with the outside world using RS-232 UART. As the card which is responding to VI is taking some 3 secs time. As i have to wait for the card to respond, i could not toggle any LEDs. But one LED has to be toggle for every one second indicating that process is going on. For this, i am planning to use one second interrupt for toggling LED.
 
 
Regards
Shivakumar Singh
0 Kudos
Message 3 of 5
(3,444 Views)

What you should probably do is seperate the application into several loops (communication loop, user interface loop and so on). If the loops are not connected to each other, they will run in parallel. Then, your comm loop can hold for 3 seconds and you can still blink the LED in the other loop.

Another way to do this blinking would be to set the Blinking property of the LED to T. When you do this, it will start blinking between its current color and another color, and it will do so without any connection to the code - there is no need to change the value of the LED.

You can set the property by right clicking the LED and selecting Create>>Property Node. Then, select the Blinking property and change it to write. Wire T into it when you want it to start blinking and F when you want it to stop. You can set the blink properties through the options menu (they're global).


___________________
Try to take over the world!
0 Kudos
Message 4 of 5
(3,442 Views)
Hi Shivakumar

On a related note, I always try to avoid the "Wait for X amount of time" algorithm. It's almost never what you want to do. What you want to do is "Wait for X event to happen," and a robust program will trigger off of the event, not a time delay. That way if X doesn't happen, or happens after an unexpected delay length, your program can deal with it.

In your case, it sounds like "X" is a response from the serial device. You can use the VISA Serial VIs to only return once the appropriate amount of data or a specific termination character is read. If that is in a seperate loop then it won't matter that it completely blocks execution flow in that branch.
0 Kudos
Message 5 of 5
(3,430 Views)