A library for the AX-12+ servo using external ICs instead of the SerialHalf-Duplex class
A library based on the AX-12+ library but using external hardware to convert from full to half duplex as suggested in the AX-12 datasheet. The buffers and NOT gate need to connected as shown below.
Don't forget the pull-up resistor!
AX12.h
- Committer:
- ms523
- Date:
- 2011-08-07
- Revision:
- 1:1dd9cd18975d
- Parent:
- 0:d4af99baf76f
- Child:
- 2:3000c6778d1c
File content as of revision 1:1dd9cd18975d:
/* mbed AX-12+ Servo Library - External hardware version */ #ifndef MBED_AX12_H #define MBED_AX12_H #include "mbed.h" #define AX12_WRITE_DEBUG 0 #define AX12_READ_DEBUG 0 #define AX12_TRIGGER_DEBUG 0 #define AX12_DEBUG 0 #define AX12_REG_GOAL_POSITION 0x1E #define AX12_REG_MOVING_SPEED 0x20 #define AX12_REG_POSITION 0x24 #define TRANSMIT 1 #define RECEIVE 0 class AX12 { public: // define which pins are used, and the ID of this instance AX12(PinName tx, PinName rx, PinName dir, int ID); // methods for writing and reading registers int read(int ID, int start, int length, char* data); int write(int ID, int start, int length, char* data); // set goal angle in integer degrees int SetGoal(int degrees); float GetPosition(); // Get current angle, only valid 0-300 private : Serial _ax12; DigitalOut _dir; int _ID; }; #endif