function [gc, kc, ti] = ituning(kp, tp, theta, tc, type)

switch type
    case 1
        if tp/theta >= 1;
            n=0.94;
            ti = min(tp, 3*(tc+theta));
            kc = min(tp/(tc+theta)/kp, 3*(1-n)/kp+n*tp/(tc+theta)/kp);
            %kc = tp/(tc+theta)/kp*(0.9+0.1*exp(0.05*(theta-tp)/theta));
        elseif tp/theta < 1;
            ti = 0.15*(tc+theta)+0.7*tp;
            kc = tp/(tc+theta)/kp+0.2/kp*(1-tp/(theta));
        end
    case 0
               k = kp/tp;
            ti = 3*(tc+theta);
            kc = 0.94/(tc+theta)/k;
end

gc = controller(1,kc,ti);
end