private void SetServoAngle(FX3Api.FX3PinObject Pin, double Angle, double Range, double PWMPeriodMs)
        {
            //Find duty cycle
            double dutyCycle = Angle / Range;
            //find PWM freq
            double freq = 1000 / PWMPeriodMs;

            //call PWM stop if needed
            if (m_FX3.isPWMPin(Pin))
            {
                m_FX3.StopPWM(Pin);
            }
            //start PWM signal generation
            m_FX3.StartPWM(freq, dutyCycle, Pin);
        }
示例#2
0
 /// <summary>
 /// Servo motor constructor
 /// </summary>
 /// <param name="ControlPin">The FX3 pin which drives the PWM input signal to the servo</param>
 public ServoMotor(FX3Api.FX3PinObject ControlPin)
 {
     m_pin      = ControlPin;
     m_period   = 20;
     m_maxAngle = 180;
 }