LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Limiting Entries to Text file

Solved!
Go to solution

I am trying to limit the amount of entries that are written to a text file in my code. It currently writes 12-13 entries per second. I would like to limit that to an entry every second or even better 3 seconds.


Any ideas on a good way to do this?

0 Kudos
Message 1 of 3
(2,109 Views)

Without seeing any code it is difficult to see what you are currently doing. However, what you need is a parallel task which will handle your data logging which is separate from whatever is reading/generating the data. The logging task (the parallel loop used to actually write the data to the file) will be timed to only write data every 1 second (or whatever period you want). Since you didn't mention how you wanted to handle the data it is again difficult to say how you handle it in the logging loop. You didn't say if you wanted to write all of the data that was collected but write it at a slower frequency or if you are only interested in the data point at that time period. You would generally use a queue or notifier to send the data from your loop which is reading/generating the data and the loop that is logging it.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 2 of 3
(2,095 Views)
Solution
Accepted by topic author Nack

@Nack wrote:

I am trying to limit the amount of entries that are written to a text file in my code. It currently writes 12-13 entries per second. I would like to limit that to an entry every second or even better 3 seconds.


Without a better explanation of what you are attempting, and without seeing your code (the actual VI, not a picture of it), it is difficult to provide help.  I can think of several ways such a problem could arise, each with a different sort of answer, including:

  • You are running a While loop that does something and outputs each loop, but it's going "too fast".  Solution is to put a Wait (ms) with 1000 wired to the input to make it loop once/second.
  • You don't need to see every entry, only every 12th.  Use the While's Index, do an integer Quotient/Remainder Divide by 12, and write if the Remainder is 0.
  • Add some other form of "clock" to the loop to slow it down.
  • Use a Producer/Consumer Design Pattern to "export" the data and let the Consumer worry about whether or not to write it to the file (this is technically called "Passing the Buck" -- now the Consumer needs to "write slowly" or "throw away data").

What do you really want to do?  And, for curiosity, why (meaning why slow things down)?

 

Bob Schor

0 Kudos
Message 3 of 3
(2,067 Views)