Showing results for 
Search instead for 
Did you mean: 

whats the problem in this vi?

Dear all,

with loads of help from many members of this group we designed the following attached vi.

but we made some changes recently to get a running/scroll display. basically the program has two loops, one for data acquistion and one for data generation. the acquistion loop designed to update 1 data point at a time and generation loop designed to update 1000 points at a time. but now the vi works in a funny way. when the program starts it runs the acquisition loop first and when the stop key is pressed it runs the generation loop. to stop the program, i have to abort it. can anyone point me what the mistake is and direct me in the right way please.
0 Kudos
Message 1 of 6
You wired two loops and made these cycles run one after another. I mean, for example, stop 2 in one loop wired to another loop making bottom loop running after the top loop. It's a mistake in your case. Look at the possible correct example patterns like this one:
0 Kudos
Message 2 of 6

You need to familiarize yourself with the concept of dataflow programming.

  1. The lower loop depends on data from the upper loop (the "stop 2" wire and the error cluster leading to "DAQmx write"). these will only contain data once the upper loop finishes, thus the lower loop cannot start until the upper loop finishes.
  2. The lower loop should stop after one iteration, because it also gets the TRUE from "stop 2". If it does not, it means that the code stalls somewhere, probably in one of the subVIs.

If loops need to run in parallel, you cannnot have wires going from one loop to the other. Any such wire creates a data dependency that forces execution order.

LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 3 of 6

In addition to the execllent pointers given by Sergey and Christian, I want to mention one more thing

Since you are performing a simultaneous AI, AO operation, I suggest you have a look at examples given in find examples>>H/W input output>>DAQmx>>Synchronization>>Multi Function folder and have a look at "Multi function Synch"

you will be better off by following this logic.

Message 4 of 6
Dear all,

thanks for your suggestions. i changed the looping structure and it is working fine. thanks dev for mentioning that example program once again. i should've had a look on that program more carefully the first time u mentioned. i simply followed the principle on that program and it did the magic.  thanks once again.

anyway, but as usual i have one problem now. i am not sure whether u remember the case loop u helped me with in the earlier stages for recording purposes. briefly it had been designed to record for a given number of time, depending on the number of data per cycle. it  had two options, when we press the record button, it can record for the defined amount of time or the recording can be stopped before the defined amount of time is over and so the record button will be ready for the next go.

but for some reasons, i m lacking the second option now. i can record without any problem for the defined amount of time but if i stop the recording during that period, i cant able to restart the recording again. but i have to stop the program and have to start to do that. can u tell me whats the reason for this please.

i attached the program as usual.

Many thanks.

0 Kudos
Message 5 of 6
Generally, you forget to reset your time counter variable in upper loop. Shift register contains the value of 199 and never allow to write anymore after the first time/ Quick solution is to add trigger to reset this counter. I haven't chance to test it, but should work. (attached)

0 Kudos
Message 6 of 6