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.
Fork of MX28 by
Protocol.h
00001 /* Dynamixel MX28 servo library 00002 * Copyright (c) 2012 Georgios Petrou, MIT License 00003 * 00004 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 00005 * and associated documentation files (the "Software"), to deal in the Software without restriction, 00006 * including without limitation the rights to use, copy, modify, merge, publish, distribute, 00007 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 00008 * furnished to do so, subject to the following conditions: 00009 * 00010 * The above copyright notice and this permission notice shall be included in all copies or 00011 * substantial portions of the Software. 00012 * 00013 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 00014 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00015 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 00016 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00017 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00018 */ 00019 00020 #ifndef MX28_PROTOCOL_H 00021 #define MX28_PROTOCOL_H 00022 00023 #include "mbed.h" 00024 00025 #define MX28_BUFFER_SIZE 0x8F 00026 00027 #define MX28_PROTOCOL_COMMAND_RESPONSE_TIMEOUT_MS 200 00028 00029 #define MX28_PROTOCOL_HEADER_0 0xFF 00030 #define MX28_PROTOCOL_HEADER_1 0xFF 00031 00032 #define MX28_PROTOCOL_BROADCAST_ID 0xFE 00033 00034 // EEPROM Area 00035 #define MX28_MODEL_NUMBER_L 0x00 00036 #define MX28_MODEL_NUMBER_H 0x01 00037 #define MX28_VERSION 0x02 00038 #define MX28_ID 0x03 00039 #define MX28_BAUD_RATE 0x04 00040 #define MX28_RETURN_DELAY_TIME 0x05 00041 #define MX28_CW_ANGLE_LIMIT_L 0x06 00042 #define MX28_CW_ANGLE_LIMIT_H 0x07 00043 #define MX28_CCW_ANGLE_LIMIT_L 0x08 00044 #define MX28_CCW_ANGLE_LIMIT_H 0x09 00045 #define MX28_UP_LIMIT_TEMPERATURE 0x0B 00046 #define MX28_DOWN_LIMIT_VOLTAGE 0x0C 00047 #define MX28_UP_LIMIT_VOLTAGE 0x0D 00048 #define MX28_MAX_TORQUE_L 0x0E 00049 #define MX28_MAX_TORQUE_H 0x0F 00050 #define MX28_STATUS_RETURN_LEVEL 0x10 00051 #define MX28_ALARM_LED 0x11 00052 #define MX28_ALARM_SHUTDOWN 0x12 00053 00054 // RAM Area 00055 #define MX28_TORQUE_ENABLE 0x18 00056 #define MX28_LED_ENABLE 0x19 00057 #define MX28_D_GAIN 0x1A 00058 #define MX28_I_GAIN 0x1B 00059 #define MX28_P_GAIN 0x1C 00060 #define MX28_GOAL_POSITION_L 0x1E 00061 #define MX28_GOAL_POSITION_H 0x1F 00062 #define MX28_MOVING_SPEED_L 0x20 00063 #define MX28_MOVING_SPEED_H 0x21 00064 #define MX28_TORQUE_LIMIT_L 0x22 00065 #define MX28_TORQUE_LIMIT_H 0x23 00066 #define MX28_PRESENT_POSITION_L 0x24 00067 #define MX28_PRESENT_POSITION_H 0x25 00068 #define MX28_PRESENT_SPEED_L 0x26 00069 #define MX28_PRESENT_SPEED_H 0x27 00070 #define MX28_PRESENT_LOAD_L 0x28 00071 #define MX28_PRESENT_LOAD_H 0x29 00072 #define MX28_PRESENT_VOLTAGE 0x2A 00073 #define MX28_PRESENT_TEMPERATURE 0x2B 00074 #define MX28_REGISTERED_INSTRUCTION 0x2C 00075 #define MX28_MOVING 0x3E 00076 #define MX28_LOCK 0x2F 00077 #define MX28_PUNCH_L 0x30 00078 #define MX28_PUNCH_H 0x31 00079 00080 // Instruction set 00081 #define MX28_PING 0x01 00082 #define MX28_READ_DATA 0x02 00083 #define MX28_WRITE_DATA 0x03 00084 #define MX28_REG_WRITE 0x04 00085 #define MX28_ACTION 0x05 00086 #define MX28_RESET 0x06 00087 #define MX28_SYNC_WRITE 0x83 00088 00089 // Errors 00090 #define MX28_ERRBIT_NONE 0x00 00091 #define MX28_ERRBIT_VOLTAGE 0x01 00092 #define MX28_ERRBIT_ANGLE 0x02 00093 #define MX28_ERRBIT_OVERHEAT 0x04 00094 #define MX28_ERRBIT_RANGE 0x08 00095 #define MX28_ERRBIT_CHECKSUM 0x10 00096 #define MX28_ERRBIT_OVERLOAD 0x20 00097 #define MX28_ERRBIT_INSTRUCTION 0x40 00098 00099 // Extra errors 00100 #define MX28_ERRBIT_WRITE_TIMEOUT 0xFD 00101 #define MX28_ERRBIT_READ_TIMEOUT 0xFE 00102 #define MX28_ERRBIT_MASTER_CHECKSUM 0xFF 00103 00104 struct MX28_PROTOCOL_PACKET 00105 { 00106 uint8_t servoId; 00107 uint8_t length; 00108 uint8_t instructionErrorId; 00109 uint8_t parameter[MX28_BUFFER_SIZE]; 00110 uint8_t checkSum; 00111 }; 00112 00113 enum MX28_PROTOCOL_ENCODER_DECODER_STATE 00114 { 00115 WAIT_ON_HEADER_0, 00116 WAIT_ON_HEADER_1, 00117 WAIT_ON_SERVO_ID, 00118 WAIT_ON_LENGTH, 00119 WAIT_ON_INSTRUCTION_ERROR_ID, 00120 WAIT_ON_PARAMETER, 00121 WAIT_ON_CHECK_SUM 00122 }; 00123 00124 #endif // MX28_PROTOCOL_H
Generated on Thu Jul 14 2022 04:02:36 by
