from Serial control magnet power supply IPS-120 by Laurens Willems van Beveren
This code controls a superconducting magnet.

setMagnetHeatOnserial()
function setMagnetHeatOnserial()
%delete(instrfind)
%clear all;
%clc;

%global instr; 
s = serial('COM1');
s.Timeout = 2; % [s]
s.Terminator = 'CR'; % sets CR
sPause = 0.5;

fopen(s)

%cmd=['R18' 13];
%fprintf(s, cmd);

cmd=['R18'];
fprintf(s, cmd);
pause(sPause); % in units of sec
%fprintf(s, ['R18' 13]) % this reads the persistent field
%fprintf(s, ['V' 13]) % this sends a carriage return 
out = fscanf(s);
pause(sPause); % in units of sec
out % display the result back from the magnet
% set(s,'EOSCharCode',13); %carriage return
% set(s,'EOSMode','read');

%fprintf(s, ['$C3' 13]);  % remote mode and unlocked
%fprintf(s, ['$H1' 13]);  % switch heater ON

fprintf(s, ['$C3']);  % remote mode and unlocked
pause(sPause); % in units of sec
fprintf(s, ['$H1']);  % switch heater ON
pause(sPause); % in units of sec

fclose(s);

Contact us