Communauté des utilisateurs LabVIEW Discussions

annuler
Affichage des résultats de 
Rechercher plutôt 
Vouliez-vous dire : 

Advanced while loop

Hi, 

 

Please, could someone explain to me how the code works in the advanced while loop in the attached picture and what is the difference with the simple version of the code? 

It's something Urgent. 

Thank you in advance 🙂 

Lam_8_0-1666563801277.png

 

 

0 Compliments
Message 1 sur 4
295 Visites

Since you know the number of iterations before the loops even start, they should be a FOR loop. No need to check for termination at each iteration

 

  • The simple version will create an array with about 10 elements, then exit. The array size will grow by 1 with each iteration.
  • The upper version (I will not call it "advanced"!) will create an array of NaNs with 20 elements and the replace the first 10 elements in order before exiting, leaving you with an array of 20 element, half are NaN. The array size will be constant. Make sure you resize the array container to see all elements!

 

The difference becomes more important if the loops run for very long time at a fast rate and we don't know when they will be stopped by the operator. I that case, the lower loop will grow the array forever and eventually you'll run out of memory. The upper loop will have a fixed size array with 20 elements and the oldest element will get overwritten with the new data. Much more memory efficient.

 

So, I recommend the following tests to understand things:

 

  • Resize all array indicator containers to show at least 30 elements. (container size != array size!)
  • Remove the comparison and just wire the termination condition to a stop button on the front panel.
  • Run each version for at least 30 seconds.
0 Compliments
Message 2 sur 4
263 Visites

Dear Altenbach,

 

I have a problem with my MacBook computer. I can't launch LabVIEW. It is an assignment to be done for today (a two-page report). The file LabVIEW is attached. Please, could you send me screenshots on Labview of what you recommended I do?
I'll be very grateful to you.
Thank you very much.

 

0 Compliments
Message 3 sur 4
226 Visites

@Lam_8 wrote:

I have a problem with my MacBook computer. I can't launch LabVIEW. It is an assignment to be done for today (a two-page report). The file LabVIEW is attached. Please, could you send me screenshots on Labview of what you recommended I do?

 


(Sorry, I don't have access to LabVIEW 2021 at the moment, so I cannot look at your attachment. If you have a hardware problem, talk to your teacher. Maybe there is an alternative solution)

 

The recommendation on what to do depends on the exact problem description. What is the purpose of the program? What are the controls? What should the desired output be. What problem does it solve? How does it fit into the big picture? 

 

We don't know any of this!!! All you asked was the difference between the two code versions in the first message and I explained it to you.in detail. Did you understand my explanation?

 

What should be the topic of the two-page report? For the report, give it a good title and don't forget to include your name,

Start with one or two paragraphs explaining the problem description, followed by a description of the program and how to use it. Add some screenshots. At the end write conclusions and an outlook what could be improved in the future and how it could be scaled to a much larger program.

0 Compliments
Message 4 sur 4
188 Visites