Numeric Time-based Integration
 public void PositiveIntegralTest1Step()
 {
     Integral t = new Integral();
     //Utility.AccurateWaitSeconds(1);
     t.Dt = 1.0;
     Assert.AreEqual(1, t.Get(1), 0.02);
 }
 public void NegativeIntegralTest1Step()
 {
     Integral t = new Integral();
     t.Dt = 1;
     //Utility.AccurateWaitSeconds(1);
     Assert.AreEqual(-1, t.Get(-1), 0.02);
 }
 public void PositiveIntegralTest10Step()
 {
     Integral t = new Integral();
     t.Dt = 0.1;
     for(int i = 0; i < 10; i++)
     {
         //Utility.AccurateWaitMilliseconds(100);
         Assert.AreEqual(0.1 * (i + 1), t.Get(1), 0.02);
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Creates a new instance of the SimplePID class
        /// </summary>
        /// <param name="p">Proportional constant</param>
        /// <param name="i">Integral Constant</param>
        /// <param name="d">Derivative Constant</param>
        /// <param name="min">Minimum allowed output of the PID loop</param>
        /// <param name="max">Maximum allowed output of the PID loop</param>
        public SimplePID(double p, double i, double d, double min, double max)
        {
            if(max < min)
                throw new ArgumentException($"Invalid Arguments: {max} Is less than {min}");

            m_kP = p; m_kI = i; m_kD = d;
            Max = max;
            Min = min;
            SetPoint = 0;
            m_d = new Derivative();
            m_i = new Integral();
            Continuous = false;
        }