function set_deg(value,target)
    write_volt(value,0);
    arr_volt=[];
    arr_deg=[];
    time=[];
    index=1;
    t=tic;
    kp=0.5;
    ki=0.001;
    kd=0.5;
    tacho_gain=-0.5;
    integral1=0;
    errprev=0;
    errprev2=0;
    total_prev=0;
    target_volt=scaling(0,360,0,4.81148,target);
    err=target_volt;
    for i=1:600
        t1=tic;
        [arr_volt(index),arr_deg(index)]=read_sig(value);
        tacho_volt=read_tacho(value);
        if(tacho_volt>10)
            tacho_volt=10;
        else if(tacho_volt<-10)
                tacho_volt=-10;
            end
        end
        tacho_volt=tacho_gain*tacho_volt;
        time(index)=toc(t);
        dt=toc(t1);
        err=(target_volt-arr_volt(index)-tacho_volt)*15;
        if(err>10)
            err=10;
        else if(err<-10)
                err=-10;
            end
        end
        %total=calc_PID(total_prev,err,errprev,errprev2,kp,ki,kd,dt);
        fun_p=err*kp;
        integral1=integral1+(err);
        fun_i=integral1*ki;
        fun_d=kd*(err-errprev);
        total=fun_p+fun_i+fun_d;
        if total > 2
            total = 2;
        else if total < -2
            total = -2;
            end
        end
        write_volt(value,total);
        index=index+1;
        errprev2=errprev;
        errprev=err;
        total_prev=total;
    end
    write_volt(value,0);
        
end