function [time_array]=square_to_delay(vel1,vel2,length)
%square_to_delay allows you to input the parameters for a square wave, and
%   get out the delay times that represent a sine way to the PIC
%vel1 is the velocity of the first direction in mm/s
%vel2 is the velocity of the return in mm/s
%length is the length of travel in each direction in mm
%time_array is a signed output of delay times.  The magnitude represents
%   the direction, while the magnitude represents the magnitude of delay in
%   us

%set parameters
diameter=1.783*25.4; %mm
circumfrance=pi*diameter;
steps_per_rev=360/1.8;
step_dist=circumfrance/steps_per_rev;

%find square wave parameters
delay_time1=step_dist/vel1;
delay_time2=step_dist/vel2;
iteration_num=round(length/step_dist);

%create array of delay times
for i=1:iteration_num %forward path
    time_array(i)=round(delay_time1*1000000);
end
for i=iteration_num+1:2*iteration_num %backward path
    time_array(i)=round(-delay_time2*1000000);
end