Lib herkulex utilisée pour la carte du phare
fonctions_herkulex.h@11:542de77801ba, 2019-05-25 (annotated)
- Committer:
- Artiom
- Date:
- Sat May 25 12:06:02 2019 +0000
- Revision:
- 11:542de77801ba
- Parent:
- 10:cf3ae80dddd3
- Child:
- 12:562aa318952c
maj fonction verification en booleen
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kyxstark | 8:bde29d98f783 | 1 | #ifndef LIB_HERKULEX_H |
kyxstark | 8:bde29d98f783 | 2 | #define LIB_HERKULEX_H |
AdrienSalle | 0:32fd5a08c430 | 3 | #include "mbed.h" |
AdrienSalle | 0:32fd5a08c430 | 4 | |
AdrienSalle | 0:32fd5a08c430 | 5 | //#define ID 0xFD //=253 |
AdrienSalle | 0:32fd5a08c430 | 6 | |
AdrienSalle | 0:32fd5a08c430 | 7 | // Herkulex ROM Register |
AdrienSalle | 0:32fd5a08c430 | 8 | #define ROM_MODEL_NO1 0 |
AdrienSalle | 0:32fd5a08c430 | 9 | #define ROM_MODEL_NO2 1 |
AdrienSalle | 0:32fd5a08c430 | 10 | #define ROM_VERSION1 2 |
AdrienSalle | 0:32fd5a08c430 | 11 | #define ROM_VERSION2 3 |
AdrienSalle | 0:32fd5a08c430 | 12 | #define ROM_BAUD_RATE 4 |
AdrienSalle | 0:32fd5a08c430 | 13 | #define ROM_RESERVED5 5 |
AdrienSalle | 0:32fd5a08c430 | 14 | #define ROM_ID 6 |
AdrienSalle | 0:32fd5a08c430 | 15 | #define ROM_ACK_POLICY 7 |
AdrienSalle | 0:32fd5a08c430 | 16 | #define ROM_ALARM_LED_POLICY 8 |
AdrienSalle | 0:32fd5a08c430 | 17 | #define ROM_TORQUE_POLICY 9 |
AdrienSalle | 0:32fd5a08c430 | 18 | #define ROM_RESERVED10 10 |
AdrienSalle | 0:32fd5a08c430 | 19 | #define ROM_MAX_TEMPERATURE 11 |
AdrienSalle | 0:32fd5a08c430 | 20 | #define ROM_MIN_VOLTAGE 12 |
AdrienSalle | 0:32fd5a08c430 | 21 | #define ROM_MAX_VOLTAGE 13 |
AdrienSalle | 0:32fd5a08c430 | 22 | #define ROM_ACCELERATION_RATIO 14 |
AdrienSalle | 0:32fd5a08c430 | 23 | #define ROM_MAX_ACCELERATION_TIME 15 |
AdrienSalle | 0:32fd5a08c430 | 24 | #define ROM_DEAD_ZONE 16 |
AdrienSalle | 0:32fd5a08c430 | 25 | #define ROM_SATURATOR_OFFSET 17 |
AdrienSalle | 0:32fd5a08c430 | 26 | #define ROM_SATURATOR_SLOPE 18 // 2Byte |
AdrienSalle | 0:32fd5a08c430 | 27 | #define ROM_PWM_OFFSET 20 |
AdrienSalle | 0:32fd5a08c430 | 28 | #define ROM_MIN_PWM 21 |
AdrienSalle | 0:32fd5a08c430 | 29 | #define ROM_MAX_PWM 22 // 2Byte |
AdrienSalle | 0:32fd5a08c430 | 30 | #define ROM_OVERLOAD_PWM_THRESHOLD 24 // 2Byte |
AdrienSalle | 0:32fd5a08c430 | 31 | #define ROM_MIN_POSITION 26 // 2Byte |
AdrienSalle | 0:32fd5a08c430 | 32 | #define ROM_MAX_POSITION 28 // 2Byte |
AdrienSalle | 0:32fd5a08c430 | 33 | #define ROM_POSITION_KP 30 // 2Byte |
AdrienSalle | 0:32fd5a08c430 | 34 | #define ROM_POSITION_KD 32 // 2Byte |
AdrienSalle | 0:32fd5a08c430 | 35 | #define ROM_POSITION_KI 34 // 2Byte |
AdrienSalle | 0:32fd5a08c430 | 36 | #define ROM_POSITION_FEEDFORWARD_1ST_GAIN 36 // 2Byte |
AdrienSalle | 0:32fd5a08c430 | 37 | #define ROM_POSITION FEEDFORWARD_2ND_GAIN 38 // 2Byte |
AdrienSalle | 0:32fd5a08c430 | 38 | #define ROM_RESERVED40 40 // 2Byte |
AdrienSalle | 0:32fd5a08c430 | 39 | #define ROM_RESERVED42 42 // 2Byte |
AdrienSalle | 0:32fd5a08c430 | 40 | #define ROM_LED_BLINK_PERIOD 44 |
AdrienSalle | 0:32fd5a08c430 | 41 | #define ROM_ADC_FAULT_CHECK_PERIOD 45 |
AdrienSalle | 0:32fd5a08c430 | 42 | #define ROM_PACKET_GARBAGE_CHECK_PERIOD 46 |
AdrienSalle | 0:32fd5a08c430 | 43 | #define ROM_STOP_DETECTION_PERIOD 47 |
AdrienSalle | 0:32fd5a08c430 | 44 | #define ROM_OVERLOAD_DETECTION_PERIOD 48 |
AdrienSalle | 0:32fd5a08c430 | 45 | #define ROM_STOP_THRESHOLD 49 |
AdrienSalle | 0:32fd5a08c430 | 46 | #define ROM_INPOSITION_MARGIN 50 |
AdrienSalle | 0:32fd5a08c430 | 47 | #define ROM_RESERVED51 51 |
AdrienSalle | 0:32fd5a08c430 | 48 | #define ROM_RESERVED52 52 |
AdrienSalle | 0:32fd5a08c430 | 49 | #define ROM_CALIBRATION_DIFFERENCE 53 |
AdrienSalle | 0:32fd5a08c430 | 50 | |
AdrienSalle | 0:32fd5a08c430 | 51 | //------------------------------------------------------------------------------ |
AdrienSalle | 0:32fd5a08c430 | 52 | // Herkulex RAM Register |
AdrienSalle | 0:32fd5a08c430 | 53 | #define RAM_ID 0 |
AdrienSalle | 0:32fd5a08c430 | 54 | #define RAM_ACK_POLICY 1 |
AdrienSalle | 0:32fd5a08c430 | 55 | #define RAM_ALARM_LED_POLICY 2 |
AdrienSalle | 0:32fd5a08c430 | 56 | #define RAM_TORQUE_POLICY 3 |
AdrienSalle | 0:32fd5a08c430 | 57 | #define RAM_RESERVED4 4 |
AdrienSalle | 0:32fd5a08c430 | 58 | #define RAM_MAX_TEMPERATURE 5 |
AdrienSalle | 0:32fd5a08c430 | 59 | #define RAM_MIN_VOLTAGE 6 |
AdrienSalle | 0:32fd5a08c430 | 60 | #define RAM_MAX_VOLTAGE 7 |
AdrienSalle | 0:32fd5a08c430 | 61 | #define RAM_ACCELERATION_RATIO 8 |
AdrienSalle | 0:32fd5a08c430 | 62 | #define RAM_MAX_ACCELERATION 9 |
AdrienSalle | 0:32fd5a08c430 | 63 | #define RAM_DEAD_ZONE 10 |
AdrienSalle | 0:32fd5a08c430 | 64 | #define RAM_SATURATOR_OFFSET 11 |
AdrienSalle | 0:32fd5a08c430 | 65 | #define RAM_SATURATOR_SLOPE 12 // 2Byte |
AdrienSalle | 0:32fd5a08c430 | 66 | #define RAM_PWM_OFFSET 14 |
AdrienSalle | 0:32fd5a08c430 | 67 | #define RAM_MIN_PWM 15 |
AdrienSalle | 0:32fd5a08c430 | 68 | #define RAM_MAX_PWM 16 // 2Byte |
AdrienSalle | 0:32fd5a08c430 | 69 | #define RAM_OVERLOAD_PWM_THRESHOLD 18 // 2Byte |
AdrienSalle | 0:32fd5a08c430 | 70 | #define RAM_MIN_POSITION 20 // 2Byte |
AdrienSalle | 0:32fd5a08c430 | 71 | #define RAM_MAX_POSITION 22 // 2Byte |
AdrienSalle | 0:32fd5a08c430 | 72 | #define RAM_POSITION_KP 24 // 2Byte |
AdrienSalle | 0:32fd5a08c430 | 73 | #define RAM_POSITION_KD 26 // 2Byte |
AdrienSalle | 0:32fd5a08c430 | 74 | #define RAM_POSITION_KI 28 // 2Byte |
AdrienSalle | 0:32fd5a08c430 | 75 | #define RAM_POSITION_FEEDFORWARD_1ST_GAIN 30 // 2Byte |
AdrienSalle | 0:32fd5a08c430 | 76 | #define RAM_POSITION_FEEDFORWARD 2ND GAIN 32 // 2Byte |
AdrienSalle | 0:32fd5a08c430 | 77 | #define RAM_RESERVED34 34 // 2Byte |
AdrienSalle | 0:32fd5a08c430 | 78 | #define RAM_RESERVED36 36 // 2Byte |
AdrienSalle | 0:32fd5a08c430 | 79 | #define RAM_LED_BLINK_PERIOD 38 |
AdrienSalle | 0:32fd5a08c430 | 80 | #define RAM_ADC_FAULT_DETECTION_PERIOD 39 |
AdrienSalle | 0:32fd5a08c430 | 81 | #define RAM_PACKET_GARBAGE_DETECTION_PERIOD 40 |
AdrienSalle | 0:32fd5a08c430 | 82 | #define RAM_STOP_DETECTION_PERIOD 41 |
AdrienSalle | 0:32fd5a08c430 | 83 | #define RAM_OVERLOAD_DETECTION_PERIOD 42 |
AdrienSalle | 0:32fd5a08c430 | 84 | #define RAM_STOP_THRESHOLD 43 |
AdrienSalle | 0:32fd5a08c430 | 85 | #define RAM_INPOSITION_MARGIN 44 |
AdrienSalle | 0:32fd5a08c430 | 86 | #define RAM_RESERVED45 45 |
AdrienSalle | 0:32fd5a08c430 | 87 | #define RAM_RESERVED46 46 |
AdrienSalle | 0:32fd5a08c430 | 88 | #define RAM_CALIBRATION_DIFFERENCE 47 |
AdrienSalle | 0:32fd5a08c430 | 89 | #define RAM_STATUS_ERROR 48 |
AdrienSalle | 0:32fd5a08c430 | 90 | #define RAM_STATUS_DETAIL 49 |
AdrienSalle | 0:32fd5a08c430 | 91 | #define RAM_RESERVED50 50 |
AdrienSalle | 0:32fd5a08c430 | 92 | #define RAM_RESERVED51 51 |
AdrienSalle | 0:32fd5a08c430 | 93 | #define RAM_TORQUE_CONTROL 52 |
AdrienSalle | 0:32fd5a08c430 | 94 | #define RAM_LED_CONTROL 53 |
AdrienSalle | 0:32fd5a08c430 | 95 | #define RAM_VOLTAGE 54 |
AdrienSalle | 0:32fd5a08c430 | 96 | #define RAM_TEMPERATURE 55 |
AdrienSalle | 0:32fd5a08c430 | 97 | #define RAM_CURRENT_CONTROL_MODE 56 |
AdrienSalle | 0:32fd5a08c430 | 98 | #define RAM_TICK 57 |
AdrienSalle | 0:32fd5a08c430 | 99 | #define RAM_CALIBRATED_POSITION 58 // 2Byte |
AdrienSalle | 0:32fd5a08c430 | 100 | #define RAM_ABSOLUTE_POSITION 60 // 2Byte |
AdrienSalle | 0:32fd5a08c430 | 101 | #define RAM_DIFFERENTIAL_POSITION 62 // 2Byte |
AdrienSalle | 0:32fd5a08c430 | 102 | #define RAM_PWM 64 // 2Byte |
AdrienSalle | 0:32fd5a08c430 | 103 | #define RAM_RESERVED66 66 // 2Byte |
AdrienSalle | 0:32fd5a08c430 | 104 | #define RAM_ABSOLUTE_GOAL_POSITION 68 // 2Byte |
AdrienSalle | 0:32fd5a08c430 | 105 | #define RAM_ABSOLUTE_DESIRED_TRAJECTORY_POSITION 70 // 2Byte |
AdrienSalle | 0:32fd5a08c430 | 106 | #define RAM_DESIRED_VELOCITY 72 // 2Byte |
AdrienSalle | 0:32fd5a08c430 | 107 | |
AdrienSalle | 0:32fd5a08c430 | 108 | //------------------------------------------------------------------------------ |
AdrienSalle | 0:32fd5a08c430 | 109 | // Request Packet [To Servo Module] |
AdrienSalle | 0:32fd5a08c430 | 110 | #define CMD_ROM_WRITE 0x01 // Write Length number of values to EEP Register Address |
AdrienSalle | 0:32fd5a08c430 | 111 | #define CMD_ROM_READ 0x02 // Request Length number of values from EEP Register Address |
AdrienSalle | 0:32fd5a08c430 | 112 | #define CMD_RAM_WRITE 0x03 // Write Length number of values to RAM Register Address |
AdrienSalle | 0:32fd5a08c430 | 113 | #define CMD_RAM_READ 0x04 // Request Lenght number of values from RAM Register Address |
AdrienSalle | 0:32fd5a08c430 | 114 | #define CMD_I_JOG 0x05 // Able to send JOG command to maximum 43 servos (operate timing of individual Servo) |
AdrienSalle | 0:32fd5a08c430 | 115 | #define CMD_S_JOG 0x06 // Able to send JOG command to maximum 53 servos (operate simultaneously at same time) |
AdrienSalle | 0:32fd5a08c430 | 116 | #define CMD_STAT 0x07 // Status Error, Status Detail request |
AdrienSalle | 0:32fd5a08c430 | 117 | #define CMD_ROLLBACK 0x08 // Change all EEP Regsters to Factory Default value |
AdrienSalle | 0:32fd5a08c430 | 118 | #define CMD_REBOOT 0x09 // Request Reboot |
AdrienSalle | 0:32fd5a08c430 | 119 | |
AdrienSalle | 0:32fd5a08c430 | 120 | //------------------------------------------------------------------------------ |
AdrienSalle | 0:32fd5a08c430 | 121 | // ACK Packet [To Controller(ACK)] |
AdrienSalle | 0:32fd5a08c430 | 122 | #define CMD_ACK_MASK 0x40 // ACK Packet CMD is Request Packet CMD + 0x40 |
AdrienSalle | 0:32fd5a08c430 | 123 | #define CMD_EEP_WRITE_ACK (CMD_EEP_WRITE|CMD_ACK_MASK) |
AdrienSalle | 0:32fd5a08c430 | 124 | #define CMD_EEP_READ_ACK (CMD_EEP_READ|CMD_ACK_MASK) |
AdrienSalle | 0:32fd5a08c430 | 125 | #define CMD_RAM_WRITE_ACK (CMD_RAM_WRITE|CMD_ACK_MASK) |
AdrienSalle | 0:32fd5a08c430 | 126 | #define CMD_RAM_READ_ACK (CMD_RAM_READ|CMD_ACK_MASK) |
AdrienSalle | 0:32fd5a08c430 | 127 | #define CMD_I_JOG_ACK (CMD_I_JOG|CMD_ACK_MASK) |
AdrienSalle | 0:32fd5a08c430 | 128 | #define CMD_S_JOG_ACK (CMD_S_JOG|CMD_ACK_MASK) |
AdrienSalle | 0:32fd5a08c430 | 129 | #define CMD_STAT_ACK (CMD_STAT|CMD_ACK_MASK) |
AdrienSalle | 0:32fd5a08c430 | 130 | #define CMD_ROLLBACK_ACK (CMD_ROLLBACK|CMD_ACK_MASK) |
AdrienSalle | 0:32fd5a08c430 | 131 | #define CMD_REBOOT_ACK (CMD_REBOOT|CMD_ACK_MASK) |
AdrienSalle | 0:32fd5a08c430 | 132 | |
AdrienSalle | 0:32fd5a08c430 | 133 | //------------------------------------------------------------------------------ |
AdrienSalle | 0:32fd5a08c430 | 134 | // Status Error |
AdrienSalle | 0:32fd5a08c430 | 135 | #define STATUS_OK = 0x00; |
AdrienSalle | 0:32fd5a08c430 | 136 | #define ERROR_EXCEED_INPUT_VOLTAGE = 0x01; |
AdrienSalle | 0:32fd5a08c430 | 137 | #define ERROR_EXCEED_POT_LIMIT = 0x02; |
AdrienSalle | 0:32fd5a08c430 | 138 | #define ERROR_EXCEED_TEMPERATURE_LIMIT = 0x04; |
AdrienSalle | 0:32fd5a08c430 | 139 | #define ERROR_INVALID_PACKET = 0x08; |
AdrienSalle | 0:32fd5a08c430 | 140 | #define ERROR_OVERLOAD = 0x10; |
AdrienSalle | 0:32fd5a08c430 | 141 | #define ERROR_DRIVER_FAULT = 0x20; |
AdrienSalle | 0:32fd5a08c430 | 142 | #define ERROR_EEP_REG_DISTORT = 0x40; |
AdrienSalle | 0:32fd5a08c430 | 143 | |
AdrienSalle | 0:32fd5a08c430 | 144 | //------------------------------------------------------------------------------ |
AdrienSalle | 0:32fd5a08c430 | 145 | // Status Detail |
AdrienSalle | 0:32fd5a08c430 | 146 | #define MOVING_FLAG = 0x01; |
AdrienSalle | 0:32fd5a08c430 | 147 | #define INPOSITION_FLAG = 0x02; |
AdrienSalle | 0:32fd5a08c430 | 148 | #define CHECKSUM_ERROR = 0x04; // Invalid packet`s detailed information |
AdrienSalle | 0:32fd5a08c430 | 149 | #define UNKNOWN_COMMAND = 0x08; // Invalid packet`s detailed information |
AdrienSalle | 0:32fd5a08c430 | 150 | #define EXCEED_REG_RANGE = 0x10; // Invalid packet`s detailed information |
AdrienSalle | 0:32fd5a08c430 | 151 | #define GARBAGE_DETECTED = 0x20; // Invalid packet`s detailed information |
AdrienSalle | 0:32fd5a08c430 | 152 | #define MOTOR_ON_FLAG = 0x40; |
AdrienSalle | 0:32fd5a08c430 | 153 | |
AdrienSalle | 0:32fd5a08c430 | 154 | //------------------------------------------------------------------------------ |
AdrienSalle | 0:32fd5a08c430 | 155 | // Header |
AdrienSalle | 0:32fd5a08c430 | 156 | #define HEADER 0xFF |
AdrienSalle | 0:32fd5a08c430 | 157 | |
AdrienSalle | 0:32fd5a08c430 | 158 | // Size |
AdrienSalle | 0:32fd5a08c430 | 159 | #define MIN_PACKET_SIZE 7 |
AdrienSalle | 0:32fd5a08c430 | 160 | #define MIN_ACK_PACKET_SIZE 9 |
AdrienSalle | 0:32fd5a08c430 | 161 | #define WRITE_PACKET_SIZE 13 |
AdrienSalle | 0:32fd5a08c430 | 162 | #define MAX_PACKET_SIZE 223 |
AdrienSalle | 0:32fd5a08c430 | 163 | #define MAX_DATA_SIZE (MAX_PACKET_SIZE-MIN_PACKET_SIZE) |
AdrienSalle | 0:32fd5a08c430 | 164 | |
AdrienSalle | 0:32fd5a08c430 | 165 | // ID |
AdrienSalle | 0:32fd5a08c430 | 166 | #define MAX_PID 0xFD |
AdrienSalle | 0:32fd5a08c430 | 167 | #define DEFAULT_ID 0xFD |
AdrienSalle | 0:32fd5a08c430 | 168 | #define MAX_ID 0xFD |
AdrienSalle | 0:32fd5a08c430 | 169 | #define BROADCAST_ID 0xFE |
AdrienSalle | 0:32fd5a08c430 | 170 | |
AdrienSalle | 0:32fd5a08c430 | 171 | // Checksum |
AdrienSalle | 0:32fd5a08c430 | 172 | #define CHKSUM_MASK 0xFE |
AdrienSalle | 0:32fd5a08c430 | 173 | |
AdrienSalle | 0:32fd5a08c430 | 174 | // Torque CMD |
AdrienSalle | 0:32fd5a08c430 | 175 | #define TORQUE_FREE 0x00 |
AdrienSalle | 0:32fd5a08c430 | 176 | #define BREAK_ON 0x40 |
AdrienSalle | 0:32fd5a08c430 | 177 | #define TORQUE_ON 0x60 |
AdrienSalle | 0:32fd5a08c430 | 178 | |
AdrienSalle | 0:32fd5a08c430 | 179 | // Register Size |
AdrienSalle | 0:32fd5a08c430 | 180 | #define BYTE1 1 |
AdrienSalle | 0:32fd5a08c430 | 181 | #define BYTE2 2 |
AdrienSalle | 0:32fd5a08c430 | 182 | |
AdrienSalle | 0:32fd5a08c430 | 183 | // Jog Set CMD |
AdrienSalle | 0:32fd5a08c430 | 184 | #define STOP 0x01 |
AdrienSalle | 0:32fd5a08c430 | 185 | #define POS_MODE 0x00 |
AdrienSalle | 0:32fd5a08c430 | 186 | #define TURN_MODE 0x02 |
AdrienSalle | 0:32fd5a08c430 | 187 | #define GLED_ON 0x04 |
AdrienSalle | 0:32fd5a08c430 | 188 | #define BLED_ON 0x08 |
AdrienSalle | 0:32fd5a08c430 | 189 | #define RLED_ON 0x10 |
AdrienSalle | 0:32fd5a08c430 | 190 | |
AdrienSalle | 0:32fd5a08c430 | 191 | //------------------------------------------------------------------------------ |
AdrienSalle | 0:32fd5a08c430 | 192 | //------------------------------------------a choisir--------------------------- |
AdrienSalle | 0:32fd5a08c430 | 193 | #define nombre_servomoteur 3 // |
Artiom | 1:94a29f20ca18 | 194 | |
Artiom | 4:8ed862a631eb | 195 | |
AdrienSalle | 0:32fd5a08c430 | 196 | |
AdrienSalle | 0:32fd5a08c430 | 197 | //------------------------------------------------------------------------------ |
AdrienSalle | 0:32fd5a08c430 | 198 | |
AdrienSalle | 0:32fd5a08c430 | 199 | /** Create an Herkulex servo object connected to the serial pins and baudrate |
AdrienSalle | 0:32fd5a08c430 | 200 | * |
AdrienSalle | 0:32fd5a08c430 | 201 | * @param tx Transmit pin. |
AdrienSalle | 0:32fd5a08c430 | 202 | * @param rx Receive pin. |
AdrienSalle | 0:32fd5a08c430 | 203 | * @param baudRate The serial tx/rx speed. |
AdrienSalle | 0:32fd5a08c430 | 204 | */ |
AdrienSalle | 0:32fd5a08c430 | 205 | // void Herkulex(PinName tx, PinName rx, uint32_t baudRate); |
AdrienSalle | 0:32fd5a08c430 | 206 | |
AdrienSalle | 0:32fd5a08c430 | 207 | /** Destroy an Herkulex servo object |
AdrienSalle | 0:32fd5a08c430 | 208 | */ |
AdrienSalle | 0:32fd5a08c430 | 209 | //void N_Herkulex(); |
AdrienSalle | 0:32fd5a08c430 | 210 | |
AdrienSalle | 0:32fd5a08c430 | 211 | /** Transmit packet datas |
AdrienSalle | 0:32fd5a08c430 | 212 | * |
AdrienSalle | 0:32fd5a08c430 | 213 | * @param packetSize The packet size. |
AdrienSalle | 0:32fd5a08c430 | 214 | * @param data The transmit packet data array. |
AdrienSalle | 0:32fd5a08c430 | 215 | */ |
AdrienSalle | 0:32fd5a08c430 | 216 | void txPacket(uint8_t packetSize, uint8_t* data, uint8_t numero_serial); |
AdrienSalle | 0:32fd5a08c430 | 217 | |
AdrienSalle | 0:32fd5a08c430 | 218 | /** Receive packet datas |
AdrienSalle | 0:32fd5a08c430 | 219 | * |
AdrienSalle | 0:32fd5a08c430 | 220 | * @param packetSize The packet size. |
AdrienSalle | 0:32fd5a08c430 | 221 | * @param data The receive packet data array. |
AdrienSalle | 0:32fd5a08c430 | 222 | */ |
AdrienSalle | 0:32fd5a08c430 | 223 | void rxPacket(uint8_t packetSize, uint8_t* data, uint8_t numero_serial); |
AdrienSalle | 0:32fd5a08c430 | 224 | |
AdrienSalle | 0:32fd5a08c430 | 225 | /** Clear error status |
AdrienSalle | 0:32fd5a08c430 | 226 | * |
AdrienSalle | 0:32fd5a08c430 | 227 | * @param id The herkulex servo ID. |
AdrienSalle | 0:32fd5a08c430 | 228 | */ |
AdrienSalle | 0:32fd5a08c430 | 229 | void clear(uint8_t id, uint8_t numero_serial); |
AdrienSalle | 0:32fd5a08c430 | 230 | |
AdrienSalle | 0:32fd5a08c430 | 231 | /** Set torque setting |
AdrienSalle | 0:32fd5a08c430 | 232 | * |
AdrienSalle | 0:32fd5a08c430 | 233 | * @param id The herkulex servo ID. |
AdrienSalle | 0:32fd5a08c430 | 234 | * @param cmdTorque The Command for setting of torque (TORQUE_FREE 0x00, BREAK_ON 0x40, TORQUE_ON 0x60) |
AdrienSalle | 0:32fd5a08c430 | 235 | */ |
AdrienSalle | 0:32fd5a08c430 | 236 | void setTorque(uint8_t id, uint8_t cmdTorque, uint8_t numero_serial); |
AdrienSalle | 0:32fd5a08c430 | 237 | //------------------------------Déplacements------------------------------------- |
AdrienSalle | 0:32fd5a08c430 | 238 | /** Position Control |
AdrienSalle | 0:32fd5a08c430 | 239 | * |
AdrienSalle | 0:32fd5a08c430 | 240 | * @param id The herkulex servo ID. |
AdrienSalle | 0:32fd5a08c430 | 241 | * @param position The goal position of herkulex servo. |
AdrienSalle | 0:32fd5a08c430 | 242 | * @param playtime Time to target position. |
AdrienSalle | 0:32fd5a08c430 | 243 | * @param setLED Select LED and on/off controll (GLED_ON 0x00,BLED_ON 0x08, RLED_ON 0x10) |
AdrienSalle | 0:32fd5a08c430 | 244 | */ |
AdrienSalle | 0:32fd5a08c430 | 245 | void positionControl(uint8_t id, uint16_t position, uint8_t playtime, uint8_t setLED, uint8_t numero_serial); |
AdrienSalle | 0:32fd5a08c430 | 246 | |
AdrienSalle | 0:32fd5a08c430 | 247 | /** Velocity Control |
AdrienSalle | 0:32fd5a08c430 | 248 | * |
AdrienSalle | 0:32fd5a08c430 | 249 | * @param id The herkulex servo ID. |
AdrienSalle | 0:32fd5a08c430 | 250 | * @param speed The goal position of herkulex servo. |
AdrienSalle | 0:32fd5a08c430 | 251 | * @param setLED Select LED and on/off controll (GLED_ON 0x00,BLED_ON 0x08, RLED_ON 0x10) |
AdrienSalle | 0:32fd5a08c430 | 252 | */ |
AdrienSalle | 0:32fd5a08c430 | 253 | void velocityControl(uint8_t id, int16_t speed,uint8_t setLED, uint8_t numero_serial); |
AdrienSalle | 0:32fd5a08c430 | 254 | /** |
AdrienSalle | 0:32fd5a08c430 | 255 | * |
AdrienSalle | 0:32fd5a08c430 | 256 | *même paramètres que positionControl(); |
AdrienSalle | 0:32fd5a08c430 | 257 | *permet de donner des instructions à deux servomoteurs simultanéments |
AdrienSalle | 0:32fd5a08c430 | 258 | */ |
AdrienSalle | 0:32fd5a08c430 | 259 | void positionControl_Mul_ensemble(uint8_t id, uint16_t position, uint8_t playtime, uint8_t setLED,uint8_t id2, uint16_t position2, uint8_t setLED2, uint8_t numero_serial); |
AdrienSalle | 0:32fd5a08c430 | 260 | /** |
AdrienSalle | 0:32fd5a08c430 | 261 | * |
AdrienSalle | 0:32fd5a08c430 | 262 | *même paramètres que positionControl_Mul_ensemble(); |
AdrienSalle | 0:32fd5a08c430 | 263 | *permet de donner des instructions à deux servomoteurs simultanéments avec un playtime différent |
AdrienSalle | 0:32fd5a08c430 | 264 | */ |
AdrienSalle | 0:32fd5a08c430 | 265 | void positionControl_Mul_playtime_different(uint8_t id, uint16_t position, uint8_t playtime, uint8_t setLED,uint8_t id2, uint16_t position2, uint8_t playtime2, uint8_t setLED2, uint8_t numero_serial); |
AdrienSalle | 0:32fd5a08c430 | 266 | /** |
AdrienSalle | 0:32fd5a08c430 | 267 | * |
AdrienSalle | 0:32fd5a08c430 | 268 | * |
AdrienSalle | 0:32fd5a08c430 | 269 | *permet de donner des instructions à deux servomoteurs simultanéments avec un playtime différent |
AdrienSalle | 0:32fd5a08c430 | 270 | */ |
AdrienSalle | 0:32fd5a08c430 | 271 | void positionControl_Mul_ensemble_complex(uint8_t nb_servo, uint8_t playtime, uint8_t* data, uint16_t* pos, uint8_t numero_serial); // uint16_t position, uint8_t setLED, uint8_t id |
AdrienSalle | 0:32fd5a08c430 | 272 | /** |
AdrienSalle | 0:32fd5a08c430 | 273 | * |
AdrienSalle | 0:32fd5a08c430 | 274 | *même paramètres que positionControl_Mul_ensemble(); |
AdrienSalle | 0:32fd5a08c430 | 275 | *permet de donner des instructions à deux servomoteurs simultanéments avec un playtime différent |
AdrienSalle | 0:32fd5a08c430 | 276 | */ |
AdrienSalle | 0:32fd5a08c430 | 277 | void positionControl_Mul_ensemble_different_complex(uint8_t nb_servo, uint8_t* data, uint16_t* pos, uint8_t numero_serial); // uint16_t position, uint8_t setLED, uint8_t id, uint8_t playtime |
AdrienSalle | 0:32fd5a08c430 | 278 | |
AdrienSalle | 0:32fd5a08c430 | 279 | |
marwanesaich | 10:cf3ae80dddd3 | 280 | void compteTour(int ID,int16_t speed,uint8_t tour, uint16_t position,uint8_t setLED,uint8_t serial); |
marwanesaich | 9:0f09e3ee52e9 | 281 | |
AdrienSalle | 0:32fd5a08c430 | 282 | //-------------------------------------Demandes d'informations |
AdrienSalle | 0:32fd5a08c430 | 283 | /** Get Status |
AdrienSalle | 0:32fd5a08c430 | 284 | * |
AdrienSalle | 0:32fd5a08c430 | 285 | * @param id The herkulex servo ID. |
AdrienSalle | 0:32fd5a08c430 | 286 | * @return -1 is getStatus failed. other is servo`s status error value. |
AdrienSalle | 0:32fd5a08c430 | 287 | */ |
AdrienSalle | 0:32fd5a08c430 | 288 | int8_t getStatus(uint8_t id, uint8_t numero_serial); |
AdrienSalle | 0:32fd5a08c430 | 289 | |
AdrienSalle | 0:32fd5a08c430 | 290 | /** Get Position |
AdrienSalle | 0:32fd5a08c430 | 291 | * |
AdrienSalle | 0:32fd5a08c430 | 292 | * @param id The herkulex servo ID. |
AdrienSalle | 0:32fd5a08c430 | 293 | * @return -1 is getPos failed. other is servo's current position. |
AdrienSalle | 0:32fd5a08c430 | 294 | */ |
AdrienSalle | 0:32fd5a08c430 | 295 | int16_t getPos(uint8_t id, uint8_t numero_serial); |
AdrienSalle | 0:32fd5a08c430 | 296 | |
AdrienSalle | 0:32fd5a08c430 | 297 | //void recevoir_irq(void); |
AdrienSalle | 0:32fd5a08c430 | 298 | |
AdrienSalle | 0:32fd5a08c430 | 299 | void receive_Sv(void); |
Artiom | 11:542de77801ba | 300 | bool verification(); |
AdrienSalle | 0:32fd5a08c430 | 301 | |
AdrienSalle | 0:32fd5a08c430 | 302 | int8_t Get_Torque(int8_t id, uint8_t numero_serial); |
AdrienSalle | 0:32fd5a08c430 | 303 | |
AdrienSalle | 0:32fd5a08c430 | 304 | int8_t Get_Temperature_MAX(int8_t id, uint8_t numero_serial); |
AdrienSalle | 0:32fd5a08c430 | 305 | |
AdrienSalle | 0:32fd5a08c430 | 306 | int8_t Get_Tension_MIN(int8_t id, uint8_t numero_serial); |
AdrienSalle | 0:32fd5a08c430 | 307 | |
AdrienSalle | 0:32fd5a08c430 | 308 | void Set_Tension_MIN(int8_t id,uint8_t Tension_Min, uint8_t numero_serial); |
AdrienSalle | 0:32fd5a08c430 | 309 | |
AdrienSalle | 0:32fd5a08c430 | 310 | |
AdrienSalle | 0:32fd5a08c430 | 311 | int8_t Get_Tension_actuelle(int8_t id, uint8_t numero_serial); |
AdrienSalle | 0:32fd5a08c430 | 312 | |
AdrienSalle | 0:32fd5a08c430 | 313 | //--------------------------------------------Fonctions d'interruptions et de vérifications------------------------------------------------------------------ |
AdrienSalle | 0:32fd5a08c430 | 314 | |
AdrienSalle | 0:32fd5a08c430 | 315 | void servo_interrupt_en(void); |
AdrienSalle | 0:32fd5a08c430 | 316 | |
AdrienSalle | 0:32fd5a08c430 | 317 | void Interrupt1_en(void); |
AdrienSalle | 0:32fd5a08c430 | 318 | |
AdrienSalle | 0:32fd5a08c430 | 319 | void Interrupt2_en(void); |
AdrienSalle | 0:32fd5a08c430 | 320 | |
AdrienSalle | 0:32fd5a08c430 | 321 | void Interrupt3_en(void); |
AdrienSalle | 0:32fd5a08c430 | 322 | |
AdrienSalle | 0:32fd5a08c430 | 323 | void Interrupt4_en(void); |
AdrienSalle | 0:32fd5a08c430 | 324 | |
AdrienSalle | 0:32fd5a08c430 | 325 | void Interrupt5_en(void); |
AdrienSalle | 0:32fd5a08c430 | 326 | |
AdrienSalle | 0:32fd5a08c430 | 327 | void automate_serial1(void); |
AdrienSalle | 0:32fd5a08c430 | 328 | |
AdrienSalle | 0:32fd5a08c430 | 329 | void automate_serial2(void); |
AdrienSalle | 0:32fd5a08c430 | 330 | |
AdrienSalle | 0:32fd5a08c430 | 331 | void automate_serial3(void); |
AdrienSalle | 0:32fd5a08c430 | 332 | |
AdrienSalle | 0:32fd5a08c430 | 333 | void automate_serial4(void); |
AdrienSalle | 0:32fd5a08c430 | 334 | |
AdrienSalle | 0:32fd5a08c430 | 335 | void automate_serial5(void); |
kyxstark | 8:bde29d98f783 | 336 | /* |
AdrienSalle | 0:32fd5a08c430 | 337 | void Pompe_init(PinName Pompe_pin); |
AdrienSalle | 0:32fd5a08c430 | 338 | |
kyxstark | 8:bde29d98f783 | 339 | void Pompe_essai(PinName Pompe_pin);*/ |
AdrienSalle | 0:32fd5a08c430 | 340 | |
AdrienSalle | 0:32fd5a08c430 | 341 | //----------------Définition des ports série en variables externes--------------------------- |
AdrienSalle | 0:32fd5a08c430 | 342 | /* |
AdrienSalle | 0:32fd5a08c430 | 343 | * permet d'utiliser les ports série dans le main.ci |
AdrienSalle | 0:32fd5a08c430 | 344 | */ |
kyxstark | 6:81733a7b69e9 | 345 | //extern RawSerial pc; |
AdrienSalle | 0:32fd5a08c430 | 346 | extern RawSerial serial5; |
AdrienSalle | 0:32fd5a08c430 | 347 | extern RawSerial serial4; |
AdrienSalle | 0:32fd5a08c430 | 348 | extern RawSerial serial3; |
AdrienSalle | 0:32fd5a08c430 | 349 | extern RawSerial serial2; |
AdrienSalle | 0:32fd5a08c430 | 350 | extern RawSerial serial1; |
AdrienSalle | 0:32fd5a08c430 | 351 | //extern RawSerial serial1; |
AdrienSalle | 0:32fd5a08c430 | 352 | //#define Serial1 serial4 |
AdrienSalle | 0:32fd5a08c430 | 353 | |
kyxstark | 8:bde29d98f783 | 354 | #endif |