A library for the AX-12+ servo using external ICs instead of the SerialHalf-Duplex class

Embed: (wiki syntax)

« Back to documentation index

AX12 Class Reference

AX12 Class Reference

mbed AX-12+ Servo Library - External hardware version More...

#include <AX12.h>

Public Member Functions

 AX12 (Serial &bus, PinName dir, int ID)
 define which pins are used, and the ID of this instance
int read (int ID, int start, int length, char *data)
 Read info from the specified AX-12 register.
int write (int ID, int start, int length, char *data)
 Write info to the specified AX-12 register.
int SetGoal (int degrees)
 Sets the goal position for the servo.
float GetPosition ()
 Getss the current position for the servo.

Detailed Description

mbed AX-12+ Servo Library - External hardware version

Example:

 // Move a servo back and forth...
 #include "mbed.h"
 #include "Servo.h"
 
 Serial ax12_bus(p28,p27);
 AX12 my_ax12(ax12_bus, p29, 1);
 
 int main() {
     while(1) {
         my_ax12.SetGoal(0);      // move to 0
         wait(2);
         my_ax12.SetGoal(300);    // move to 300
         wait(2);
     }
 }

Definition at line 58 of file AX12.h.


Constructor & Destructor Documentation

AX12 ( Serial &  bus,
PinName  dir,
int  ID 
)

define which pins are used, and the ID of this instance

Definition at line 6 of file AX12.cpp.


Member Function Documentation

float GetPosition ( void   )

Getss the current position for the servo.

Returns:
current position

Definition at line 26 of file AX12.cpp.

int read ( int  ID,
int  start,
int  length,
char *  data 
)

Read info from the specified AX-12 register.

Parameters:
IDthe ID of the AX-12 servo
startthe address of the 1st register to be read
lengththe number of bytes to read
datawhere the read data is stored
Returns:
servo status

Definition at line 40 of file AX12.cpp.

int SetGoal ( int  degrees )

Sets the goal position for the servo.

Parameters:
degreesthe new target position
Returns:
error code

Definition at line 14 of file AX12.cpp.

int write ( int  ID,
int  start,
int  length,
char *  data 
)

Write info to the specified AX-12 register.

Parameters:
IDthe ID of the AX-12 servo
startthe address of the 1st register to be written to
lengththe number of bytes to write
datawhere the data to be written is stored
Returns:
servo status

Definition at line 89 of file AX12.cpp.