close all
clear all


port = "COM5";
I_offset = 0.5;      
I_amp    = 0.5;      
T        = 0.5;      
dt       = 0.01;   
duration = 30;    
sp = serialport(port, 4800);
BK_EnableRemote(sp,1)
BK_SetCCMode(sp)
BK_LoadOn(sp,1)
t0 = tic;

while toc(t0) < duration
    t = toc(t0);   
    I = I_offset + I_amp*cos(2*pi*t/T);
    BK_SetCurrent(sp,I)
    

    fprintf("t = %.3f seconds\n", t);

    pause(dt);
end
fprintf("test complete");
