function [out1,out2,test_data,legend_string,ls_index,l_p,plt_index] = store_sig(kp,ki,kd,value,target,ls_index,legend_string,max_time,tacho_gain,p_index)

    write_volt(value,0);
    arr_volt=[];
    arr_rpm=[];
    time=[];
    index=1;
    t=tic;
    integral1=0;
    errprev=0;
    errprev2=0;
    total_prev=0;
    target_volt=scaling(0,360,0,4.81148,target);
    err=target_volt;
    for o=1:5
    [init_volt,init_deg]=read_sig(value);
    write_volt(value,0);
    end
    %t_init=0;
    while (toc(t)<=max_time)
        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);
        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*10;
        integral1=integral1+(err);
        fun_i=integral1*ki;
        fun_d=kd*(err-errprev);
        total=fun_p+fun_i+fun_d; 
        write_volt(value,total);
        index=index+1;
        errprev2=errprev;
        errprev=err;
        total_prev=total;
        
end
    str1=[strcat(strcat('Kp:',num2str(kp)), strcat('; Ki:',num2str(ki)) ,strcat('; Kd:',num2str(kd)))];
    legend_string{ls_index}=str1;
    ls_index=ls_index+1;
    out1=arr_deg;
    out3=arr_volt;
    out2=time;
    test_data=out_data(out2,out1);
    str0=[strcat('Ref.Volt: ',num2str(target), ' volt')];
    [legend_string,ls_index,l_p,plt_index] = plot_fig(out1,out2,kp,ki,kd,target,legend_string,max_time,(ls_index-1),str0,p_index);
    write_volt(value,0);
        
end