LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Write data to file at timed intervals

Hi,

 

I want write to a data file at specified intervals. I specify how many readings (N) and time intervals in an array. For example I might want the first 60 reading to be written every 1 second and the next 100 reading every 5 seconds and then the next 200 reading every 15 seconds and so on ........

 

I have written a program (attached) which I think will do exactly that but the problem is that I do not know how to convert it into a subVI like the ones found in Labview. By that I mean I know how to make a subVI in Labview but if I did so with the attached VI then I would have all those shift registers as inputs and outputs too. I was wondering if this could be converted into an sort of "independent" subVI (like the ones found in Labview) which will run inside a while loop with only the input array as the input and boolean as the output. I could then wire in the boolean to a case structure which has write to file subvi.

 

I ultimate intention is not to write to a output file every 1 or 5 or 15 seconds but collect around say 100 of those readings in an array and then and then write them to the file and then start collecting again ....... But for the moment, as I am only in the testing stage of my main program I will settle for writing to file every time the boolean is true.

 

Thanks. 

0 Kudos
Message 1 of 8
(3,708 Views)

Hey,

 

How are you plannig to extract the data from this VI if you desire only the boolean terminal as the output? The system should have an output terminal which gives out the value of the array, so that it can be used as desired. You may or may not wire the terminal if so desired.

 

If this is not what you are asking, I would appreciate if u can be a bit specific to your problem.

 

RJ

0 Kudos
Message 2 of 8
(3,702 Views)

What I had in mind with the posted VI was a VI which will send a true value in the boolean output as specified in the input array. In that way I can wire the boolean output to a case structure which will have write to file as the true case.

 

I think the VI works the way I want it to but if I convert that to a subVI the way I know how to do it, then I will have all those shift registers as input and output to the subVI. I was wondering if there was a way to do what the posted VI does but in a more elegant way say like the PID Setpoint Profile subvi in Labview, in which case I can only have the input array and the boolean output as the input and output. 

 

Regarding storing the data points and writing them in say 100 data points block to a input file. I haven't thought of that now but that is what I ultimately want to do because in that way my main VI can run a little faster.

 

Thanks

0 Kudos
Message 3 of 8
(3,674 Views)

Well,

 

You can define a local variable for the Variable for which you are using the shift register. This way, u will save the value into this local variable and then retrieve values from it in the next cycle, thus elimination the need for shift register.

 

I hope you know how to create a local variable.

 

RJ

0 Kudos
Message 4 of 8
(3,667 Views)

Rishabh,

 

A local variable is really not a wise choice.

 

Sharmaa,

 

Your code is to confusing and certainly would not work as a subVI since you need to stop the loop by clicking the front panel's Boolean. You could consider an Action Engine. A Producer/Consumer architecture would also work where you have a shift register there.

 

 

Message 5 of 8
(3,647 Views)

Hi sharmaa,

 

I agree with Dennis that your code is a bit complicated and because you require user interaction to stop the loop, it is not a good candidate for use in a SubVI. However, just taking what you wrote in your initial post, you could maybe do something like this:

 

17071i2C66AA951B5A0379

 

This may not be exactly what you're looking for, but it could be a good starting point.

 

Aaron P

National Instruments

Applications Engineer

http://www.ni.com/support

 

Message 6 of 8
(3,598 Views)

Thanks Dennis,

 

I knew my code wouldn't work as a subVI in the way it was written and I wanted to know how it could be turned into one that could be. After your comment I did some searching on Action Engine and and took a better look at how the Set Point Profile calculated its elaspsed time. Now I have a better idea. Thanks.

0 Kudos
Message 7 of 8
(3,577 Views)

Thanks Aaron,

 

I think I might be able to use this. I hadn't originally planned on having parallel loops (bit too complicated for a new programmer like me) but now looking at the simplicity of your solution I think I will give it a try. Thanks a lot.

0 Kudos
Message 8 of 8
(3,574 Views)