Rtos API example
« Back to documentation index
AX12 Class Reference
Servo control class, based on a PwmOut.
More...
#include <AX12.h >
Public Member Functions
AX12 (PinName tx, PinName rx, int ID, int baud=1000000)
Create an AX12 servo object connected to the specified serial port, with the specified ID.
int SetMode (int mode)
Set the mode of the servo.
int SetBaud (int baud)
Set baud rate of all attached servos.
int SetGoal (int degrees, int flags=0)
Set goal angle in integer degrees, in positional mode.
int SetCRSpeed (float speed)
Set the speed of the servo in continuous rotation mode.
int SetCWLimit (int degrees)
Set the clockwise limit of the servo.
int SetCCWLimit (int degrees)
Set the counter-clockwise limit of the servo.
int SetID (int CurrentID, int NewID)
Change the ID of a servo.
int isMoving (void)
Poll to see if the servo is moving.
void trigger (void)
Send the broadcast "trigger" command, to activate any outstanding registered commands.
float GetPosition ()
Read the current angle of the servo.
float GetTemp (void)
Read the temperature of the servo.
float GetVolts (void)
Read the supply voltage of the servo.
Detailed Description
Servo control class, based on a PwmOut.
Example:
#include "mbed.h"
#include "AX12.h"
int main() {
AX12 myax12 (p9, p10, 1);
while (1) {
myax12.SetGoal(0);
wait (2.0);
myax12.SetGoal(300);
wait (2.0);
}
}
Definition at line 71 of file AX12.h .
Constructor & Destructor Documentation
AX12
(
PinName
tx ,
PinName
rx ,
int
ID ,
int
baud = 1000000
)
Create an AX12 servo object connected to the specified serial port, with the specified ID.
Parameters:
pin tx pin
pin rx pin
int ID, the Bus ID of the servo 1-255
Definition at line 27 of file AX12.cpp .
Member Function Documentation
float GetPosition
(
void
)
Read the current angle of the servo.
Returns: float in the range 0.0-300.0
Definition at line 240 of file AX12.cpp .
Read the temperature of the servo.
Returns: float temperature
Definition at line 256 of file AX12.cpp .
Read the supply voltage of the servo.
Returns: float voltage
Definition at line 269 of file AX12.cpp .
Poll to see if the servo is moving.
Returns: true is the servo is moving
Definition at line 178 of file AX12.cpp .
Set baud rate of all attached servos.
Parameters:
mode 0x01 = 1,000,000 bps 0x03 = 500,000 bps 0x04 = 400,000 bps 0x07 = 250,000 bps 0x09 = 200,000 bps 0x10 = 115,200 bps 0x22 = 57,600 bps 0x67 = 19,200 bps 0xCF = 9,600 bp
Definition at line 162 of file AX12.cpp .
int SetCCWLimit
(
int
degrees )
Set the counter-clockwise limit of the servo.
Parameters:
Definition at line 129 of file AX12.cpp .
int SetCRSpeed
(
float
speed )
Set the speed of the servo in continuous rotation mode.
Parameters:
speed,-1.0 to 1.0 -1.0 = full speed counter clock wise 1.0 = full speed clock wise
Definition at line 87 of file AX12.cpp .
int SetCWLimit
(
int
degrees )
Set the clockwise limit of the servo.
Parameters:
Definition at line 110 of file AX12.cpp .
int SetGoal
(
int
degrees ,
int
flags = 0
)
Set goal angle in integer degrees, in positional mode.
Parameters:
degrees 0-300
flags,defaults to 0 flags[0] = blocking, return when goal position reached flags[1] = register, activate with a broadcast trigger
Definition at line 56 of file AX12.cpp .
int SetID
(
int
CurrentID ,
int
NewID
)
Change the ID of a servo.
Parameters:
If a servo ID is not know, the broadcast address of 0 can be used for CurrentID. In this situation, only one servo should be connected to the bus
Definition at line 148 of file AX12.cpp .
Set the mode of the servo.
Parameters:
mode 0 = Positional, default 1 = Continuous rotation
Definition at line 38 of file AX12.cpp .
Send the broadcast "trigger" command, to activate any outstanding registered commands.
Definition at line 186 of file AX12.cpp .