Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Formatting String Read from Serial Instrument

I have a Thermo Orion 4-Star pH/Conductivity meter and am communicating with it, for now, with the basic serial example provided with LabView 7.1.  It has been edited so that whatever is read is saved to Excel.  When I type the command to print a measurement, the meter prints a long string: 
112,123456,28,5,06-29-2004 09:05:27,-183.3,mV,10.45,pH,25.0,C,3,2.  All I am interested in reading, however, are the pH and Cond. (
10.45,pH,25.0,C).  How can I format the printed string so just those values are read and is there a way to insert a CR between the values so they show up in different cells once exported to Excel?
0 Kudos
Message 1 of 6
(4,034 Views)

You just need to use the Spreadsheet String to Array function and then index out the elements of the array. Here's an example that uses that and some other improvements. I'm assuming you want to do this repeatedly so you should have a while loop. Do not use run continuous mode.

I don't understand your last comment though about the extra CR. The way the strings were being written before with a comma between values, they would each show up in a different cell when you imported a csv file in Excel.

Message Edited by Dennis Knutson on 07-23-2007 09:43 AM

0 Kudos
Message 2 of 6
(4,026 Views)
Thanks very much,  Dennis.  After a few tweaks, I am reading exactly what I want to read.  As a last adjustment, how can I edit the VI you provided so that the pH & Cond. (uS/cm) readings are in columns side-by-side (A & B) so I can easily set up graphs and such?  The readings are still separated by commas.




0 Kudos
Message 3 of 6
(4,007 Views)
The only reason they are not in separate columns is that in Excel, you did not specify to use a comma as a column separator when you imported the file. If you save a text file with the .csv (comma separated values) extension, Excel will automatically assume the comma and everything will be just fine. Otherwise, you will get the text import wizard and in step 2, you specify the delimiter.
0 Kudos
Message 4 of 6
(4,002 Views)
I now have a VI that reads from two different instruments (Ohaus balance and Thermo pH meter) and writes to one excel file.  The format of the excel file, however is still not favorable.  pH and conductivity are printed side by side, as they should be, then the weight is printed in a different row.  How can I fix this formatting problem?


0 Kudos
Message 5 of 6
(3,984 Views)
You have two separate loops and two separate write functions. You can't have the two separate write functions. The easiest thing for you do do is just have a single loop and combine the results and use one write file.
0 Kudos
Message 6 of 6
(3,981 Views)