02-09-2009 06:28 AM
Hi guys,
i am trying to write a VI that will create an tab delimetated file, add some text to it for colum titles and then log numeric front pannel data to it once per second. I have got it working but am having some problems with the structure.
in the current layout the VI ignores the "log data button", if you set it before you run the vi it works but if you set it while the vi is running it sees it as false. But i have tried putting the button further into the loop and then it works but the stop function stops working.
I have attached a picture of the program. Thanks Zac
Solved! Go to Solution.
02-09-2009 06:34 AM
Hi Zac,
you kn ow the term "data flow", don't you?
Your boolean switch is only read once before the sequence structure is run. That's why your vi "ignores" that switch when you set it after you started your program. Put the switch inside the sequence (and inside loops) when you need to poll it more than once...
02-09-2009 08:08 AM - edited 02-09-2009 08:10 AM
Hmm, i have tried loads of combinations, if i put the boolean in the while loop inside the right hand sequence i cant then wire it to the case statement in the left of the sequece. If i create a local variable in the left sequence it doesnt work.
i have attached some pictures.
"showasfalse.jpg" shows the probe on the boolean when the button is switched. (it still shows as false even though its in the while loop, and i have tried it with the delay timer in the outer while loop.
"booleaninloop.jpg" shows that i am unable to connect the switch to both case statements when it is nested in the loop.
"booleanlocalvariable.jpg" shows the layout with the switch in the loop and a local variable for the other case statement, they both read as false.
Thanks Zac.
02-09-2009 08:19 AM
You still have serious dataflow problems.
1. In Show as False. The value is not actually false. False is the defaut data type for a boolean. You'll notice that the probe is greyed out. That means it hasn't been read yet since the probe was placed. That's because the program probably already entered your inner while loop by the time you placed the probe. You actually have no way of stopping that inner while loop. The condition for the stop terminal comes from outside the loop. So it will either run once if that boolean is True, or run forever if that boolean is false. That's because the event structure will only execute a single time before the inner while loop gets entered.
2. In boolean in loop you have a broken wire. That is because you are trying to force the data flow backwards. The second fram of the sequence structure can't run until the first frame is complete. However with your wiring, your requiring the data from the boolean control in the 2nd frame before you execute the code in the first frame. A logical impossibility.
Get rid of the inner while loop in the 2nd frame. Move the shift registers out to the outer while loop. Change the data type on your shift register intialization from a blue integer wire to the Double orange wire.
With what you are doing, you should look at a state machine architecture. Search the forums for examples.
Also, I would recommend looking at the online LabVIEW tutorials
LabVIEW Introduction Course - Three Hours
LabVIEW Introduction Course - Six Hours
02-09-2009 08:25 AM
Thanks for the info, i will try doing what you said, and i will see if i can find any info on state machines. Its only my second week playing with labview so im very much still learning.
Thanks for the help, Zac