close all
clear all


sp = serialport("COM4",4800);
I_offset = 0.5;
I_amp = 0.5;
T = 5;
dt = 0.1;
writeline(sp, "SYS:REM");

writeline(sp, "MODE CC");

writeline(sp, "LOAD ON");

t0 = tic; %start clock

while true
    t = toc(t0);

    %instantaneous current
    I = I_offset + I_amp*cos(2*pi*t/T);
    % send current to load
    writeline(sp, "CURR " + sprintf("%.3f", I));

    pause(dt);
end