hisyam fs / Mbed 2 deprecated Test_all

Dependencies:   mbed ADS1115 StepperMotor SRF05 TPA81new

Embed: (wiki syntax)

« Back to documentation index

AX12 Class Reference

AX12 Class Reference

Servo control class for AX12 and other compatible Dynamixel servo. More...

#include <AX12.h>

Public Member Functions

 AX12 (PinName tx, PinName rx, PinName tx_ena, int ID, int baud)
 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.
void MultSetGoal (int degrees1, float speed1, int degrees2, float speed2, int degrees3, float speed3, int degrees4, float speed4, int degrees5, float speed5, int degrees6, float speed6, int degrees7, float speed7, int degrees8, float speed8, int degrees9, float speed9, int degrees10, float speed10, int degrees11, float speed11, int degrees12, float speed12, int degrees13, float speed13, int degrees14, float speed14, int degrees15, float speed15, int degrees16, float speed16, int degrees17, float speed17, int degrees18, float speed18)
 Set the position and speed of 18 servo from ID 1-18 at the same time.
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.
void ControlID (int ID)
 Change the ID of a servo controlled.
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.
void SetTorqueEnable (char val)
 Set torque enable of the servo.

Detailed Description

Servo control class for AX12 and other compatible Dynamixel servo.

Example:

 #include "mbed.h"
 #include "AX12.h"
 
 int main() {
   // The controlled servo has ID = 1
   // Connected to pin p9 as TX and p10 as RX
   // p11 used as toggle between TX and RX mode
   // The baudrate used to communicate with servo is 1 000 000
   AX12 myax12 (p9, p10, p11, 1, 1000000);

   while (1) {
       myax12.SetGoal(0);    // go to 0 degrees
       wait (2.0);
       myax12.SetGoal(300);  // go to 300 degrees
       wait (2.0);
   }
 }

Definition at line 70 of file AX12.h.


Constructor & Destructor Documentation

AX12 ( PinName  tx,
PinName  rx,
PinName  tx_ena,
int  ID,
int  baud 
)

Create an AX12 servo object connected to the specified serial port, with the specified ID.

Parameters:
pintx pin
pinrx pin
pintx enable, to switch between tx and rx
intID, the Bus ID of the servo 1-255
intbaud, the baudrate of the servo

Definition at line 27 of file AX12.cpp.


Member Function Documentation

void ControlID ( int  ID )

Change the ID of a servo controlled.

Parameters:
ID1-255

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 245 of file AX12.cpp.

float GetPosition ( void   )

Read the current angle of the servo.

Returns:
float in the range 0.0-300.0

Definition at line 303 of file AX12.cpp.

float GetTemp ( void   )

Read the temperature of the servo.

Returns:
float temperature

Definition at line 309 of file AX12.cpp.

float GetVolts ( void   )

Read the supply voltage of the servo.

Returns:
float voltage

Definition at line 315 of file AX12.cpp.

int isMoving ( void   )

Poll to see if the servo is moving.

Returns:
true is the servo is moving

Definition at line 265 of file AX12.cpp.

void MultSetGoal ( int  degrees1,
float  speed1,
int  degrees2,
float  speed2,
int  degrees3,
float  speed3,
int  degrees4,
float  speed4,
int  degrees5,
float  speed5,
int  degrees6,
float  speed6,
int  degrees7,
float  speed7,
int  degrees8,
float  speed8,
int  degrees9,
float  speed9,
int  degrees10,
float  speed10,
int  degrees11,
float  speed11,
int  degrees12,
float  speed12,
int  degrees13,
float  speed13,
int  degrees14,
float  speed14,
int  degrees15,
float  speed15,
int  degrees16,
float  speed16,
int  degrees17,
float  speed17,
int  degrees18,
float  speed18 
)

Set the position and speed of 18 servo from ID 1-18 at the same time.

Parameters:
degrees1..18The position of servo with ID 1..18
speed1..18The speed of servo with ID 1..18

Definition at line 93 of file AX12.cpp.

int SetBaud ( int  baud )

Set baud rate of all attached servos.

Parameters:
mode0x01 = 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 258 of file AX12.cpp.

int SetCCWLimit ( int  degrees )

Set the counter-clockwise limit of the servo.

Parameters:
degrees,0-300

Definition at line 233 of file AX12.cpp.

int SetCRSpeed ( float  speed )

Set the speed of the servo in continuous rotation mode.

Parameters:
speed,-1.0to 1.0 -1.0 = full speed counter clock wise 1.0 = full speed clock wise

Definition at line 199 of file AX12.cpp.

int SetCWLimit ( int  degrees )

Set the clockwise limit of the servo.

Parameters:
degrees,0-300

Definition at line 221 of file AX12.cpp.

int SetGoal ( int  degrees,
int  flags = 0 
)

Set goal angle in integer degrees, in positional mode.

Parameters:
degrees0-300
flags,defaultsto 0 flags[0] = blocking, return when goal position reached flags[1] = register, activate with a broadcast trigger

Definition at line 63 of file AX12.cpp.

int SetID ( int  CurrentID,
int  NewID 
)

Change the ID of a servo.

Parameters:
CurentID0-253
NewID0-253

If a servo ID is not know, the broadcast address of 254 (0xFE) can be used for CurrentID. In this situation, only one servo should be connected to the bus

Definition at line 252 of file AX12.cpp.

int SetMode ( int  mode )

Set the mode of the servo.

Parameters:
mode0 = Positional, default 1 = Continuous rotation

Definition at line 43 of file AX12.cpp.

void SetTorqueEnable ( char  val )

Set torque enable of the servo.

Definition at line 630 of file AX12.cpp.

void trigger ( void   )

Send the broadcast "trigger" command, to activate any outstanding registered commands.

Definition at line 271 of file AX12.cpp.