function [test_results,legend_string,ls_index,l_p,plt_index]=open_loop(value,kp,target,max_time,legend_string,ls_index,plt_index,test_results)
format longG
result_volt_ol=[];
    result_rpm_ol=[];
    time_const_ol=[];
    motor_gain_ol=[];
    for i=1:length(kp)
        write_volt(value,0);
        arr_volt=[];
        time=[];
        index=1;
        target_volt=target;
        pause(10);
        t=tic;
        for o=1:5
            init_volt=read_sig(value);
            write_volt(value,0);
        end
        while (toc(t)<=max_time)
            t1=tic;
            arr_volt(index)=read_sig(value); %Read the tacho voltage
            drive_volt=kp(i)*(target_volt);   %Calculate the drive voltage
            time(index)=toc(t);  % Note the time using the timer
            if(drive_volt>7) %Check for extreme condition
                drive_volt=7;
            else if(drive_volt<-6)
                drive_volt=-6;
                end
            end
            index=index+1; %Increase the index for next set of calculations
            write_volt(value,drive_volt); % Write the drive voltage as calculated
        end
        result_volt_ol(i)=arr_volt(length(arr_volt));
        result_rpm_ol(i)=input('Enter the rpm value as you see in the unit:\n');
        str1=[(strcat('Drive:',num2str(kp(i)),' | Final Tacho Output:',num2str(result_volt_ol(i)),' | Final RPM:',num2str(result_rpm_ol(i))))];
        legend_string{ls_index}=str1;
        ls_index=ls_index+1;
        out1=arr_volt;
        out2=time;
        test_data=out_data(out2,out1);
        [time_const_ol(i),voltage]=calc_rise_time(out1,test_data);
        motor_gain_ol(i)=result_rpm_ol(i)/result_volt_ol(i);
        str0=[strcat('Ref.Volt: ',num2str(target), ' volt')];
        [legend_string,ls_index,l_p,plt_index]=plot_fig(out1,out2,kp,target,legend_string,max_time,(ls_index-1),str0,plt_index); %Plot the data stored in tim array and degree array through this function
        txt0=sprintf('Time Constant: %0.3f sec',time_const_ol(i));
        txt1=sprintf('Motor Gain:%.0f rpm/volt',motor_gain_ol(i));
        txt2=sprintf('Stady State Speed N, rpm: %.0f rpm ',result_rpm_ol(i));
        txt3=sprintf('Steady State Tacho Output, Vt: %.2f Volts ',result_volt_ol(i)); 
        str=sprintf('DC Speed Control Open Loop Response with Kp:%.2f',kp(i));
        plot_result(out1,out2,time_const_ol(i),voltage,str,txt0,txt1,txt2,txt3,max_time,target);
        write_volt(value,0);
        pause(10);
    end
    for i=1:length(kp)
    test_results=final_result(kp(i),result_volt_ol(i),result_rpm_ol(i),time_const_ol(i),motor_gain_ol(i),test_results);
    end
    
    
end