From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
05-28-2014 07:35 AM - edited 05-28-2014 08:04 AM
(Version française plus bas)
Hello,
I have made a tiny .vi for using DAQ USB in analog acquisition of sine.
I want to store each step of test in one array. But when I start a new measure , it erase the old one.
Sorry for my bad english
---------------------
Bonjour,
Je suis actuellement entrain de mesurer des dephasages grâce au DAQ de LabView. J'aimerai sauver mes différentses phases de test dans un tableau mais à chaque nouveau test les valeurs sont écrasées.
Merci d'avance pour vos conseils
Solved! Go to Solution.
05-28-2014 08:26 AM
Your innermost while loop only runs once.
The shift register you have on that while loop gets cleared everytim that case structure allows it to execute again because you are initializing the shift register with an empty array.
Turn on Highlight Execution. Watch the data flow, and you'll see what is going on.
05-28-2014 08:42 AM
Yes, and if I change the boolean FALSE to TRUE of this loop, my array goes well but it didn't stop ..
05-28-2014 08:45 AM
Your shift register belongs on the outermost while loop. I don't think you need the innermost one at all.
05-28-2014 08:52 AM
If you want to store data in a shift regsiter, that shift register belongs on the outermost loop and if the data in it should survive between runs of the program, it should be uninitialized.
You have one big sequence structure that allows only half of the code to respond at any single time. I think a state machine architecture would be more appropriate.
Your current code is way too convoluted and inefficient. Did you noTice that your VI uses 100% CPU when doing nothing by polling a button as fast as the computer allows?
05-28-2014 10:02 AM
I have change the initialisation of the shift and it works like I wanted.
I also have modified the VI for using both system acquisition when I want.
But I don't understand why you said that the CPU is full used when I run ?
And I don't understand why my "STOP" button didn't stop the run of the VI ?
05-28-2014 10:18 AM
Your stop button is read, the value enters the loop. Until that loop stops so that the stop button can be read again, it is going to be stuck at false and the loops will run for ever.
This is a basic data flow principle
I would recommend looking at the online LabVIEW tutorials
LabVIEW Introduction Course - Three Hours
LabVIEW Introduction Course - Six Hours
The nested while loops are going to give you a lot of problems. You really need a state machine architecture like Altenbach was talking about.
05-28-2014 10:26 AM - edited 05-28-2014 10:26 AM
The stop button does not work because you have a dataflow problem. The stop button gets read exactly once at the start of the program, and then never again because the inner loops never stop. Once the inner loop starts, the outermost loop does not iterate until all inner loops have completed. This also means that the stop button will not get read. If you want a button to get the updated value inside an inner loop, the terminal needs to be inside the inner loop.
If all three of your buttons are off, you have three inner loops that execute empty cases, each as fast as the computer allows, consuming all available CPU. The loops need a small wait. See also.
You really need to learn about dataflow and design patterns. You code could be simplified dramatically. It is way to chopped up and inside out.
05-29-2014 02:32 AM
Thanks for your advices,
I ask myself about the timer on the inner loops, do I set them in the if "FALSE" loops ? Because I don't want to loose data by putting timer in DAQ's loops. Or it has no influence ?
How can I keep an "infinite" running app with state architecture ? Because I want to run my VI "like an .exe"
I actually read second tutorials. I had already read the first one in french.
Sorry for being noob, this is my 4th week on labview and my works end in 4 weeks ..
For the little story,
I have to caracterise stepper motor with an LabView application. So doing that I have to measure phase between a resistor and 1 coil and that for each phases. So a lot of data will be store and at the end it will create a datasheet of the stepper.
05-29-2014 07:09 AM
I have changed some things ..
Using a State Machine String based and an unique loop for measure.
I hope this time my VI isn't too bad.