static void Main(string[] args) { float Ts = 0.0002f; //Sample Time float Vs = 2f; //Gain Constant for Route float T1 = 0.005f; //Time Constant for Route Controller_I I1= new Controller_I(0f); Step Step1 = new Step(0.02f, 0.0f); PT1 PT11 = new PT1(Vs, T1); Simulator Simulator1 = new Simulator(I1,Step1,PT11); Optimize.Controller(PT11, I1); float[,] result = Simulator1.simulate(Ts, 300 * Ts); for (int i = 0; i < (result.Length/2); ++i) { Console.WriteLine("[ " + result[0,i] + " , " + result[1,i] + " ]"); } Console.Read(); }
/// <summary> /// Optimize a controller for a specific control loop /// </summary> /// <param name="control_loop">The PT1-control loop in your Schematic</param> /// <param name="controller">The I-controller you want to optimize</param> public static void Controller(PT1 control_loop, Controller_I controller) { controller._Ti = 2 * control_loop._Vs * control_loop._T1; controller.recalc_coefficients(); }