LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

incrementing filename after n entries

Solved!
Go to solution

hi all,

 

i have written a small vi and it does 90% of what i set out to do, but need to increment the filename to 000, 001, etc every 32000 entrys  (or 1000) , had a look at some vi's on this subject but not seeing what i really need. Ive done the hard bit but struggle to grasp how to integrate this change to my code,,, any assitance greatly welcomed,

 

 

 

and why does the first line output ok, then 2nd line has two time entries?

 

TIME,111,222,333,444,555,666
14/04/2014 13:37:18,9.338,9.337,9.343,9.346,9.342,9.349
14/04/2014 13:37:19,14/04/2014 13:37:29,9.338,9.337,9.343,9.348,9.342,9.344
14/04/2014 13:37:30,14/04/2014 13:37:40,9.338,9.337,9.355,9.351,9.350,9.357
14/04/2014 13:37:41,14/04/2014 13:37:51,9.338,9.337,9.343,9.348,9.345,9.344
14/04/2014 13:37:52,14/04/2014 13:38:02,9.336,9.337,9.343,9.351,9.342,9.346
14/04/2014 13:38:03,14/04/2014 13:38:13,9.333,9.330,9.343,9.346,9.350,9.351

 

Steven

0 Kudos
Message 1 of 5
(2,543 Views)
Solution
Accepted by topic author mgbglasgow

Hi, 

 

From what I can see, your upper loop will only run if it is true and your lower loop will not run unless it gets data from the upper loop. I think you'll need to grasp some LabVIEW fundamentals by taking up courses in your local area (contact NI branch near your location).

 

Here are the example which I have done based on your code:

Capture.JPG

 

What I have done is a simple producer consumer architecture whereby the upper loop is the producer and the lower loop is the consumer. You can read about producer consumer and queues here: 

http://www.ni.com/white-paper/3023/en/

http://digital.ni.com/public.nsf/allkb/DD7DBD9B10E3E537862565BC006CC2E4

 

The logic is that I only enqueue the data only if I want to (notice the case structure at the producer loop?). While at the consumer loop, I have created a state machine architecture. You can learn about state machine here:
http://www.ni.com/white-paper/3024/en/
http://www.ni.com/white-paper/7595/en/

 

At the consumer loop, there is a Get Queue Status which check the status of the queue. It tells me if I have, for this example, 10 data in my queue. If I do, I flush out that 10 data (it is in the form of an array of strings) from the queue and write them into the text file. By default, I have set the code to create and write 0.txt at your desktop (You can find out more about Get System Directory.vi here: http://digital.ni.com/public.nsf/allkb/09A6C28B6ED6795F862575EF0075C968). If 10 data has been writen to the text file, I will run the next state called "Check":

Capture2.JPG

 

In "Check" state, I will increment a number to create a new text to write on before heading to "Data" state which checks if I have 10 data to write on.

 

Understand the code does and hopefully you can make a much better coding than this. 

 

Hope that helps

 

Warmest regards,

Lennard.C 

 

Learning new things everyday...
Download All
Message 2 of 5
(2,468 Views)

that is a fantastic assist! i will get my head round that this weekend, i had heard of post mention consumer/producer, it makes sense.

 

I know my code was a cheat re wait in loop til all data was ready, but it worked.

 

I will impose those changes once i understand it fully,

 

many thanks

 

Steven

0 Kudos
Message 3 of 5
(2,452 Views)

that is a fantastic assist! i will get my head round that this weekend, i had heard of post mention consumer/producer, it makes sense.

 

I know my code was a cheat re wait in loop til all data was ready, but it worked.

 

I will impose those changes once i understand it fully,

 

many thanks

 

Steven

0 Kudos
Message 4 of 5
(2,452 Views)

Hi Steven,

 

You're most welcome. Smiley Wink

 

Cheers 

Lennard.C

Learning new things everyday...
0 Kudos
Message 5 of 5
(2,417 Views)