Code covered by the BSD License  

Highlights from
Powersupply EA PSI 900 VCP _USB Control Exsample

Powersupply EA PSI 900 VCP _USB Control Exsample

by

 

Control EA PSI 9000 Powersupply with Instrument Toolbox

G=Read_UIPnenn(G)
function G=Read_UIPnenn(G)
%% Lesen Unenn Inenn Pnenn

% StartDelimiter
Sendungstype=1;
Laenge =3;
SD_bin = uint8( bin2dec(...
    [ dec2bin(Sendungstype,2)...
      dec2bin(G.Cast,1)...
      dec2bin(G.Richtung,1)... 
      dec2bin(Laenge,4)...
    ] ));
% Objekt
OBJ_bin=uint8(2); % Unenn
% checksum
CS_bin = swapbytes( uint16(SD_bin) +uint16(G.DN_bin) +uint16(OBJ_bin) );
% Tellegramm Unenn
G.T_Unenn =uint8([...
            SD_bin G.DN_bin OBJ_bin  ...
            typecast(CS_bin, 'uint8') ]);
fwrite(G.s,G.T_Unenn);
Antw=fread(G.s,9,'uint8');
G.U_nenn =hexsingle2num([dec2hex(Antw(4),2) dec2hex(Antw(5),2) ...
          dec2hex(Antw(6),2) dec2hex(Antw(7),2)]);

      
% Objekt
OBJ_bin=uint8(3); % Inenn
% checksum
CS_bin = swapbytes( uint16(SD_bin) +uint16(G.DN_bin) +uint16(OBJ_bin) );
% Tellegramm Unenn
G.T_Inenn =uint8([...
            SD_bin G.DN_bin OBJ_bin  ...
            typecast(CS_bin, 'uint8') ]);
fwrite(G.s,G.T_Inenn);
Antw=fread(G.s,9,'uint8');
G.I_nenn =hexsingle2num([dec2hex(Antw(4),2) dec2hex(Antw(5),2) ...
          dec2hex(Antw(6),2) dec2hex(Antw(7),2)]);
      

      
% Objekt
OBJ_bin=uint8(4); % Pnenn
% checksum
CS_bin = swapbytes( uint16(SD_bin) +uint16(G.DN_bin) +uint16(OBJ_bin) );
% Tellegramm Unenn
G.T_Pnenn =uint8([...
            SD_bin G.DN_bin OBJ_bin  ...
            typecast(CS_bin, 'uint8') ]);
fwrite(G.s,G.T_Pnenn);
Antw=fread(G.s,9,'uint8');
G.P_nenn =hexsingle2num([dec2hex(Antw(4),2) dec2hex(Antw(5),2) ...
          dec2hex(Antw(6),2) dec2hex(Antw(7),2)]);

Contact us