LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with OK Buttons

Hi

I have a labview code where I name two OK buttons to do two tasks as DoTask1 and DoTask2. If I press DoTask1, the program will do task 1 for about 15 secs and stops. The same deal applies for DoTask2.

These two buttons are in the same big while loop, where each iteration only runs when either task1 or task2 buttons are clicked.

In other words, the program runs like this. [click task1] - [run one iteration] - [wait for the next input] - [click task1] - [run another iteration] - [wait for the next input] - and so on

Now I want to write a code to control this task alternatively and automatically, say DoTask1 - DoTask2 - DoTask1 - DoTask2 - ...

The problem is that I cannot manage to get my little code to alternatively "click" buttons forever.

Please help
Thank!
0 Kudos
Message 1 of 15
(4,192 Views)

Hi,

        To do the ask alternatively its better to use event structure in the while loop.Create to events for task1 and task2.Hope this helps you.

0 Kudos
Message 2 of 15
(4,187 Views)

Use a state machine with three states (idle, task1, task2). The idle state will poll the buttons and switch to the relevants task.

At the completion of each task you can decide what the next state should be (idle or "other" task, for example).

(There is not need to programmatcially click any buttons.)

Message Edited by altenbach on 10-13-2008 09:18 PM
0 Kudos
Message 3 of 15
(4,184 Views)

Hi

 

Other then the 2 options suggested above you can also use shift register, if your requirement is just to run both the Tasks alternatively.

 

Please see the attachment.

Thanks & Regards,
Rajan
Download All
0 Kudos
Message 4 of 15
(4,154 Views)
Here is what the code looks like.

The subVI #9, will just receive the boolean values passed by this code.
0 Kudos
Message 5 of 15
(4,120 Views)
Now with the help from Rajan_77, I tried to implement it with my code, but I still have to problem. Please see attachment

Thanks
0 Kudos
Message 6 of 15
(4,116 Views)
Please see attachment "Original.gif"

Ideally I do not want to change the original code. I just want the helper code, within the same file (not other VIs), to help me click the buttons.

According to altenbach, by doing so, will the 2 buttons still be pressable from other users? My labmates want to be able to press them, but I just want to oscillate between two positions. 

Thanks for all the help!
0 Kudos
Message 7 of 15
(4,110 Views)
Diagrams have been attached. Still need help. 🙂

Thanks
0 Kudos
Message 8 of 15
(4,069 Views)
Im not sure I follow you.  You want to have a user click on either "Move to A" or "Move to B" (Lets say "Move to A" for clarification), which will move into your subVI and act accordingly.  Once the subVI finishes its execution you want the program to automatically execute "Move to B".  Once the subVI finshes execution the program will automatically execute "Move to A"...  Is this what you are looking for?  Do you want the user to be able to interrupt this with a button press?  How do you want to implement the while loop stop logic?  Will it stop whenever the stop button is selected?
0 Kudos
Message 9 of 15
(4,057 Views)
Hi

Your understanding is almost correct. I want to write a code with a very simple interface, says having "start and stop buttons. Once the start button is pressed, the program will do the job such that it will alternatively "click" Move to A and Move to B forever, until the stop button is hit.


Once the subVI finishes its execution you want the program to automatically execute "Move to B".  Once the subVI finshes execution the program will automatically execute "Move to A"...  Is this what you are looking for?
- Yes.

Do you want the user to be able to interrupt this with a button press?  How do you want to implement the while loop stop logic?  Will it stop whenever the stop button is selected?
- That would be nice. A stop button will stop the loop and return to the idle state, says the loop waits for the next input.

Thanks for your help 🙂
0 Kudos
Message 10 of 15
(4,040 Views)