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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabView, Storing in array some dynamics variables (ENG - FR)

Solved!
Go to solution

(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

 

0 Kudos
Message 1 of 19
(2,593 Views)

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.

0 Kudos
Message 2 of 19
(2,573 Views)

Yes, and if I change the boolean FALSE to TRUE of this loop, my array goes well but it didn't stop ..

 

 

0 Kudos
Message 3 of 19
(2,566 Views)

Your shift register belongs on the outermost while loop.  I don't think you need the innermost one at all.

0 Kudos
Message 4 of 19
(2,561 Views)

 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?

0 Kudos
Message 5 of 19
(2,560 Views)

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 ?

0 Kudos
Message 6 of 19
(2,547 Views)

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.

0 Kudos
Message 7 of 19
(2,540 Views)

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.

0 Kudos
Message 8 of 19
(2,537 Views)

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.

 

0 Kudos
Message 9 of 19
(2,491 Views)

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.

0 Kudos
Message 10 of 19
(2,474 Views)