LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Basic serial example

Hi,

I'am currently using the basic serial read and write example, as attached, since the instrument I' am trying to communicate with has no labview driver. I am able to receive values from my instrument using the example my question is rather than just displaying the values how can I modify my block diagram to write the values directly into excel or matlab.

Thanks and regards

Marc
0 Kudos
Message 1 of 6
(3,336 Views)
The simplest thing to do is to use Write Characters to File to create text file. Append a CR at the end of each value written to get data in a single column or append a , or tab to get data in a single row with multiple columns. Excel (and Matlaab, I assume) can read either type of file. If you want to create a .xls file, then you have to use ActiveX. There is a shipping example called Write Table to Excel. While it is written to write a 2D array of data, it can be modified to write to a new cell (in either a new row or new column) pretty easily. There's also been a lot Excel examples posted to the forum. Do a search for Excel and take your pick.
0 Kudos
Message 2 of 6
(3,331 Views)
Hi,

yes I have found that basic excel example and it looks very useful however with reference to the basic serial example. Readings are taken from the instrument (over specified time) and displayed in the viewing window of the Vi front pannel. What do I replace the read string function block with in order to store each reading in a table which can then be output to excel or is it possible to automatically store a value to excel as it is read from the instrument.

Thanks and Regards

Marc
0 Kudos
Message 3 of 6
(3,319 Views)
You don't replace your VISA Read with anything. If you replace the VISA Read, you won't read any data from the serial port. You just wire the output to a function that writes to a file. A wire can go to multiple destinations. One goes to the string indicator and the other to a file write function. Here's your example modified to write to a text file. Provide a path to the file and each time it's called, it will append a new reading.
0 Kudos
Message 4 of 6
(3,293 Views)
Hi,

Yes thanks for that I can now write to a text document, however what do I need to do to continually write each new value measured by the instrument into the text file without having to re-run the Vi and enter a new file name each time.

thanks for your help

regards

Marc
0 Kudos
Message 5 of 6
(3,273 Views)
You can put a while loop around the code so it runs until you click a stop button and if you provide a file name into the file path control, you won't be prompted for a name each time it's run.

These are pretty basic things. I would recomend that you check into a class or take one of the tutorials that you can find at the LabVIEW Learning Center.
0 Kudos
Message 6 of 6
(3,241 Views)