LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Gloabal variable can't change the value in an event structure

Ok, I don't think you completely understand how a while loop works.  You have it inside a case structure with a boolean control, and you want that control to start and stop the loop?  It won't work that way.  The reason the switch isn't working is that as soon as you switch it on, the inside while loop is running and since you have a false constant connected to the stop terminal in the inner loop, it will never end.  You need some kind of condition to stop the inner loop.  The easiest thing would be to just put another switch connected to the stop terminal, so you can manually stop it.  Without knowing much about what this program is doing, I can't really figure out when the inner loop needs to stop.
0 Kudos
Message 11 of 23
(1,268 Views)

I have an idea.  Create a local variable for the start/stop switch and connect it to the inside stop terminal.  Then click on the stop sign to change it to a Continue While True.  You'll need to disconnect the switch from the outside loop, but just connect a stop button to this to stop the program.

Now, when the switch is true, the case structure will be true so the loop will start.  Then once in the loop, it will continue until you switch off the start/stop switch.  You'll need to have the switch off and press your new stop button to stop the program.  This isn't how I would normally structure a program, but it looks like it's what you're trying to do.

0 Kudos
Message 12 of 23
(1,263 Views)

So simply choosing "Value Change" from the event list is not good enough? 

Chris

Chris Reyerson
Optical Systems Engineer
Arete Associates
Tucson, AZ
0 Kudos
Message 13 of 23
(1,255 Views)
No, it is.  The problem we're talking about is when you change the value of a control programmatically with a local variable or "value" property node.  This will not cause the "value change" event to trigger.  However, if you want to change a value with code and you do want it to trigger the event case, you need to use the "value(signalling)" property node.  This will assign the value and also trigger the event, as you can see in the example I posted.
Message 14 of 23
(1,243 Views)
which event case are you talking about? the one in NEWEXAMPLE.vi, if so, like Marc said, you have the inner loop connected to constant false, so it's going to run infinitely, change it to stop when you toggle stops.
also, you might want to change the time constant on the event structure to 1 instead of -1, i think if you have -1, the event structure will keep waiting for an event and the loop won't go to the next iteration until an event occurs.
 
sorry Marc, i know what you're talking about now ^_^
0 Kudos
Message 15 of 23
(1,244 Views)

Marc I think u missed something, in my program structure, Like Ray are saying , i  got the switch as an event by value change, so when i press the stop, the event handles the

action, and the event case stops as well. its not a problem, but i need the small case to stop to, so the big outer loop i sready again for a start action by the switch!!

zamzam

HFZ
0 Kudos
Message 16 of 23
(1,243 Views)
That picture  is different than the zip file you posted.  In the zip file, you had a false constant wired to the stop terminal on the inner loop, And there was no small case structure, only the big one with the event structure in it.  If you're talking about the small case structure with DataRead.vi, then I can't really tell you why it's not exiting.  It's probably a problem with that VI.
0 Kudos
Message 17 of 23
(1,236 Views)

Sorry sorry , mi mistake , i  think you got a later version, coz i havent saved it before i zipped the files

. When i run the program in signal motion, i can see that the signals (the 2 visa signals) at the end after pressing stop, goes out from the event case, then from inner loop, then from  the case structure and  at last to the outer loop and stops there. I thought that after that the outer loop will run again, but it dont!

If somehow i can send a signal from the event case when switched to stop, to stop the small case structure with the dataread, then meaby the outer loop will run again.

i'll try to remove it

HFZ
0 Kudos
Message 18 of 23
(1,223 Views)
Well another thing I just noticed is that you have a stop button wired to the stop terminal in a loop in dataread.vi.  This is why it's not stopping, you have no way of pressing the stop button.  There needs to be some other condition to stop the subVI.  I'm going by the version in the zip file, so unless you updated the subVI since then, this is why the program is getting stuck in the small case structure.
0 Kudos
Message 19 of 23
(1,221 Views)
Here is the newest program vers.
I removed the small case with the Dataread sub.vi, and i it worked,
It was because the small case was running in the loop. but now the problem is that i need that sub vi, cos its there i'll develop my data reads from flowmeter!!
and the next problem is that i want that sub.vi (dataread ) to stop also when stop is pressed, and to start again for measurements when pressed to start again.!!
 
any suggestions, meaby i can place the dataread subvi outside the big while loop ...
 
HFZ
0 Kudos
Message 20 of 23
(1,216 Views)