コード例 #1
0
ファイル: PIDControllerA.cs プロジェクト: sycomix/Win10Bot
 /// <summary>
 /// The PID will either be connected to a DIRECT acting process (+Output leads
 /// to +Input) or a REVERSE acting process(+Output leads to -Input.)  we need to
 /// know which one, because otherwise we may increase the output when we should
 /// be decreasing.  This is called from the constructor.
 /// </summary>
 /// <param name="direction"></param>
 public void SetControllerDirection(PidDirection direction)
 {
     if (inAuto && direction != controllerDirection)
     {
         kp = (0 - kp);
         ki = (0 - ki);
         kd = (0 - kd);
     }
     controllerDirection = direction;
 }
コード例 #2
0
        /// <summary>
        /// The parameters specified here are those for for which we can't set up
        /// reliable defaults, so we need to have the user set them.
        /// </summary>
        /// <param name="Input"></param>
        /// <param name="Output"></param>
        /// <param name="Setpoint"></param>
        /// <param name="Kp"></param>
        /// <param name="Ki"></param>
        /// <param name="Kd"></param>
        /// <param name="ControllerDirection"></param>
        /// <param name="millis">time in milliseconds</param>
        public PIDControllerA(double Input, double Output, double Setpoint,
                              double Kp, double Ki, double Kd,
                              PidDirection ControllerDirection, ulong millis)
        {
            myOutput   = Output;
            myInput    = Input;
            mySetpoint = Setpoint;
            inAuto     = true;

            SetOutputLimits(0.0d, 255.0d, 255.0d);      //default output limit corresponds to the arduino pwm limits

            SampleTime = 100L;                          //default Controller Sample Time is 0.1 seconds

            SetControllerDirection(ControllerDirection);
            SetTunings(Kp, Ki, Kd);

            lastTime = (millis - SampleTime) > 0 ? (millis - SampleTime) : 0;
        }
コード例 #3
0
        /// <summary>
        /// The parameters specified here are those for for which we can't set up 
        /// reliable defaults, so we need to have the user set them.
        /// </summary>
        /// <param name="Input"></param>
        /// <param name="Output"></param>
        /// <param name="Setpoint"></param>
        /// <param name="Kp"></param>
        /// <param name="Ki"></param>
        /// <param name="Kd"></param>
        /// <param name="ControllerDirection"></param>
        /// <param name="millis">time in milliseconds</param>
        public PIDControllerA(double Input, double Output, double Setpoint,
            double Kp, double Ki, double Kd,
            PidDirection ControllerDirection, ulong millis)
        {
            myOutput = Output;
            myInput = Input;
            mySetpoint = Setpoint;
            inAuto = true;

            SetOutputLimits(0.0d, 255.0d, 255.0d);	//default output limit corresponds to the arduino pwm limits

            SampleTime = 100L;						//default Controller Sample Time is 0.1 seconds

            SetControllerDirection(ControllerDirection);
            SetTunings(Kp, Ki, Kd);

            lastTime = (millis - SampleTime) > 0 ? (millis - SampleTime) : 0;
        }
コード例 #4
0
 /// <summary>
 /// The PID will either be connected to a DIRECT acting process (+Output leads 
 /// to +Input) or a REVERSE acting process(+Output leads to -Input.)  we need to
 /// know which one, because otherwise we may increase the output when we should
 /// be decreasing.  This is called from the constructor.
 /// </summary>
 /// <param name="direction"></param>
 public void SetControllerDirection(PidDirection direction)
 {
     if (inAuto && direction != controllerDirection)
     {
         kp = (0 - kp);
         ki = (0 - ki);
         kd = (0 - kd);
     }
     controllerDirection = direction;
 }