function cosWave(sp,I_offset,I_amp,T,dt)
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
end


