public class TetrixServo extends java.lang.Object implements Servo
The HiTechnic Servo Controller allows setting of the PWM output from 0.75 - 2.25ms. Note that some servos may hit their internal mechanical limits at each end of this range causing them to consume excessive current and potentially be damaged.
Modifier and Type | Method and Description |
---|---|
float |
getAngle()
Returns the current servo angle as reverse calculated by the last call to
setAngle() . |
int |
getpulseWidth()
Get the current PWM pulse width for the servo.
|
void |
setAngle(float angle)
Sets the angle target of the servo.
|
void |
setpulseWidth(int microSeconds)
Set the PWM pulse width for the servo.
|
void |
setRange(int microsecLOW,
int microsecHIGH,
int travelRange)
Set the allowable pulse width operating range of this servo in microseconds and the total travel range.
|
public void setRange(int microsecLOW, int microsecHIGH, int travelRange) throws java.lang.IllegalArgumentException
The midpoint of the pulse width operating range should normally be 1500 microseconds so the range extents should reflect this.
This information must reflect the appropriate specifications and/or empirical characterization data of the specific
servo used for the setAngle()
method to be able to position the servo accurately.
setRange
in interface Servo
microsecLOW
- The low end of the servos response/operating range in microsecondsmicrosecHIGH
- The high end of the servos response/operating range in microsecondstravelRange
- The total mechanical travel range of the servo in degreesjava.lang.IllegalArgumentException
- if the range isn't within 750 and 2250setAngle(float)
public void setAngle(float angle)
setRange()
be called with the
correct parameters to establish proper ranging conversion to internal controller representation of servo position.setAngle
in interface Servo
angle
- Set servo angle in degrees.setRange(int, int, int)
,
getAngle()
public float getAngle()
setAngle()
. This is calculated from the
internal byte representation used (calculated by setAngle()
) to control the servo so the resolution will be
affected by ranging factors set with setRange()
The actual physical servo position may or may not be at the reported angle if mechanical limits have been reached.
getAngle
in interface Servo
setRange(int, int, int)
,
setAngle(float)
public void setpulseWidth(int microSeconds) throws java.lang.IllegalArgumentException
A servo pulse of 1500 microseconds (1.5 ms) width will typically set the servo to its "neutral" position. This is the "standard pulse servo mode" used by all hobby analog servos.
The HiTechic Servo Controller allows setting of the PWM output from 750 to 2250 microseconds with a step resolution
of 5.88 microseconds (1 byte is used to control the pulse width output) and this method will calculate and use the stepped
value closest to value passed in microSeconds
.
Note that some servos may hit their internal mechanical limits at each end of this range causing them to consume excessive current and potentially be damaged.
setpulseWidth
in interface Servo
microSeconds
- The pulse width time in microsecondsjava.lang.IllegalArgumentException
- if the range isn't within 750 and 2250setRange(int, int, int)
public int getpulseWidth()
Servo
getpulseWidth
in interface Servo