LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Header and data into an incrementing file

Solved!
Go to solution

Hi. I'm Sorin.
After a couple of days of thinking and trying, I decided to ask for help.
I need an idea or a sugestion or even a good exemplification for my problem. It's an easy think at first, but i encountered many issues.
I have a picture uploaded in here with my general idea.
I want to write header first and data at 1 line/sec in text file. But the file shouldn't exceed 65536 lines (excel limit), so I compute them, I put a condition for limitation, and after that thedata recorded must pass to the next file (e.g. file_1,file_2,file_3, and so on).
I tried in many ways, many loops, but not the result I aspected to be.
I mention that I have the modules:
-write header in file (write to spreadsheet file);
-write data in file (write to spreadsheet file);
-compute n lines in file (.vi)
So, if you please help me, just make a square or something in place of that modules. I made them separately and they all work fine.
I avoid goto function because I don't control it. Maybe that's why I failed.
A pseudo schematic with loops and wires would help me. I don't dare more.
Thanks.

 

0 Kudos
Message 1 of 10
(4,048 Views)

Hi Sorin,

see the attached example please.

 

Hope it helps.

Mike

0 Kudos
Message 2 of 10
(4,032 Views)

Very complicated that vi (data2file.vi). It's not working very well, I mean i must create path before I run, and it's not working as I expected, or as it should work.

But It gave me an idea with "format into string" and a shift register. I apply it, but it seems that i really need "goto" function. I know this function doesn't exist in Labview, and you have to simulate it with "state machine" algorithm, but again, i don't control it. Maybe someone has o good and simple  exemple with "goto" function.

Or another idea for my initial problem. Smiley Sad

Still thinking......

0 Kudos
Message 3 of 10
(3,997 Views)

Hi dsasorin,

i' sorry to hear that.

 

Can you please explain where your data come from? Do you read it from a hardware or do you have the entire data before starting the program?

What do you mean with goto? Why do you think you need it?

 

Mike

0 Kudos
Message 4 of 10
(3,994 Views)

My data came from hardware. I read it on serial port (VISA serial, Labview 8.5)  Works fine communication. The problem is with save data. I want to aquire non stop at 1 read / second / line. So I create path, with date included, and i want the file to be: file 1 and file 2 / per day. the next day will be at another path (the date changes) with file 1 and file 2 into. And so on.

- like this:

D:\data\04 feb 2009\file_01.txt

D:\data\04 feb 2009\file_02.txt

D:\data\05 feb 2009\file_01.txt

D:\data\05 feb 2009\file_02.txt

 

If you see my algorithm in the picture from the first post, you see goto function appears. This is what I need, or something similar with it.

I must exit from the small loop when condition is true, so the file changes with increment , and write in the new one.....

Oh, and I want header too, because I have 30 columns Smiley Tongue

0 Kudos
Message 5 of 10
(3,989 Views)

Hi dsasorin,

at which rate do you get your values. Do you already have a function to read your values?

 

You can use a queue to transfer your values from the acquire loop to the store loop. Place the "read queue element" at the position where i have the index array function in may example and remove the "10 ms". You should use "-1" for the timeout. If you get a lot of values, then you can first buffer them in a shiftregister and write 10 at ones.

 

Try to help.

Mike

0 Kudos
Message 6 of 10
(3,978 Views)

I use of course VISA read, write,open,close, etc  to handle serial communication, that's easy.

I aquire at 1 read /sec (for all values at one time), so I have 30 values at 1 sec.

Those I have to record in text file, non stop.

And for better management I decided to have a folder per day with files in it. Excel limits number of lines at 65536, an I must limit somehow this. (65536 lines or seconds= aprox. 18 hours, So I need 2 files per 24h.

I also record in file, date and hour to simplify read and management. 

 

0 Kudos
Message 7 of 10
(3,970 Views)

I don't know what it is , and how to handle queues.

I don't want to complicate the procedure. I want to keep it simple.

I though it's easy. Seems like I'm wrong.

Thankyou for helping me.

0 Kudos
Message 8 of 10
(3,968 Views)
Solution
Accepted by dsasorin

Dsasorin

 

check this out

 

 

0 Kudos
Message 9 of 10
(3,925 Views)

Thanks Huter !!!

I was able to make a vi preaty similar, I mean: loop,loop stop. But much complicated. I have now Date folder + Time file, and 65536 lines in file.Smiley Happy

 

Yours is very simple, because I don' have to count number in file, just increment .And I liked the way you create header, with a string array....good idea.Smiley Wink Mine was to concatenate 30 strings...Smiley Tongue.   ( my initial idea was to append data in file, and if I run the vi again, increment and number of lines were different.)

so thanks again, Huter !! Thanks NI.Smiley Very Happy 

 

Now i want to zip each file generated after it closes. Let's see.....

0 Kudos
Message 10 of 10
(3,901 Views)