From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Lakeshore 331 Temperature Controller Remote Communication with MATLAB

I am trying to communicate with a Lakeshore 331 Temperature Controller via RS-232 serial interface. I would like to query the instrument's identification information and current temperature reading. I am using the following code, but the output comes back jarbled:

lakeshore331 = visa('ni','ASRL3::INSTR');
set(lakeshore331,'InputBufferSize',3000000,'Timeout',5.0);
fopen(lakeshore331);
iden = query(lakeshore331,'*IDN?')
temp = query(lakeshore331,'KRDG?')
fclose(lakeshore331);
delete(lakeshore331);
clear('lakeshore331');

Here's the output that results:

iden =
LÓCI,ÍOÄEL³³1E,³°¶°¶1,°³2³°1
Š
temp =
«7¹®¹¹8
Š

Do you have any suggestions for how to clean up the output?

0 Kudos
Message 1 of 4
(4,984 Views)
First, check the communication in MAX or a program such as Putty. It looks like you have a mismatch between the pc and the instrument. Your code is not configuring the port.
0 Kudos
Message 2 of 4
(4,955 Views)

I have checked that the computer can communicate via the serial port in both MAX and PuTTy. The "3" in lakeshore331 = visa('ni','ASRL3::INSTR'); sets the port number to COM3. The output is still coming in distorted from the instrument.

0 Kudos
Message 3 of 4
(4,789 Views)
The 3 in the asrl is obvious. What is not there is the settings for baud rate, parity, and the rest of the port configuration.

Since you seem confident that you have programmed It correctly and it works with MAX, it must be a problem with matlab so you should be asking Mathworks.
0 Kudos
Message 4 of 4
(4,760 Views)