LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Append Column of Data to Text File

Solved!
Go to solution

Hello,

 

I am creating a program that will actuate a product on and off for many cycles and am measuring sensor values over time using DAQ Assistant and other express VIs to acquire and log data to a text file.  This text file contains a column for time and columns for sensor data.

 

I am also interested in the number of times a sensor value passes a certain threshold so I created code to detect this, which then increments a "cycle count" indicator in my program.

 

Is there a way to log this "cycle count" indicator along with my data log text file in another column that is synchronous in time?

 

Any feedback is appreciated. Thanks,

0 Kudos
Message 1 of 6
(2,840 Views)

(This is a LabVIEW programming question unrelated to "multifunction DAQ" and I will move moved it to the LabVIEW forum.)

 

To get better help, feel free to attach a simplified version of your code.

0 Kudos
Message 2 of 6
(2,830 Views)

I have attached my code.  Thanks,

0 Kudos
Message 3 of 6
(2,805 Views)

You could just merge the count with the dynamic data going to the "write to measurement file" express VI but might want to also output the count as an autoindexing array out of the FOR loop. This way it has the same number of points as the other channels.

 

Part of the problem is your use of express VIs and dynamic data, making the code too opaque. It might be easier using lower level functions. (Sorry, I don't have any DAQ tools installed here).

 

Some other problems:

  • Both loops try to use 100% of CPU when the booleans are false.
  • Upper loop
    • Shouldn't some of your shift register be initialized or carried also across the outer loop?
  • lower loop
    • Code cannot stop ever (just aborted) once the inner loop is running.
    • Why do you think you need to configure the same virtual channel over and over? Once before the loop is sufficient.
    • Instead of the two writes and the wait, you could use a single write in a FOR loop, autoindexing on a [T,F] array. You could even autoindex on two waits (500ms, 5000ms)
0 Kudos
Message 4 of 6
(2,799 Views)

thank you for your advice!!

 

Can you please clarify your last comment: 

  • Instead of the two writes and the wait, you could use a single write in a FOR loop, autoindexing on a [T,F] array. You could even autoindex on two waits (500ms, 5000ms)

Is there a way you can explain through code?

Thanks!

0 Kudos
Message 5 of 6
(2,788 Views)
Solution
Accepted by topic author ANON12345

@ANON12345 wrote:

there a way you can explain through code?


There are many variations, depending on how accurate the timing needs to be, but here's a comparison.

 

TFloop.png

Message 6 of 6
(2,768 Views)