コード例 #1
0
        private void InitPid(ulong millis)
        {
            double kp     = 0.0d;
            double ki     = 0.0d;
            double kd     = 0.0d;
            double limits = 300.0d;     // PID output limits, a single cycle correction max

            kp = 0.055d;
            //ki = 0.000001d;
            kd = 0.005d;

            pidA = new PIDControllerA(0, 0, 0, kp, ki, kd, PidDirection.DIRECT, millis);

            pidA.SetSampleTime(pidSampleTimeMs);

            pidA.SetOutputLimits(-limits, limits, 70);

            pidA.Initialize();
        }
コード例 #2
0
        private void CollectAndApplyPidControls()
        {
            try
            {
                double kp = double.Parse(textBoxKp.Text.Trim());
                double ki = double.Parse(textBoxKi.Text.Trim());
                double kd = double.Parse(textBoxKd.Text.Trim());

                double min = double.Parse(textBoxMin.Text.Trim());
                double max = double.Parse(textBoxMax.Text.Trim());
                //double integralMax = double.Parse(textBoxIntegralMax.Text.Trim());        // not used on pidA

                pidA.SetTunings(kp, ki, kd);
                pidA.SetOutputLimits(min, max);
            }
            catch (Exception ex)
            {
            }
        }