Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Read data from a RS 232 Serial port

Solved!
Go to solution

Hi, 

 

I am using a Particle measuring system instrument Lasair III 110 laser particle counter in my testing. 

The communication of this instrument is Serial Rs 232. 

I made a simple LabVIEW to control it for sampling and to collect the testing data and I have attached my code here. 

The serial command for starting sampling is "SS" and the serial command for transmitting the last data sample (i.e. latest time). is "TL".  Data is sent in standard CSV (comma separated value). The sampling time is 1 min. 

However, I cannot get any testing results from the "TL" command. It only gave me "SS" in the indicator of read buffer.

 

When I used "YAT"  for the command "SS" and "TL", I am able to get the latest data sample.

 

Really need help to figure out how to get the latest testing results and extract the useful test results to do some calculation by using "LabVIEW".

 

Thank you very much. 

 

 

 

0 Kudos
Message 1 of 11
(4,714 Views)

The byte count you want to read is the same as the data you have written.

Is that correct?

Is the data almost immediate available or do you get a timeout error.

Default the timeout is 10 seconds.

Is that enough?

I suggest to control the number of characters to read by a control on the frontpanel.

Or use an endcharacter in your case probably LF or CR.

 

greetings from the Netherlands
0 Kudos
Message 2 of 11
(4,707 Views)

Hi, Albert

Thank you very much  for your quick reply.

I don't think the byte count I want to read is the same as the data I have written.

What I have written is the command "SS" and the command "TL".

I don't think the data is immediate available. Because the "SS" command means "start sampling" and the sampling period is 1 minutes. The data is supposed to be available after 1 mins.

I did not get any timeout error or any error.

Please see the attachment for the results I got from "YAT".

I believe there is some "time" issue and endcharacter issue as well.

 

Thank you very much for your help.

 

Bingji

 

 

0 Kudos
Message 3 of 11
(4,680 Views)

The problem with the first VI you posted is that your VISA Read is only giving you 3 characters since that is what you told it to do.  From the the screen capture, it is evident that the instrument ends its messages with a Carriage Return and a Line Feed.  So you want to leave the defaults for the termination character.  Now tell the VISA Read to read more bytes than you expect in a message (I bounce between 50 and 100 depending on my mood and/or the device).  What this will do is allow the VISA Read to stop when it encounters the termination character.  This ensures you get your full message.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 11
(4,678 Views)

Hi, Crossrulz

 

Thank you very much for your help.

I modified the code and please see the attachment.

When I put 50 in the "byte control", the "read buffer" indicator gave me like "TL".

When I put 100 in the control, the indicator gave me like "°TL".

They are still not the results I want to get which are the fourth line in the screen capture I posted.

Please help with the issue.

 

Thanks a lot.

 

Bingji

 

0 Kudos
Message 5 of 11
(4,671 Views)

I am not sure if the buffer size is not big enough.

 

Therefore, I added the buffer size change VI before the Visa Read. Please see the attached code.

 

However, it still did not give me the results I wanted.

 

Thanks,

 

Bingji

0 Kudos
Message 6 of 11
(4,662 Views)

Bingji wrote:

I modified the code and please see the attachment.

When I put 50 in the "byte control", the "read buffer" indicator gave me like "TL".


This sounds like the instrument has an echo its protocol.  Try performing an extra read.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 7 of 11
(4,657 Views)

Yes.

It is said "All characters are echoed" in the instrument manual.

 

I will try it and thank you very much for your help.

 

Bingji

 

0 Kudos
Message 8 of 11
(4,649 Views)

Hi,

 

I have tried to add another Visa read and the code you suggested.

 

This time, the response has "OK".

 

I think it is the second line of the screen capture.

 

I want the forth line in the screen capture as the result.

 

Please help.

 

Thanks,

 

Bingji

0 Kudos
Message 9 of 11
(4,644 Views)
Solution
Accepted by Bingji

Bingji wrote:

I want the forth line in the screen capture as the result.


From what I can tell from that screen capture, it looks like you have to send another TL and then the results will come (after the echo).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 10 of 11
(4,639 Views)