LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how do i write multiple data types to a file?

Recently started programming in labview. From the ending of a sequence structure, I need to write a date stamp, start time stamp, an end time stamp, and a number of events. How do I write this MIXED data of string and integer to a file, I see there is quite a few file IO functions, but I'm not sure what to use, most only have ONE data input? So I am not sure what to do.
I also need this data to be written to the file without a prompt ie - write after the sequnence and continue onto another itteration and APPEND continuing data to the file.
0 Kudos
Message 1 of 6
(3,986 Views)
There are many ways to write multiple data types to file. I attached a sample vi, I'm sure there are other methods in this forum and in LabVIEW help. The "Format Into String" function can be replaced with other appropriate conversion function, in this case use "Concatenate String" function to combine the resulting strings. For the "Format Into String" function, select Edit Format String by right clicking on it to edit the format string input.
0 Kudos
Message 2 of 6
(3,986 Views)
Just a quick note that of the two suggestions in the other post, Format to String is the better of the two when you have a large number of different kinds of values because, it takes up less space and is easier to use because you can see in the format string exactly how the data is going to be put together--no guesswork.

In terms of the broader question of how to save the data, it depends to some extent on your application. If it's running rather slowly and will run for an extended period, you might want to write to the file after every IO cycle. If on the other hand the acquisitions are very fast, you can save the data and write to a file after the acquisition finishes.

Can you tell us a little more about your application?

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 3 of 6
(3,986 Views)
Thanks for the help, great example & was understandable... is there anyway I can void the prompt to open a file?

IOW, can I just make a blank text file and have it written to repeatedly without a prompt to open?

Thanks
0 Kudos
Message 4 of 6
(3,986 Views)
The application is a life cycle on a uv filter wheel..
A stepper motor driven wheel. Each position or step in not particularly fast and a sequence of motor steps in a determined manner makes up a "mode". There are 4 different modes, each mode lasting about 30 to 60 seconds, the modes are repeated determined on how many 'cycles' are requested. I need to archive each 'event' or step of the motor, plus a time stamp for the beginning of a mode, ending of a mode, total time of all the modes in a cycle, and total events in a cycle.

The time to move to each position is about 0.5 seconds.

I need to somehow record the individual mode events, time stamps and append them to an all inclusive archive of all the mode paramters within a cycle.

It is the data arch
iving that is the big overhead, the mode positioning was quite easy.

Scott
0 Kudos
Message 5 of 6
(3,986 Views)
With the high-level file IO routines that ship with LV, if you provide a path they won't ask for a location. You can also set up the logic such that it only asks the first time. See attachment.

Also you don't have to worry about creating an empty file. The default action has the effect of creating a new file or overwriting an existing one of the same name. Notice how I play with that programatically in the example.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 6 of 6
(3,986 Views)