Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed ros_lib_kinetic
Mx28.h
00001 /* 00002 How Dynamixel work can be found 00003 -------------------------------- 00004 Robotis e-Manual 00005 http://support.robotis.com 00006 00007 Overview of Communication 00008 http://support.robotis.com/en/product/dynamixel/dxl_communication.htm 00009 00010 Kind of Instruction 00011 http://support.robotis.com/en/product/dynamixel/communication/dxl_instruction.htm 00012 00013 Instruction Packet & Status Packet (Return Packet) 00014 http://support.robotis.com/en/product/dynamixel/communication/dxl_packet.htm 00015 00016 Control Table 00017 http://support.robotis.com/en/product/dynamixel/mx_series/mx-28.htm 00018 00019 */ 00020 00021 #ifndef Mx28_h 00022 #define Mx28_h 00023 00024 //------------------------------------------------------------------------------------------------------------------------------- 00025 // define - Dynamixel Hex code table 00026 //------------------------------------------------------------------------------------------------------------------------------- 00027 // EEPROM AREA 00028 #define EEPROM_MODEL_NUMBER_L 0x00 00029 #define EEPROM_MODEL_NUMBER_H 0x01 00030 #define EEPROM_VERSION 0x02 00031 #define EEPROM_ID 0x03 00032 #define EEPROM_BAUD_RATE 0x04 00033 #define EEPROM_RETURN_DELAY_TIME 0x05 00034 #define EEPROM_CW_ANGLE_LIMIT_L 0x06 00035 #define EEPROM_CW_ANGLE_LIMIT_H 0x07 00036 #define EEPROM_CCW_ANGLE_LIMIT_L 0x08 00037 #define EEPROM_CCW_ANGLE_LIMIT_H 0x09 00038 #define EEPROM_LIMIT_TEMPERATURE 0x0B 00039 #define EEPROM_LOW_LIMIT_VOLTAGE 0x0C 00040 #define EEPROM_HIGN_LIMIT_VOLTAGE 0x0D 00041 #define EEPROM_MAX_TORQUE_L 0x0E 00042 #define EEPROM_MAX_TORQUE_H 0x0F 00043 #define EEPROM_RETURN_LEVEL 0x10 00044 #define EEPROM_ALARM_LED 0x11 00045 #define EEPROM_ALARM_SHUTDOWN 0x12 00046 // RAM AREA 00047 #define RAM_TORQUE_ENABLE 0x18 00048 #define RAM_LED 0x19 00049 #define RAM_DERIVATIVE_GAIN 0x1A 00050 #define RAM_INTERGRAL_GAIN 0x1B 00051 #define RAM_PROPORTIONAL_GAIN 0x1C 00052 #define RAM_GOAL_POSITION_L 0x1E 00053 #define RAM_GOAL_POSITION_H 0x1F 00054 #define RAM_GOAL_SPEED_L 0x20 00055 #define RAM_GOAL_SPEED_H 0x21 00056 #define RAM_TORQUE_LIMIT_L 0x22 00057 #define RAM_TORQUE_LIMIT_H 0x23 00058 #define RAM_PRESENT_POSITION_L 0x24 00059 #define RAM_PRESENT_POSITION_H 0x25 00060 #define RAM_PRESENT_SPEED_L 0x26 00061 #define RAM_PRESENT_SPEED_H 0x27 00062 #define RAM_PRESENT_LOAD_L 0x28 00063 #define RAM_PRESENT_LOAD_H 0x29 00064 #define RAM_PRESENT_VOLTAGE 0x2A 00065 #define RAM_PRESENT_TEMPERATURE 0x2B 00066 #define RAM_REGISTER 0x2C 00067 #define RAM_MOVING 0x2E 00068 #define RAM_LOCK 0x2F 00069 #define RAM_PUNCH_L 0x30 00070 #define RAM_PUNCH_H 0x31 00071 #define RAM_PRESENT_CURRENT_L 0x44 00072 #define RAM_PRESENT_CURRENT_H 0x45 00073 00074 00075 00076 //------------------------------------------------------------------------------------------------------------------------------- 00077 // Instruction commands Set 00078 //------------------------------------------------------------------------------------------------------------------------------- 00079 #define COMMAND_PING 0x01 00080 #define COMMAND_READ_DATA 0x02 00081 #define COMMAND_WRITE_DATA 0x03 00082 #define COMMAND_REG_WRITE_DATA 0x04 00083 #define COMMAND_ACTION 0x05 00084 #define COMMAND_RESET 0x06 00085 #define COMMAND_SYNC_WRITE 0x83 00086 00087 00088 //------------------------------------------------------------------------------------------------------------------------------- 00089 //Instruction packet lengths 00090 #define READ_ONE_BYTE_LENGTH 0x01 00091 #define READ_TWO_BYTE_LENGTH 0x02 00092 #define RESET_LENGTH 0x02 00093 #define PING_LENGTH 0x02 00094 #define ACTION_LENGTH 0x02 00095 #define SET_ID_LENGTH 0x04 00096 #define SET_BD_LENGTH 0x04 00097 #define SET_RETURN_LEVEL_LENGTH 0x04 00098 #define READ_TEMP_LENGTH 0x04 00099 #define READ_POS_LENGTH 0x04 00100 #define READ_LOAD_LENGTH 0x04 00101 #define READ_SPEED_LENGTH 0x04 00102 #define READ_VOLT_LENGTH 0x04 00103 #define READ_REGISTER_LENGTH 0x04 00104 #define READ_MOVING_LENGTH 0x04 00105 #define READ_LOCK_LENGTH 0x04 00106 #define LED_LENGTH 0x04 00107 #define SET_HOLDING_TORQUE_LENGTH 0x04 00108 #define SET_MAX_TORQUE_LENGTH 0x05 00109 #define SET_ALARM_LENGTH 0x04 00110 #define READ_LOAD_LENGTH 0x04 00111 #define SET_RETURN_LENGTH 0x04 00112 #define WHEEL_LENGTH 0x05 00113 #define SERVO_GOAL_LENGTH 0x07 00114 #define SET_MODE_LENGTH 0x07 00115 #define SET_PUNCH_LENGTH 0x04 00116 #define SET_PID_LENGTH 0x06 00117 #define SET_TEMP_LENGTH 0x04 00118 #define SET_VOLT_LENGTH 0x05 00119 #define SYNC_LOAD_LENGTH 0x0D 00120 #define SYNC_DATA_LENGTH 0x02 00121 00122 00123 //------------------------------------------------------------------------------------------------------------------------------- 00124 // Specials 00125 //------------------------------------------------------------------------------------------------------------------------------- 00126 00127 #define OFF 0x00 00128 #define ON 0x01 00129 00130 #define SERVO 0x01 00131 #define WHEEL 0x00 00132 00133 #define LEFT 0x00 00134 #define RIGHT 0x01 00135 00136 #define NONE 0x00 00137 #define READ 0x01 00138 #define ALL 0x02 00139 00140 #define BROADCAST_ID 0xFE 00141 00142 #define HEADER 0xFF 00143 00144 #define STATUS_PACKET_TIMEOUT 50 // in millis() 00145 #define STATUS_FRAME_BUFFER 5 00146 00147 00148 00149 class DynamixelClass { 00150 private: 00151 DigitalOut *servoSerialDir; 00152 Serial *servoSerial; 00153 void transmitInstructionPacket(void); 00154 unsigned int readStatusPacket(void); 00155 bool overflow; 00156 void debugframe(void); 00157 void debugStatusframe(void); 00158 DigitalOut *led2; 00159 public: 00160 00161 DynamixelClass(int baud,PinName D_Pin,PinName tx, PinName rx); //Constructor 00162 ~DynamixelClass(void); //destruktor 00163 00164 void NewBaudRate(int baud); 00165 unsigned int reset(unsigned char); 00166 unsigned int ping(unsigned char); 00167 00168 unsigned int setStatusPaketReturnDelay(unsigned char,unsigned char); 00169 unsigned int setID(unsigned char, unsigned char); 00170 unsigned int setBaudRate(unsigned char, long); 00171 unsigned int setMaxTorque(unsigned char, int); 00172 unsigned int setHoldingTorque(unsigned char, bool); 00173 unsigned int setAlarmShutdown(unsigned char,unsigned char); 00174 unsigned int setStatusPaket(unsigned char,unsigned char); 00175 unsigned int setMode(unsigned char, bool, unsigned int, unsigned int); 00176 unsigned int setPunch(unsigned char,unsigned int); 00177 unsigned int setPID(unsigned char,unsigned char,unsigned char,unsigned char); 00178 unsigned int setTemp(unsigned char,unsigned char); 00179 unsigned int setVoltage(unsigned char,unsigned char,unsigned char); 00180 00181 unsigned int writeReg(unsigned char ID,unsigned char reg,unsigned int data); 00182 unsigned int servo(unsigned char, unsigned int, unsigned int); 00183 unsigned int servoPreload(unsigned char, unsigned int, unsigned int); 00184 unsigned int wheel(unsigned char, bool, unsigned int); 00185 void wheelSync(unsigned char,bool,unsigned int,unsigned char, bool,unsigned int,unsigned char, bool,unsigned int); 00186 unsigned int wheelPreload(unsigned char, bool, unsigned int); 00187 00188 unsigned int action(unsigned char); 00189 00190 unsigned int readTemperature(unsigned char); 00191 unsigned int readVoltage(unsigned char); 00192 unsigned int readGoalPosition(unsigned char); 00193 unsigned int readPosition(unsigned char); 00194 unsigned int readLoad(unsigned char); 00195 unsigned int readSpeed(unsigned char); 00196 00197 unsigned int checkRegister(unsigned char); 00198 unsigned int checkMovement(unsigned char); 00199 unsigned int checkLock(unsigned char); 00200 00201 unsigned int ledState(unsigned char, bool); 00202 }; 00203 00204 #endif
Generated on Tue Jul 12 2022 19:42:54 by
