new ax12 lib
Fork of AX12 by
Revision 3:ced71d1b2558, committed 2011-04-10
- Comitter:
- chris
- Date:
- Sun Apr 10 21:20:44 2011 +0000
- Parent:
- 2:5ea99c37a2d7
- Child:
- 4:8350c0155571
- 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 |
--- 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) {
--- 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