Package com.diozero.api
Class ServoTrim
- java.lang.Object
-
- com.diozero.api.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 Summary
Fields Modifier and Type Field Description static ServoTrim
DEFAULT
Default to 180 degree range, from 0.6ms to 2.4ms with 1.5ms centrestatic int
DEFAULT_90_DELTA_US
static int
DEFAULT_MID_US
static ServoTrim
MG996R
static int
MID_ANGLE
static ServoTrim
TOWERPRO_SG5010
static ServoTrim
TOWERPRO_SG90
-
Constructor Summary
Constructors Constructor Description ServoTrim(int midPulseWidthUs, int ninetyDegPulseWidthUs)
Assumes 180 degree range of movementServoTrim(int midPulseWidthUs, int ninetyDegPulseWidthUs, int rangePulseWidthUs)
ServoTrim(int midPulseWidthUs, int ninetyDegPulseWidthUs, int minPulseWidthUs, int maxPulseWidthUs)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description float
convertAngleToPulseWidthMs(int angle)
int
convertAngleToPulseWidthUs(int angle)
int
convertPulseWidthMsToAngle(float pulseWidthMs)
int
convertPulseWidthUsToAngle(int pulseWidthUs)
float
convertPulseWidthUsToValue(int pulseWidthUs)
int
convertValueToPulseWidthUs(float value)
int
getMaxAngle()
Get the servo maximum angle in degrees where 90 degrees is the middle anglefloat
getMaxPulseWidthMs()
int
getMaxPulseWidthUs()
int
getMidAngle()
Get the servo middle angle in degrees (constant - 90 degrees)float
getMidPulseWidthMs()
int
getMidPulseWidthUs()
int
getMinAngle()
Get the servo minimum angle in degrees where 90 degrees is the middle anglefloat
getMinPulseWidthMs()
int
getMinPulseWidthUs()
float
getNinetyDegPulseWidthMs()
int
getNinetyDegPulseWidthUs()
-
-
-
Field Detail
-
MID_ANGLE
public static final int MID_ANGLE
- See Also:
- Constant Field Values
-
DEFAULT_MID_US
public static final int DEFAULT_MID_US
- See Also:
- Constant Field Values
-
DEFAULT_90_DELTA_US
public static final int DEFAULT_90_DELTA_US
- See Also:
- Constant Field Values
-
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)
-
-