Dependents:   Snackotron Single_Axis NewCyroroProto AX12 ... more

Files at this revision

API Documentation at this revision

Comitter:
chris
Date:
Sun Apr 10 21:20:44 2011 +0000
Parent:
2:5ea99c37a2d7
Commit message:
Added baud rate function to the AX12 class

Changed in this revision

AX12.cpp Show annotated file Show diff for this revision Revisions of this file
AX12.h Show annotated file Show diff for this revision Revisions of this file
diff -r 5ea99c37a2d7 -r ced71d1b2558 AX12.cpp
--- a/AX12.cpp	Sun Apr 10 20:58:21 2011 +0000
+++ b/AX12.cpp	Sun Apr 10 21:20:44 2011 +0000
@@ -159,6 +159,21 @@
 }
 
 
+int AX12::SetBaud (int baud) {
+
+    char data[1];
+    data[0] = baud;
+
+#ifdef AX12_DEBUG
+    printf("Setting Baud rate to %d\n",baud);
+#endif
+
+    return (write(0xFE, AX12_REG_BAUD, 1, data));
+
+}
+
+
+
 // return 1 is the servo is still in flight
 int AX12::isMoving(void) {
 
diff -r 5ea99c37a2d7 -r ced71d1b2558 AX12.h
--- a/AX12.h	Sun Apr 10 20:58:21 2011 +0000
+++ b/AX12.h	Sun Apr 10 21:20:44 2011 +0000
@@ -32,6 +32,7 @@
 //#define AX12_DEBUG 0
 
 #define AX12_REG_ID 0x3
+#define AX12_REG_BAUD 0x4
 #define AX12_REG_CW_LIMIT 0x06
 #define AX12_REG_CCW_LIMIT 0x08
 #define AX12_REG_GOAL_POSITION 0x1E
@@ -86,6 +87,21 @@
      */
     int SetMode(int mode);
 
+    /** Set baud rate of all attached servos
+     * @param 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
+     */
+    int SetBaud(int baud);
+
+
     /** Set goal angle in integer degrees, in positional mode
      *
      * @param degrees 0-300