00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00042
00043
00044 #ifndef COMMON_EDC_ETHERCAT_PROTOCOL_H_INCLUDED
00045 #define COMMON_EDC_ETHERCAT_PROTOCOL_H_INCLUDED
00046
00048 typedef enum
00049 {
00050 EDC_COMMAND_INVALID = 0,
00051 EDC_COMMAND_SENSOR_DATA,
00052 EDC_COMMAND_SENSOR_CHANNEL_NUMBERS,
00053 EDC_COMMAND_SENSOR_ADC_CHANNEL_CS,
00054 EDC_COMMAND_CAN_DIRECT_MODE
00055
00056
00057 }EDC_COMMAND;
00058
00059
00060
00061 #ifndef NO_STRINGS // The PIC compiler doesn't deal well with strings.
00062
00063 static const char* slow_data_types[17] = { "Invalid",
00064 "SVN revision",
00065 "SVN revision on server at build time",
00066
00067 "Modified from SVN revision",
00068 "Serial number low",
00069 "Serial number high",
00070 "Motor gear ratio",
00071 "Assembly date year",
00072 "Assembly date month, day",
00073
00074 "Controller F",
00075 "Controller P",
00076 "Controller I",
00077 "Controller Imax",
00078 "Controller D",
00079 "Controller deadband and sign",
00080
00081 "Controller loop frequency Hz"
00082 };
00083
00084 #endif
00085
00086
00089 typedef enum
00090 {
00091 DIRECTION_DATA_REQUEST = 0x0,
00092 DIRECTION_TO_MOTOR = 0x1,
00093 DIRECTION_FROM_MOTOR = 0x2,
00094 DIRECTION_BOOTLOADER = 0x3
00095 }MESSAGE_DIRECTION;
00096
00097
00098 #define MESSAGE_ID_DIRECTION_BITS 0b11000000000 //!< Bit mask specifying which bits of the CAN message ID are used for the MESSAGE_DIRECTION
00099 #define MESSAGE_ID_MOTOR_ID_BITS 0b00111100000 //!< Bit mask specifying which bits of the CAN message ID are used for the motor ID [0..9]
00100 #define MESSAGE_ID_ACK_BIT 0b00000010000 //!< Bit mask specifying which bits of the CAN message ID are used for the ACK bit (only for bootloading)
00101 #define MESSAGE_ID_TYPE_BITS 0b00000001111 //!< Bit mask specifying which bits of the CAN message ID are used for the TO_MOTOR_DATA_TYPE or FROM_MOTOR_DATA_TYPE
00102
00103
00104 #define MESSAGE_ID_DIRECTION_SHIFT_POS 9 //!< Bit number of lowest bit of MESSAGE_ID_DIRECTION_BITS
00105
00106
00107
00108 #define SENSORS_NUM_0X20 ((int)36) //!< The number of sensors in the robot.
00109
00110
00111
00112 #define JOINTS_NUM_0X20 ((int)28) //!< The number of joints in the hand
00113
00114
00115
00116
00117 #ifndef NO_STRINGS // The PIC compiler doesn't deal well with strings.
00118
00119 static const char* joint_names[JOINTS_NUM_0X20] = { "FFJ0", "FFJ1", "FFJ2", "FFJ3", "FFJ4",
00120 "MFJ0", "MFJ1", "MFJ2", "MFJ3", "MFJ4",
00121 "RFJ0", "RFJ1", "RFJ2", "RFJ3", "RFJ4",
00122 "LFJ0", "LFJ1", "LFJ2", "LFJ3", "LFJ4","LFJ5",
00123 "THJ1", "THJ2", "THJ3", "THJ4", "THJ5",
00124 "WRJ1", "WRJ2"
00125 };
00126
00127
00129
00130 static const char* sensor_names[SENSORS_NUM_0X20] = {"FFJ1", "FFJ2", "FFJ3", "FFJ4",
00131 "MFJ1", "MFJ2", "MFJ3", "MFJ4",
00132 "RFJ1", "RFJ2", "RFJ3", "RFJ4",
00133 "LFJ1", "LFJ2", "LFJ3", "LFJ4", "LFJ5",
00134 "THJ1", "THJ2", "THJ3", "THJ4", "THJ5A", "THJ5B",
00135 "WRJ1A", "WRJ1B", "WRJ2",
00136 "ACCX", "ACCY", "ACCZ",
00137 "GYRX", "GYRY", "GYRZ",
00138 "AN0", "AN1", "AN2", "AN3"
00139 };
00140 #endif
00141
00142
00144 typedef enum
00145 {
00146 FFJ1=0, FFJ2, FFJ3, FFJ4,
00147 MFJ1, MFJ2, MFJ3, MFJ4,
00148 RFJ1, RFJ2, RFJ3, RFJ4,
00149 LFJ1, LFJ2, LFJ3, LFJ4, LFJ5,
00150 THJ1, THJ2, THJ3, THJ4, THJ5A, THJ5B,
00151 WRJ1A, WRJ1B, WRJ2,
00152
00153 ACCX, ACCY, ACCZ,
00154 GYRX, GYRY, GYRZ,
00155
00156 ANA0, ANA1, ANA2, ANA3,
00157 IGNORE
00158 }SENSOR_NAME_ENUM;
00159
00160
00161
00162
00163 typedef enum
00164 {
00165 PALM_SVN_VERSION = 0,
00166 SERVER_SVN_VERSION = 1
00167 }HARD_CONFIGURATION_INFORMATION;
00168
00169
00170
00171 #define INSERT_CRC_CALCULATION_HERE crc_i = (int8u) (crc_result&0xff); \
00172 crc_i ^= crc_byte; \
00173 crc_result >>= 8; \
00174 if(crc_i & 0x01) crc_result ^= 0x3096; \
00175 if(crc_i & 0x02) crc_result ^= 0x612c; \
00176 if(crc_i & 0x04) crc_result ^= 0xc419; \
00177 if(crc_i & 0x08) crc_result ^= 0x8832; \
00178 if(crc_i & 0x10) crc_result ^= 0x1064; \
00179 if(crc_i & 0x20) crc_result ^= 0x20c8; \
00180 if(crc_i & 0x40) crc_result ^= 0x4190; \
00181 if(crc_i & 0x80) crc_result ^= 0x8320;
00182
00183
00184 #endif