LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to save data from COM port to file?

Solved!
Go to solution

hello everyone,

                      can anyone please tell me how to save COM port data to file? I am transferring 1 byte from serial port... attached is the image of the vi... very basic.

I would like to save the data in a tabular format... i mean, 1st data --> tab  2nd data--> tab 3rd data --> tab

 

and so on... can anyone help?

Now on LabVIEW 10.0 on Win7
0 Kudos
Message 1 of 38
(7,110 Views)

Basically what you are doing now, except you aren't reading one byte at a time, but however many bytes happen to be at the serial port.  Just read one byte at a time and concatenate a tab character to it then send it to the File Write.

0 Kudos
Message 2 of 38
(7,093 Views)

First you must create a reference for your file by using the open/create/replace function in the files palette before you can write data to it.  Next, why so high a baud rate on your Com port.  Will your Com port handle that speed?  Just curious.  I haven't seen any that will go beyond 115K unless you use a USB converter.  You might get 230K out of it in that case, but not reliably.  Double check your settings.

Your usage of file functions is completely off.  You are trying to write the report headers to a text file, which is fine, but then you are writing the data to a binary file, using the same reference no less.  Pick one or the other.  Do you want to be able to view the file with an editor of some sort?  If yes, use a text file, but don't mix and match.  Text files are OK for data collection and raw data, but you may want to use ms excel for generating proper reports if this is your aim.  Refer to the Report Generation Toolkit (I don't know if LV 8.0 has these features or not.  I doubt it).

As far as the organization of your data, that will depend on the format of the data coming from the Com port.

-----------------------------------------------------------------------------------------
Reese, (former CLAD, future CLD)

Some people call me the Space Cowboy!
Some call me the gangster of love.
Some people call me MoReese!
...I'm right here baby, right here, right here, right here at home
0 Kudos
Message 3 of 38
(7,092 Views)

MoReese,

 

Writing to a binary file with string data is the same thing as writing to a text file with string data.  Try it.Smiley Wink

0 Kudos
Message 4 of 38
(7,089 Views)

Raven's Fan, I shall definately try out that... Another thing, I would like to pass on system time to the microcontroller unit .. i tried using Get Time/Date String.vi; sent data to uC and

received data back to the LABVIEW vi, and I observed that the uC does pass the date time string correctly...

but, i cannot understand how to save the data on the uC. Do I have to give a time format string (%c) in the Get Time/Date String.vi and check the same in uC code/??

 

@MoReese, yes i am using a UART-USB converter, hence data transfer at such a high speed. 

Now on LabVIEW 10.0 on Win7
0 Kudos
Message 5 of 38
(7,081 Views)

I don't understand your question.  What does saving a date/time on a microcontroller have to do with saving data to a file using LabVIEW?

0 Kudos
Message 6 of 38
(7,077 Views)

I know, saving to file has nothing to do with date time string transfer...

 

Its a new question, just wanted to ask..

Now on LabVIEW 10.0 on Win7
0 Kudos
Message 7 of 38
(7,075 Views)

Have you created a program on the µC, like in assembler or C, that can handle the rs-232 data transfer? If you have, then it's just a matter of writing to serialport instead of reading from serial port in LabVIEW.

Regards,
Even
_________________________________
Certified LabVIEW Associate Developer

Automated Test Developer
Topro AS
Norway
0 Kudos
Message 8 of 38
(7,055 Views)

Ravens Fan,

 

"Writing to a binary file with string data is the same thing as writing to a text file with string data.  Try it."

 

I did try it and it works as you say; with the exception of a control character added to the binary string, it's readable.  I have little experience with binary files in LabView and did not realize it excepts variant data.  Thanks for the lesson.

-----------------------------------------------------------------------------------------
Reese, (former CLAD, future CLD)

Some people call me the Space Cowboy!
Some call me the gangster of love.
Some people call me MoReese!
...I'm right here baby, right here, right here, right here at home
Message 9 of 38
(7,039 Views)

There is an input at the top called "Prepend array or string size" which by default is true.  If you wire a false constant to that like in CrackJack's image, you won't get those extra characters.

0 Kudos
Message 10 of 38
(7,030 Views)