LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

delete item from array

Hi, I'm working on a system that reads data through the serial port, where the data being transmitted is built using a pre-defined space delimited method.  It is actually being transmitted wirelessly using a Zigbee radio(s) so I have to be able to parse through the data being read so that it can be formatted and output to the user.  I have the parsing section all done, but about a quarter of the time the .vi has to throw away the transmitted data since it only recieves a portion of it.  I have the data built into a cluster which executes 100 times then repeats.  My problem is that when the parsing function has to throw away the data it inserts 0's into the cluster so that when I use a XY graph it plots the data points but also the 0's so that you get a discontinuous graph.  The 0's are there because I have a case block when it doesn't like the data it's not supposed to do anything, but apparently the default case is to insert 0's into the cluster.  Does anyone know a way around this?  The ways I can think of fixing this are when you detect that the data is faulty you delete that element from the array, or when it detects this to immediately terminate the execution of the for loop.  I don't know how you'd set it up to delete the elements from the cluster and I don't think its possible to immediatly stop the execution of the for loop.
Download All
0 Kudos
Message 1 of 8
(3,337 Views)
Hi,
 
You could use a shift register and a condition in your loop which controls a case structure such that if data is good, "build array".  If data is bad just circulate the shift register.
 
Craig
LabVIEW 2012
0 Kudos
Message 2 of 8
(3,335 Views)
If you're just worried about the XY Graph, you can set the Y value to NaN. Then, it won't be plotted. You just need to do this in the False case. This way, you won't need to carry around a shift register.

Also, what's the point of having the Boolean checking against "Ready for Data" and the Stop control inside the for-loop? It certainly doesn't affect the for loop, and you're simply going to get the value from the last iteration of the for-loop.
0 Kudos
Message 3 of 8
(3,327 Views)
See attached for quick demo.
LabVIEW 2012
0 Kudos
Message 4 of 8
(3,324 Views)
Thanks, setting the Y value to NaN worked just fine.  The "Ready for Data" was in there to make sure the initialization from a previous function was correct.
0 Kudos
Message 5 of 8
(3,315 Views)
All right, but why is it in the for-loop? As I indicated, it's not doing anything useful in there.
0 Kudos
Message 6 of 8
(3,310 Views)
So when its not ready, the while loop above it will stop executing.  Am I not understanding something correctly?
0 Kudos
Message 7 of 8
(3,302 Views)
You may be using it to stop the while loop, but you're not understanding my point: why do you have it inside the for-loop? It's not stopping the for-loop, so all you're doing is calculating the resulting boolean 100 times, and the only value that gets passed out of the for-loop is the last value. If you intend to stop the for-loop with the STOP button or the "Ready for Data" global, then you need to change the for-loop to a while loop.
0 Kudos
Message 8 of 8
(3,287 Views)