LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

One data sample written to txt file

Solved!
Go to solution

I have a program that is monitoring 12 digital input (DI) levels.  A case structure inside a for loop indicates what level (high/low) the 12 DIs should be at.  IF any of the 12 input levels are not what they should be then all the levels are written to a text file with a time stamp and loop count.

 

My issue is with the loop count.  When a DI level is out of sync, reading incorrect level, and the write to file express VI is enabled three iterations and three data points are collected.  It would be prefered to have one iteration per cycle so I could use that as a counter of how many times the event has happened and use this counter to record one data point instead of three to a text file.

 

Attached is my .VI and .txt file for an example of what the data from a sample.

Download All
0 Kudos
Message 1 of 11
(3,067 Views)

I forgot to mention I am using a USB NI-6009.

0 Kudos
Message 2 of 11
(3,025 Views)
I really don't understand. You have 12 rows because that's how many bits you have and you have 3 columns because the build signal has 3 inputs - the iteration count and for some silly reason, the exact same digital data twice. Eliminate the duplicate digital data and you have two columns. Do you really want 12 columns of digital data and a 13th column for the iteration?
0 Kudos
Message 3 of 11
(3,016 Views)

I simplified and cleaned up your VI.

 

First of all, you had no way of stopping your VI other than the Abort button.  DON'T DO THAT.  You need to stop your VIs cleanly to make sure things get properly cleaned up.  So I added a stop button.

 

The FOR loops set to iterate once are useless.  I replaced one of them with a flat sequence structure.

 

There is no point in having two DAQ Assistants that are set up exactly the same.  Just have the read once outside of the case structure.  You can then do the comparisons inside the case structure.

 

Now for the writing of the data.  You need to format the data yourself.  So what I did was turn the Booleans into a 0 or 1, appended the index, and then used the Write To Spreadsheet File to write the data to the file.

 

See if this works better for you.


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
Message 4 of 11
(2,996 Views)

crossrulz,

 

Thank you for cleaning the code, it does operate much better and I learned a few things.  However, a main issue has to do with the Loop Count.  This VI is set to monitor an experiment that is running a mechanical device.  One cycle of the actual mechanical device is equivilent to one cycle through the sequence structure in LV.  However, the while loop in which the flat sequence is embeded increases 3 times per one flat sequence operation.

 

In other words, 1 flat sequence iterations = 3 while loop iterations

 

This is a problem since I want to know how many times the flat sequence, highlighted in red in the JPG below, has performed.

 

Does this make sense?

0 Kudos
Message 5 of 11
(2,992 Views)

Dennis,

 

I want to know which of the 12 digital data inputs is not what it should be as well as the 13th column for the iteration. Alternatively I could write it such that only the bit is incorrect is recorded, however, I would need to figure out how to identify which bit is incorrect.

 

The while loop is running three to four times for some reason and messing with my cycle count.  Is it possible to get a counter to increment only when the flat sequence occurs (as seen in crossrulz's revision of the VI)?

0 Kudos
Message 6 of 11
(2,987 Views)

It is difficult to emulate without your hardware but I'm not seeing a problem. Each iteration of the outer while causes the entire sequence structure to run. If the test fails, you write to file and then the loop iteration increments once and the sequence structure starts again. I don't see where you say something runs three times. What I do see in the last version is that if the indicator "Passed" is true, you write to the file. Don't you want to write to file when the Passed status is false?

Message 7 of 11
(2,977 Views)

Interesting.  I also thought it should be performing only one iteration.

 

----- said-----

...I don't see where you say something runs three times.....

 

-------END--------

 

To be clear The 'Loop Count' on the While Loop increments by 3-4 per one cycle of the flat sequence strucuture.  

This issue has happened more than once to me and would be nice to resolve.

 

----Setup----

I am running a USB NI-6009, running Windows 7 on a Dell Prescision M 6700 (2.8 GHz Intel Core i7 CPU, 16.0 GB RAM, 64 Bit OS).  Does it have something to do with the inexpensive 6009? 

----------------

 

0 Kudos
Message 8 of 11
(2,971 Views)

Again, I don't see the same thing. I see the loop count iterate once for every cycle of the sequence structure. Set some break points and use the probe tool.

0 Kudos
Message 9 of 11
(2,955 Views)

How do you know it is incrementing 3 times per read?  If you are referring to your file, then I would say that you are just passing every third iteration (nice catch on the Write to File case structure, Dennis).  Run with the highlight execution turned on and you will see what is really happening.


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 10 of 11
(2,943 Views)