Class ServoTrim


  • public class ServoTrim
    extends Object
    Arduino defaults to a range of 544 to 2400. 1 to 2 ms is the minimum pulse range used in the R/C radio control industry. The maximum pulse range is a servo specific value that you must determine by either manufacture's datasheet information or by testing of the specific servo you are using.
    • Field Detail

      • DEFAULT

        public static final ServoTrim DEFAULT
        Default to 180 degree range, from 0.6ms to 2.4ms with 1.5ms centre
      • TOWERPRO_SG90

        public static final ServoTrim TOWERPRO_SG90
      • TOWERPRO_SG5010

        public static final ServoTrim TOWERPRO_SG5010
      • MG996R

        public static final ServoTrim MG996R
    • Constructor Detail

      • ServoTrim

        public ServoTrim​(int midPulseWidthUs,
                         int ninetyDegPulseWidthUs)
        Assumes 180 degree range of movement
        Parameters:
        midPulseWidthUs - Pulse width in microseconds corresponding to the centre position (90 degrees)
        ninetyDegPulseWidthUs - Pulse width in microseconds corresponding to a 90 degree movement in either direction
      • ServoTrim

        public ServoTrim​(int midPulseWidthUs,
                         int ninetyDegPulseWidthUs,
                         int rangePulseWidthUs)
      • ServoTrim

        public ServoTrim​(int midPulseWidthUs,
                         int ninetyDegPulseWidthUs,
                         int minPulseWidthUs,
                         int maxPulseWidthUs)
    • Method Detail

      • getMidPulseWidthUs

        public int getMidPulseWidthUs()
      • getMidPulseWidthMs

        public float getMidPulseWidthMs()
      • getNinetyDegPulseWidthUs

        public int getNinetyDegPulseWidthUs()
      • getNinetyDegPulseWidthMs

        public float getNinetyDegPulseWidthMs()
      • getMinPulseWidthUs

        public int getMinPulseWidthUs()
      • getMinPulseWidthMs

        public float getMinPulseWidthMs()
      • getMaxPulseWidthUs

        public int getMaxPulseWidthUs()
      • getMaxPulseWidthMs

        public float getMaxPulseWidthMs()
      • getMinAngle

        public int getMinAngle()
        Get the servo minimum angle in degrees where 90 degrees is the middle angle
        Returns:
        the servo minimum angle (90 degrees is central)
      • getMaxAngle

        public int getMaxAngle()
        Get the servo maximum angle in degrees where 90 degrees is the middle angle
        Returns:
        the servo maximum angle (90 degrees is central)
      • getMidAngle

        public int getMidAngle()
        Get the servo middle angle in degrees (constant - 90 degrees)
        Returns:
        the servo middle angle (a constant of 90 degrees)
      • convertPulseWidthUsToAngle

        public int convertPulseWidthUsToAngle​(int pulseWidthUs)
      • convertAngleToPulseWidthUs

        public int convertAngleToPulseWidthUs​(int angle)
      • convertPulseWidthMsToAngle

        public int convertPulseWidthMsToAngle​(float pulseWidthMs)
      • convertAngleToPulseWidthMs

        public float convertAngleToPulseWidthMs​(int angle)
      • convertValueToPulseWidthUs

        public int convertValueToPulseWidthUs​(float value)
      • convertPulseWidthUsToValue

        public float convertPulseWidthUsToValue​(int pulseWidthUs)