LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

timing loop

I have a LV program which integrates with C++ to measure Q value. This prgram has 10 frames in a stacked sequence. Now, the requirement is to get Q value at different times and then plot it versus time. Is a timed loop better? If so how do I use it over a stacked sequence with many frames ?

Thanks
0 Kudos
Message 1 of 12
(4,019 Views)

A 10 frame stacked sequence is not a great program design, but  timed loop has and entirely different function so this won't be a drop-in replacement (Also, why does it need to be a timed loop, how about a plain while loop?). Basically, you should rework your code into a state machine type architecture.

More detailed advice is difficult without seeing the code (or much more information).

  1. How do you integrate C++ (e.g. using a dll)?
  2. Why are there 10 sequence frames? What happens in the frames? Where is the plot generated?
  3. How many frames calculate Q?

Please attach your program so we can be more specific in the advice. 🙂

0 Kudos
Message 2 of 12
(4,016 Views)
Thanks for the quick reply. Here is the code. Actually I only did the dll on C++. The entire program was done by someone., and so I thought it was simple to just add one more sequence for calculation of Q using the program in C++.
0 Kudos
Message 3 of 12
(3,987 Views)
You certainly do not need the sequence structure. You do not need any of the local variables. Simply use the error wires to define the dataflow. Perhaps better would be to create an aray of the commands and feed them to a for loop with the write to GPIB and read from GPIB inside. You may be able to just set the byte count inputs on the read functions to a large number. The Read will return at the end of message or end of transmission signal from the instument.

To repeat your Q measurements put the necessary parts inside a while loop.

Lynn
0 Kudos
Message 4 of 12
(3,972 Views)
Hi .. Thanks a lot for the valuable suggestion.. I jsut got it working with the arrayed commands .. and was trying to implement the while loop when the instrument or the program went off on me.. it gives me the error 0. It happened earlier too.. for no good reason and I just had to play with the buttons on the analyzer and after a while it was fine. And its doing it now.. any precautions to stop this? Am I doing soemthing wrong?
0 Kudos
Message 5 of 12
(3,938 Views)
Error 0 is usually no error. So something else may be happening. You say the program "went off..." Exactly what does it do or not do? Is it still running? Use execution highlighting (the light bulb on the diagram menu bar) to see what part of the program is active. Do the GPIB devices seem to be doing anything while the program is not working right?

Post the VI with the problem. Even though we cannot run it without the instruments, we may be able to identify something for you tocheck.

Lynn
0 Kudos
Message 6 of 12
(3,877 Views)
well.. after holidays.. I connected the analyzer and ran the program, nothing unusual happened. But I still have to figure out how to program the while loop so that, the graph of Q vs Time can be seen for every iteration  while running. I mean the requirement is that the graph should be plotted realtime. I understand that there can be 2 ways, either I specify the start and stop time prior to run, or ask the program to adjust accordingly and run it as long as I want. Am I in the right track?
0 Kudos
Message 7 of 12
(3,841 Views)
First, you should clean up your code a bit. For example the inner FOR loop to calculate the frequency array never changes inputs, so all this belongs before the big while loop. These calculations need to be only done once, and not over and over again with each iteration. 😉
 
Don't do all that clustering to prep the data for the xy graph, but simply feed it a complex 1D array :). To dynamically update it, you can build it up in a shift register.
 
I don't understand the need for the millisecond timer value. It is pretty useless.
 
In addition, you have some race conditions. e.g. if you don't click "save to file" before stopping the main loop, your chance for saving is irreversibly lost.
 
Why don't you make a nice state machine?
0 Kudos
Message 8 of 12
(3,834 Views)
Thanks a lot for the suggestion.. I am trying to clean up a lil. The thing is, I was trying to figure out how to get the values of time on the plot.. so thought a timer would do it..
Well.. the idea of a state machine sounds interesting.. but maybe its a lil bit too much for an amatuer like me 😞 But.. with ur guidance...
0 Kudos
Message 9 of 12
(3,812 Views)
Hi UofH

I hope you are doing well today! State machines would definitely be best for your code. In order to start working with state machines, I would recommend that you start with the template provided in LabVIEW. You can access this template by going to the Getting Started Window and selecting New»More»VI»From Template»Frameworks»Design Patterns»Standard State Machine. Since you have already designed a stacked sequence structure, working with state machines should be intuitive.
Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
0 Kudos
Message 10 of 12
(3,780 Views)