LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

row of zeroes when using Write to Text File. vi

Hey everyone,

 

A little background first: We have a sensor mounted on a brace and it is sending data through Bluetooth to the PC. We need data to be sent indefinitely per se, or rather, till the athlete is out of range and/or for some bizarre reason connection is dropped. (We have a microSD card that kicks in to save the data in the event that happens so no worries there.)

 

Having that said, we have created this .vi that is supposed to plot the data in real-time as well as store it in a file for later review. The issue we are currently having is that apparently, the Write to Text File. vi likes to insert rows of zeroes at will from time to time, making our graph look a little crazy (see atachments below). 

 

Any suggestions as to how to remove the row of zeroes or at least have them not plotted?

 

Thanks in advance!

 

0 Kudos
Message 1 of 2
(2,232 Views)

It looks more like your file has blank lines in it.  When converting that data into an array, then the 0s will be filled in.

 

So let's look at how you are writing the file.  You are constantly opening it, setting the file pointer to the end, and then writing the data.  Let's make life a little easier on the program.  You only need to open the file once.  So move that output of the While loop.  Pass the file reference into the loop and to the Write Text File.  Now pass the reference from the Write Text File out of the While loop and close the file outside of the loop.  This way you won't have to keep opening the file and setting the file pointer.  The pointer will always be at the end of the file.

 

Now, you are constantly reading from another file for your graph.  If "Path 5" and "Path" are different, then your graph isn't being updated.  In fact, you are just wasting clock cycles and messing with your hard drive.  If they are the same file, then you have a race condition for which will be done first (write vs read).  Instead, parse the string and build your arrays inside of the loop for your graph.

 

Now to the reading of the serial port.  It looks like it is sending ASCII data that you just write straight to disk.  Which means it is using the End Of Line character.  So I recommend turning on the termination character.  Then you can get rid of the Bytes At Port node and just wire something like 100 to the number of bytes to read.  What this will do is make it so you read 1 line at a time.  That will make the parsing of the data really easy for your graph.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 2
(2,210 Views)