function [time_array]=triangle_to_delay(vmax1,vmax2,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
%vmax1 is the maximum velocity of the first direction in mm/s
%vmax2 is the maximum 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 traingle wave parameter
iteration_num=round(length/step_dist/4);

%create array of delay times
for i=1:iteration_num %foward path up portion
    vel=vmax1*i/iteration_num;
    time_array(i)=round(step_dist/vel*1000000);
end
for i=iteration_num+1:2*iteration_num %forward path down portion
    time_array(i)=round(time_array(2*iteration_num+1-i));
end
for i=2*iteration_num+1:3*iteration_num %backward path up portion
    vel=vmax2*(i-2*iteration_num)/iteration_num;
    time_array(i)=-round(step_dist/vel*1000000);
end
for i=3*iteration_num+1:4*iteration_num %backward path down portion
    time_array(i)=round(time_array(6*iteration_num+1-i));
end