LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with global variables

I'm having trouble with the two VI:s I have attached. In the testorder VI I can add a number (1,2,3 or 4) to my order_array by pressinf the buttons on the front panel. The global variabel "delete_element_0" deletes the number that is located at index 0 in my order_array. The second VI, testshovel.vi, is a simple state machine with two states where the first state, "wait", includes a button "Delete element at index 0" that will execute the "empty" state which will set the global variabel "delete_element_0" to True. The button I have used in the default state "Delete element at index 0" is selected as "latch when pressed" and this wotks great. Now the problem I have is that not only the first element at index 0 in my order array is deleted, they all are... Now I know that this is beacuse when I set my global variable to True it stays True all the time. This will of course make delete the number at index 0 in my order array until there are no numbers left. How can I solve this ? I want to set my global variable to True and then when it is read by labview it should go back to False, this way only one nu number in my order array will be deleted. I have tried to use the same mechanical action that I used with my button called "Delete element at index 0" but it appears that it doesn't matter what kind of mechanicak action I choose. Can anyone help me ? Could it be possible to get it to work as the program is written today or do I have to change anything ?

regards
Daniel Holmqvist
0 Kudos
Message 1 of 6
(2,898 Views)
I just added a portion in the testorder.vi to change the global back to false after it has done what you wanted it to do.
________________________________________________________

Use the rating system, otherwise its useless; and please don't forget to tip your waiters!
using LV 2010 SP 1, Windows 7
________________________________________________________
0 Kudos
Message 2 of 6
(2,887 Views)
Hi !

Thanks for your answer ! Sorry to say that I'm running labview v. 7.0 so if anyone could convert it to 7.0 I would be very pleased.

/Daniel
0 Kudos
Message 3 of 6
(2,884 Views)
Here is a modification of your program which utilizes a functional global. With the functional global you can reset the value of the global when it is read inside the functional global, which is only one of the many advantages of functional globals. This should be in version 7.0.
0 Kudos
Message 4 of 6
(2,873 Views)
Hi !

Thanks for your answer, looks like you have a good tip there with the functional variables. However I can't find any attached program , or have I gone blind 😉 ? Thanks again !

/Daniel
0 Kudos
Message 5 of 6
(2,868 Views)
Oops. It looks like the attachment got lost. I have reconstructed it and attached it here.
0 Kudos
Message 6 of 6
(2,845 Views)