I would like an example of scpi over ethernet to Rigol Instruments using the instrument control toolbox.

84 vues (au cours des 30 derniers jours)
There seems to be a lack of any examples that show how to set up a communications session with Rigol Instruments such as their oscilloscopes, multimeters, arbgens, power supplies . . . using TCP/IP and SCPI commands.
  1 commentaire
Max
Max le 14 Nov 2023
I would like to set up a communication session with the Rigol DL3031A via the TCP/IP Simulink block. I was able to connect my computer to the device with MATLAB; however, I am facing issues when trying to establish the connection through the Simulink model. Any assistance to resolve this issue would be highly appreciated.

Connectez-vous pour commenter.

Réponses (2)

Benjamin Huth
Benjamin Huth le 19 Jan 2019
Modifié(e) : Benjamin Huth le 20 Jan 2019
I have several RIGOL instruments, and they all communicate over TCPIP on port 5555. I have the instrument control app, and once I found the port number, I can add the instruments with the port via the communications screen that is part of the app. This works for DM3068, DG4102, DS2202E, and DP832A. The following example is from the session log:
%% Instrument Connection
% Find a tcpip object.
obj1 = instrfind('Type', 'tcpip', 'RemoteHost', '192.168.1.62', 'RemotePort', 5555, 'Tag', '');
% Create the tcpip object if it does not exist
% otherwise use the object that was found.
if isempty(obj1)
obj1 = tcpip('192.168.1.62', 5555);
else
fclose(obj1);
obj1 = obj1(1);
end
% Connect to instrument object, obj1.
fopen(obj1);
%% Instrument Configuration and Control
% Communicating with instrument object, obj1.
data1 = query(obj1, '*IDN?');
I get back the instrument identifier string.
If you are not using the Test and Measurement GUI, then change the instrfind code to:
obj1 = tcpip('RemoteAddr',5555)

Vinod
Vinod le 8 Sep 2016
Modifié(e) : Vinod le 27 Sep 2019
I've not tested this as I don't have a Rigol scope, but you should be able to start from here:
% Initialize scope. The port number may be 5556 on certain scopes.
scopeInterface = tcpip('192.168.1.1',5555);
% Connect to instrument object, obj1.
fopen(scopeInterface);
% Stop data acquisition
fwrite(scopeInterface,':STOP')
% Grab the data from channel 1
fwrite(scopeInterface, ':WAV:POIN:MODE NOR');
fwrite(scopeInterface,':WAV:DATA? CHAN1');
data = fread(scopeInterface,9000,'uint8');
% Get the voltage scale
write(scopeInterface, ':CHAN1:SCAL?');
voltscale = str2double(fread(scopeInterface));
% And the voltage offset
fwrite(scopeInterface,':CHAN1:OFFS?');
voltoffset = str2double(fread(scopeInterface));
% Walk through the data, and map it to actual voltages
data = data * -1 + 255;
% Now, we know from experimentation that the scope display range is actually
% 30-229. So shift by 130 - the voltage offset in counts, then scale to
% get the actual voltage.
data = (data - 130.0 - voltoffset/voltscale*25) / 25 * voltscale;
% Get the timescale
fwrite(scopeInterface,':TIM:SCAL?')
timescale = str2double(fread(scopeInterface));
% Get the timescale offset
fwrite(scopeInterface,':TIM:OFFS?');
timeoffset = str2double(fread(scopeInterface));
% Start data acquisition again, and put the scope back in local mode
fwrite(scopeInterface,':RUN')
fwrite(scopeInterface,':KEY:FORC')
  3 commentaires
Ken Crandall
Ken Crandall le 9 Sep 2016
1. To resolve the error, I added the line fopen(scopeInterface) and at the end a fclose(scopeInterface). 2. Trying port 5555, there is a time-out error. 3. Trying port 5556, the error was "Connection refused"
So I'm still stuck. Any suggestions?
Vinod
Vinod le 13 Sep 2016
Sorry - I do not have a Rigol scope to test the code. The FOPEN is definitely needed.
The "Connection refused" could be because of a number of reasons
  1. A firewall or antivirus is blocking the connection. The firewall could be on the PC or on the scope
  2. The SCPI parser is not running on the scope
  3. Some network infrastructure is blocking the connection
  4. An incorrect IP address for the scope
I'd recommend getting in touch with Rigol tech support to see what needs to be done to have an external application connect to the scope over TCPIP

Connectez-vous pour commenter.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by