function valid = check_servos(delta_theta_s1, delta_theta_s2) deadband = 8; %u_secs, from spec. sheet range_min = 600; %u_secs range_max = 2400; %u_secs delta_range = range_max - range_min; valid = 1; %set to 0 if we violate a constraint slope_s1 = delta_theta_s1/delta_range slope_s2 = delta_theta_s2/delta_range %convert deadband(u_sec) to deadband(degrees) theta_deadband_s1 = slope_s1*deadband *0.5; %degrees theta_deadband_s2 = slope_s2*deadband *0.5; %degrees range_min_err = abs(slope_s2*range_min - slope_s1*range_min); %degrees range_max_err = abs(slope_s2*range_max - slope_s1*range_max) %degrees %how much can we shift the line to correct error@range_max without %exceeding the deadbands at the range_min position translation = range_min_err + theta_deadband_s1 + theta_deadband_s2; %degrees %how far apart can both lines be(before translation) %without exceeding the deadbands acceptable_err = theta_deadband_s1 + theta_deadband_s2 + translation %degrees %find useable range limit, ie: where does range_max_err = acceptable_err %this number may be larger than the actual physical joint limit useable_range_max = acceptable_err / abs(slope_s2-slope_s1)%u_secs %this will tell you the range(degrees) for which both servos can be aligned so that they do not fight eachother %note: This range can be greater than the mechanical limit of the potentiometer useable_range_degrees = useable_range_max * min(slope_s1, slope_s2) - range_min * min(slope_s1, slope_s2) if (range_max_err < acceptable_err) display('match!') else display('invalid pair!') valid = 0; end