From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Writing to file every n iterations, yet unwanted data still present

Hello,

 

I have a vi (see attached) that writes data to a file every n iterations. If the iteration is a multiple of n, the data are sent to a file; if not, to a dummy array. When I open my data file, I find the data I sent every n iteration but I also find 0's in all the rows that do not contain data from n iterations.

 

Example output if n = 5:

 

0.1

0

0

0

0

0.2

0

0

0

0

 

Could someone help me understand why the memory for these unwanted data points is allocated to my data file?

 

Thank you. 

0 Kudos
Message 1 of 4
(2,315 Views)

You have to wire a data value for every part of your case statement.  You left them unwired which defaults to "Use Default If Unwired." [Note:  The default value for the "Double" data type is 0.0.  This explains why you are seeing the zeroes in your output].  Right click the tunnels out of the case structure to disable this feature.  Then you will be forced to connect data to all cases and prevent these unseen semantic errors.

 

Read more on it here: http://zone.ni.com/reference/en-XX/help/371361H-01/lvhowto/input_output_tunnels/

 

You can try manually building your own array without using the case structure or auto-indexing for your for-loop outputs.  Instead, just add an element to an array within the case structure if it meets your criteria.  Does that make sense?  There may be a more elegant way to go about this, but this is the first that popped into my head and should be pretty easy to implement.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If someone helped you out, please select their post as the solution and/or give them Kudos!
0 Kudos
Message 2 of 4
(2,307 Views)

I can't see your code due to newer version but can you use a conditional auto-indexing tunnel?  Right-click on the tunnel and make sure conditional is selected and then provide the conditions.

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 3 of 4
(2,285 Views)

You definately want the conditional output terminals here.  Since you are using LabVIEW 2013, you are good to go with them.  Just right-click on your output tunnels and select the Tunnel Mode->Conditional.  You will see a little ? appear with the tunnel.  Wire in your write condition there.  With these, you don't need your little case structure either.


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 4 of 4
(2,246 Views)