Fork from Dynamixel AX12 Servo
for MX64 use
and not-finishi now
Dependents:
2014-Mx64
2014-mx64-test
Fork of
AX12
by Chris Styles
« Back to documentation index
MX64 Class Reference
Servo control class, based on a PwmOut.
More...
#include <MX64.h >
Public Member Functions
MX64 (PinName tx, PinName rx, int ID, int baud=1000000)
Create an MX64 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 SetGoalSpeed (int degrees, int speed, 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 "MX64.h"
int main() {
MX64 mymx64 (PTD2, PTD3, 1);
while (1) {
mymx64.SetGoal(0);
wait (2.0);
mymx64.SetGoal(360);
wait (2.0);
}
}
Definition at line 73 of file MX64.h .
Constructor & Destructor Documentation
MX64
(
PinName
tx ,
PinName
rx ,
int
ID ,
int
baud = 1000000
)
Create an MX64 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 MX64.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 276 of file MX64.cpp .
Read the temperature of the servo.
Returns: float temperature
Definition at line 292 of file MX64.cpp .
Read the supply voltage of the servo.
Returns: float voltage
Definition at line 305 of file MX64.cpp .
Poll to see if the servo is moving.
Returns: true is the servo is moving
Definition at line 214 of file MX64.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 198 of file MX64.cpp .
int SetCCWLimit
(
int
degrees )
Set the counter-clockwise limit of the servo.
Parameters:
Definition at line 165 of file MX64.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 123 of file MX64.cpp .
int SetCWLimit
(
int
degrees )
Set the clockwise limit of the servo.
Parameters:
Definition at line 146 of file MX64.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 MX64.cpp .
int SetGoalSpeed
(
int
degrees ,
int
speed ,
int
flags = 0
)
Set goal angle in integer degrees, in positional mode.
Parameters:
degrees 0-300
speed 0-100
flags,defaults to 0 flags[0] = blocking, return when goal position reached flags[1] = register, activate with a broadcast trigger
Definition at line 88 of file MX64.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 184 of file MX64.cpp .
Set the mode of the servo.
Parameters:
mode 0 = Positional, default 1 = Continuous rotation
Definition at line 38 of file MX64.cpp .
Send the broadcast "trigger" command, to activate any outstanding registered commands.
Definition at line 222 of file MX64.cpp .