LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

storing array after while loop

I'm trying to write values into an array that I pick out from a string, which works fine.  My problem is that I cannot store this array once I stop the while loop.  Can antone tell me why there is no file written when I stop the loop.  This vi is just a test of the vi I'm using for a pulse-ox sensor, but it shows what I'm trying to do.   
0 Kudos
Message 1 of 6
(3,482 Views)
The only way you can stop the loop is by using the Abort button on the toolbar. That is not the way to stop a loop. Abort means the entire VI stops - not just your while loop. Place a Boolean control on the front panel and wire it to the loop's termination terminal.
0 Kudos
Message 2 of 6
(3,479 Views)
0 Kudos
Message 3 of 6
(3,468 Views)
Hi slarkin & "ok but",

I cleaned up your vi just a little bit...

Remarks:
- use increment ("+1") and decrement ("-1") operations when possible
- try to simplify calculations
- much more comments in the vi...


Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 6
(3,449 Views)
The VI is more complicated than it needs to be.
  • Your wiring is a mess. You really should read the LabVIEW Style Guide.
  • You're using the magic number of 120 in four different places, all intended to be the same constant. You should use a wire going to the constant on the outside of the loop where you're initializing the array. But... (see next point)
  • You have a Rube Goldberg entry!

    Your code:

    my version:

    Same thing.

  • There's +1 and -1 functions that you can use instead of the Add primitive.

EDIT: Created message and posted just at the same time as Gerd. Oh well. You get the picture.

Message Edited by smercurio_fc on 04-15-2008 01:36 PM
Download All
0 Kudos
Message 5 of 6
(3,445 Views)
Before you continue, you should familiarize yourself with propler coding techniques, to avoid problems in the future. Once you add more features, the current code will become incomprehensible.
  1. Use the correct representation for the indicators
  2. SInce you only use "replace array subset", the array size never changes so it is not needed to measure it at each iteration.
  3. "Index array" and "replace array subset" are resizeable. If you work with consecutive indices, you only need to wire the top, unwired indices will be "+1" of the one above it.
  4. Don't use wires going from left to right.
  5. There are "+1" and "-1" primitives.
  6. You have three "120" diagram constants right next to each other. One is enough, just branch the wire.
  7. It is sufficient to calculate "2*(x+1)" once. You do it twice for the same wire value.
  8.  ....

The attached picture shows one way how the same code could look like if you would follow some of the points above. And, yes, as others have said, you need to stop the loop with a stop button so the following code can executed. 😄

EDIT: And yes, as smercurio_fc points out above, some of the math is way too convoluted. I did not try to make sense of it. 🙂



Message Edited by altenbach on 04-15-2008 11:39 AM
0 Kudos
Message 6 of 6
(3,441 Views)