LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

indexing a loop

yeah, you do have quite a few issues with memory management. I would suggest you take a look at:

http://zone.ni.com/reference/en-XX/help/371361D-01/lvconcepts/vi_memory_usage/

http://zone.ni.com/wv/app/doc/p/id/wv-314

You also have a  bit of race conditions. None of your main loops are dependent on the initialization sequence so they are not necessarily initialized before running. I would use an overall sequence structure to control initialization-->run-->shutdown.

You don't necessarily have to get rid of your local variables. Just make sure that you control the writes to them. If you have more than one thing writing to them you can get more race conditions and the possibility of overwritten data.
0 Kudos
Message 11 of 21
(991 Views)
Wow, I wish I had your monitor. Must be the size of a wall! 😄
 
I cannot see what kind of problem could cause your observation. Where did you add a delay to fix it?
 
Let's look at your loop in the "not working" code fragment:
  • Since the number of iteration is known before the loop starts, this should be a FOR loop.
  • You can resize the index terminal to get both values in one swoop.
  • Indexing the "size" array belongs before the loop, because it needs to be done only once. (well, with a FOR loop you don't even need it, of course).
  • The inner loop needs a wait.
  • Except for signaling, value properties shold be replaced by local variables.
  • Why do you read from a local variable of "Dark list"? It is not used anywhere else, so you could just place the terminal right there. The local variable forces another datacopy in memory.
  • This loop can never stop, keeping the entire program running forever until aborted.
In the main program, there are still tons of code fragments that show some basic musinderstandings.
  • Most of your event structures have an empty timeout event, just to spin the loop and read the local variable to stop the program. You can delete the timeout event and create another event for the stop button. This will make things predictable and eliminated the local. It also saves CPU because loops will only spin if needed. You currently switch the stop button and then reset it via a value property node in one of the loops. There is no way to guarantee that all other loops can read the therminal vial locals before it turns false again.
  • You.don't understand local variables. A local variable just refers to it's control/indicator, so writing a local variable to its own indicator serves no purpose! (Writing the "header data" local to the "header data" terminal does not change anything in the grand scheme of things. It is just pumping empty electrons. (see image).

Overall, you entire code should fit on one normal screen. You need a maximum of two loops, one event strcuture, a few shift registers, and 90% of your local variables a value property nodes can be eliminated. If I had a gigantic monitor, I could clean it up a bit, but like this I'll get carpal tunnel syndrome from all the scrolling. 😮



Message Edited by altenbach on 07-02-2008 08:57 AM
0 Kudos
Message 12 of 21
(985 Views)
Live near Mt. Palomar? Would love to have you visit>
I'm trying some of your suggestions and will get back to you.
0 Kudos
Message 13 of 21
(973 Views)
I think altenbach just wants to see the size of your monitor. Smiley Very Happy
0 Kudos
Message 14 of 21
(970 Views)


smercurio_fc wrote:
I think altenbach just wants to see the size of your monitor. Smiley Very Happy

Size does not matter. What counts is the resolution, or so I was told. 😄
0 Kudos
Message 15 of 21
(964 Views)


0 Kudos
Message 16 of 21
(957 Views)
The main program generates a list of exposure times for which dark frames have to be taken after the run. When the run is over, you go to the take dark tab in the main vi. This loads the dark exposure times into another array with a for loop and calculates various parameters the camera needs, as well as setting the number of images per exposure time. This array can be edited and the calculate button allows you to calculate how much time is require to get all the data. Hence the while loop.
Once you are satisfied, you start taking images with a for loop. You'll see the delay in the attached code.
0 Kudos
Message 17 of 21
(951 Views)
So, do you still have problem with the index incrementing wrong?
 
Anyway, there is some dead code. Did you notice that you wired to the loop border instead of N? An autoidenxing tunnel knows how to count, so you don't need to wire N unless you want to loop for fewer elements than the array has. The "array size" and "index array" can be deleted without change in functionality.
 
 
 
 


Message Edited by altenbach on 07-02-2008 10:41 AM
0 Kudos
Message 18 of 21
(937 Views)
Haven't yet figured out the loop indexing problem but the code is certainly running better. Thanks.
The loop indexing problem is better in the sense that I can see it stop on the next increment for longer before skipping it. I guess that points to it being over ridden some where else in the program.

Sure you don't want to visit Mt. Palomar?
0 Kudos
Message 19 of 21
(901 Views)


exo wrote:
Haven't yet figured out the loop indexing problem but the code is certainly running better. Thanks.
The loop indexing problem is better in the sense that I can see it stop on the next increment for longer before skipping it. I guess that points to it being over ridden some where else in the program.

Sure you don't want to visit Mt. Palomar?

I don't think it was skipping any iterations.  The loop just runs so fast that you may not see the display get updated for a given iteration.  Updates of indicators occur in the UI thread.  If you have numerous updates to be made (as Altenbach said, these updates are asynchronous) the UI thread may batch them together in a way that they get updated at the next CPU opportunity and they happen so fast, there is no way you can see them all.  With a wait statement, you slow down the code, and also give the CPU more time to service the UI thread.
0 Kudos
Message 20 of 21
(894 Views)