06-21-2017 01:11 PM
I have written a VI to test an electrical part. However, when I run the VI, the program executes the flat sequence just once inside the while loop and I am not able to identify what prompts the program to exit the while loop. I tried running the VI with just the flat sequence inside a while loop and I was able to see that it doesn't have any problem. The problem arises when I place the Daqmx inside the while loop. Could someone please help me to identify the root cause of this error and what aspect of the Daqmx is prompting the program to exit the while loop. Thank you in advance.
06-21-2017 01:18 PM
You have a dataflow issue.
I would recommend you learn more about LabVIEW from here. How to Learn LV
Your inner while loop is controlled by a stop button that is outside of that inner while loop. If the Stop button is pressed when the outer while loop starts, the inner while loop runs once, and the outer while loop runs just once.
If the stop button is not pressed, i.e. false, the outer while loop runs, and the inner while loop will run forever because it will only ever see the false value of the boolean wire on its tunnel. Even if you press the stop button, the inner while loop won't see it because the stop button won't get read again until the inner while loop stops and the outer while loop iterates again, which will never happen because the inner while loop is stuck to run forever.
06-21-2017 01:31 PM
Thanks for pointing out the data flow issue with the second while loop. However, I have modified the VI (test 1.VI) to include just the flat sequence and 1 set of Daqmx logic. I am not able to understand why the Daqmx logic is preventing the flat sequence from executing in a loop. Thank you and I really appreciate your help.
06-21-2017 01:38 PM
There are many other timing issues with this along with a block diagram that is way to large for the code.
As RavensFan pointed out, a few hours spent reading on LabVIEW basics should point you in the right direction. There is a time and a place for local variables, but this is not it.
06-21-2017 01:39 PM - edited 06-21-2017 02:37 PM
You still have a serious dataflow problem, mostly by caused by blatant overuse of local variables. Your DAQ task runs once per loop iteration using whatever the instantaneous values of the indicators happen to be at that moment (most likely the stale last values from the previous iteration :o).
Your flat sequence runs slowly in parallel, but the DAQ never updates until the start of the next while loop iteration.
You don't need any of the local variables. Use an state machine and write to the DAQ whenever the booleans change. All you need is an array of times and boolean states, then change state according to the timing and rewrite the DAQ output.
06-21-2017 01:47 PM
Thanks to both of you for answering my question. I shall go through the LabVIEW Basics and tutorials on state machines as well.
06-21-2017 02:33 PM - edited 06-21-2017 02:54 PM
Here's a very primitive implementation. Maybe it can give you some ideas. Modify as needed.
(There are probably some bugs)