code petit robot pour homologation

Fork of CRAC-Strat_2017_V2 by CRAC Team

Committer:
ClementBreteau
Date:
Fri May 19 17:13:46 2017 +0000
Revision:
16:7321fb3bb396
Parent:
15:c2fc239e85df
strat du robot, ann?e 2017, le 19 mai ? 19h

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ClementBreteau 15:c2fc239e85df 1 /* mbed AX-12+ Servo Library
ClementBreteau 15:c2fc239e85df 2 *
ClementBreteau 15:c2fc239e85df 3 * Copyright (c) 2010, cstyles (http://mbed.org)
ClementBreteau 15:c2fc239e85df 4 *
ClementBreteau 15:c2fc239e85df 5 * Permission is hereby granted, free of charge, to any person obtaining a copy
ClementBreteau 15:c2fc239e85df 6 * of this software and associated documentation files (the "Software"), to deal
ClementBreteau 15:c2fc239e85df 7 * in the Software without restriction, including without limitation the rights
ClementBreteau 15:c2fc239e85df 8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
ClementBreteau 15:c2fc239e85df 9 * copies of the Software, and to permit persons to whom the Software is
ClementBreteau 15:c2fc239e85df 10 * furnished to do so, subject to the following conditions:
ClementBreteau 15:c2fc239e85df 11 *
ClementBreteau 15:c2fc239e85df 12 * The above copyright notice and this permission notice shall be included in
ClementBreteau 15:c2fc239e85df 13 * all copies or substantial portions of the Software.
ClementBreteau 15:c2fc239e85df 14 *
ClementBreteau 15:c2fc239e85df 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
ClementBreteau 15:c2fc239e85df 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
ClementBreteau 15:c2fc239e85df 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
ClementBreteau 15:c2fc239e85df 18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
ClementBreteau 15:c2fc239e85df 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
ClementBreteau 15:c2fc239e85df 20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
ClementBreteau 15:c2fc239e85df 21 * THE SOFTWARE.
ClementBreteau 15:c2fc239e85df 22 */
ClementBreteau 15:c2fc239e85df 23
ClementBreteau 16:7321fb3bb396 24
ClementBreteau 16:7321fb3bb396 25
ClementBreteau 16:7321fb3bb396 26
ClementBreteau 15:c2fc239e85df 27 #ifndef MBED_AX12_H
ClementBreteau 15:c2fc239e85df 28 #define MBED_AX12_H
ClementBreteau 16:7321fb3bb396 29
ClementBreteau 15:c2fc239e85df 30 #include "global.h"
ClementBreteau 15:c2fc239e85df 31
ClementBreteau 15:c2fc239e85df 32 //#define AX12_WRITE_DEBUG 0
ClementBreteau 16:7321fb3bb396 33 //#define AX12_READ_DEBUG
ClementBreteau 15:c2fc239e85df 34 //#define AX12_TRIGGER_DEBUG 0
ClementBreteau 16:7321fb3bb396 35 //#define AX12_DEBUG 0
ClementBreteau 15:c2fc239e85df 36
ClementBreteau 15:c2fc239e85df 37 /****** à utiliser pour le debug !! ******/
ClementBreteau 15:c2fc239e85df 38
ClementBreteau 15:c2fc239e85df 39 //#define AX12_DEBUG_WRITE 0
ClementBreteau 15:c2fc239e85df 40 //#define AX12_DEBUG_READ 0
ClementBreteau 15:c2fc239e85df 41
ClementBreteau 15:c2fc239e85df 42 /******************************************/
ClementBreteau 15:c2fc239e85df 43
ClementBreteau 15:c2fc239e85df 44
ClementBreteau 16:7321fb3bb396 45
ClementBreteau 16:7321fb3bb396 46
ClementBreteau 15:c2fc239e85df 47 #define AX12_REG_ID 0x03
ClementBreteau 15:c2fc239e85df 48 #define AX12_REG_BAUD 0x04
ClementBreteau 15:c2fc239e85df 49 #define AX12_REG_DELAY_TIME 0x05
ClementBreteau 15:c2fc239e85df 50 #define AX12_REG_CW_LIMIT 0x06
ClementBreteau 15:c2fc239e85df 51 #define AX12_REG_CCW_LIMIT 0x08
ClementBreteau 15:c2fc239e85df 52 #define AX12_REG_TEMP_MAX 0x0B
ClementBreteau 15:c2fc239e85df 53 #define AX12_REG_LOWEST_VOLTAGE 0x0C
ClementBreteau 15:c2fc239e85df 54 #define AX12_REG_HIGHEST_VOLTAGE 0x0D
ClementBreteau 15:c2fc239e85df 55 #define AX12_REG_MAX_TORQUE 0x0E
ClementBreteau 15:c2fc239e85df 56 #define AX12_REG_SATUS_RETURN 0x10
ClementBreteau 15:c2fc239e85df 57 #define AX12_REG_ALARM_LED 0x11
ClementBreteau 15:c2fc239e85df 58 #define AX12_REG_ALARM_SHUTDOWN 0x12
ClementBreteau 15:c2fc239e85df 59 #define AX12_REG_DOWN_CALIBRATION 0x14
ClementBreteau 15:c2fc239e85df 60 #define AX12_REG_UP_CALIBRATION 0x16
ClementBreteau 15:c2fc239e85df 61 #define AX12_REG_TORQUE_ENABLE 0x18
ClementBreteau 15:c2fc239e85df 62 #define AX12_REG_LED 0x19
ClementBreteau 15:c2fc239e85df 63 #define AX12_REG_CW_MARGIN 0x1A
ClementBreteau 15:c2fc239e85df 64 #define AX12_REG_CCW_MARGIN 0x1B
ClementBreteau 15:c2fc239e85df 65 #define AX12_REG_CW_SLOPE 0x1C
ClementBreteau 15:c2fc239e85df 66 #define AX12_REG_CCW_SLOPE 0x1D
ClementBreteau 15:c2fc239e85df 67 #define AX12_REG_GOAL_POSITION 0x1E
ClementBreteau 15:c2fc239e85df 68 #define AX12_REG_MOVING_SPEED 0x20
ClementBreteau 15:c2fc239e85df 69 #define AX12_REG_TORQUE_LIMIT 0x22
ClementBreteau 15:c2fc239e85df 70 #define AX12_REG_POSITION 0x24
ClementBreteau 15:c2fc239e85df 71 #define AX12_REG_PRESENT_SPEED 0x26
ClementBreteau 15:c2fc239e85df 72 #define AX12_REG_PRESENT_LOAD 0x28
ClementBreteau 15:c2fc239e85df 73 #define AX12_REG_VOLTS 0x2A
ClementBreteau 15:c2fc239e85df 74 #define AX12_REG_TEMP 0x2B
ClementBreteau 15:c2fc239e85df 75 #define AX12_REG_INSTRUCTION 0x2C
ClementBreteau 15:c2fc239e85df 76 #define AX12_REG_MOVING 0x2E
ClementBreteau 15:c2fc239e85df 77 #define AX12_REG_LOCK 0x2F
ClementBreteau 15:c2fc239e85df 78 #define AX12_REG_PUNCH 0x30
ClementBreteau 15:c2fc239e85df 79
ClementBreteau 15:c2fc239e85df 80
ClementBreteau 15:c2fc239e85df 81 #define AX12_MODE_POSITION 0
ClementBreteau 15:c2fc239e85df 82 #define AX12_MODE_ROTATION 1
ClementBreteau 15:c2fc239e85df 83
ClementBreteau 15:c2fc239e85df 84 #define AX12_CW 1
ClementBreteau 15:c2fc239e85df 85 #define AX12_CCW 0
ClementBreteau 15:c2fc239e85df 86
ClementBreteau 15:c2fc239e85df 87 //--- Instruction ---
ClementBreteau 15:c2fc239e85df 88 #define INST_PING 0x01
ClementBreteau 15:c2fc239e85df 89 #define INST_READ 0x02
ClementBreteau 15:c2fc239e85df 90 #define INST_WRITE 0x03
ClementBreteau 15:c2fc239e85df 91 #define INST_REG_WRITE 0x04
ClementBreteau 15:c2fc239e85df 92 #define INST_ACTION 0x05
ClementBreteau 15:c2fc239e85df 93 #define INST_RESET 0x06
ClementBreteau 15:c2fc239e85df 94 #define INST_DIGITAL_RESET 0x07
ClementBreteau 15:c2fc239e85df 95 #define INST_SYSTEM_READ 0x0C
ClementBreteau 15:c2fc239e85df 96 #define INST_SYSTEM_WRITE 0x0D
ClementBreteau 15:c2fc239e85df 97 #define INST_SYNC_WRITE 0x83
ClementBreteau 15:c2fc239e85df 98 #define INST_SYNC_REG_WRITE 0x84
ClementBreteau 15:c2fc239e85df 99
ClementBreteau 15:c2fc239e85df 100 #define DEFAULT_RETURN_PACKET_SIZE 6
ClementBreteau 15:c2fc239e85df 101
ClementBreteau 15:c2fc239e85df 102 #define BROADCASTING_ID 0xfe
ClementBreteau 15:c2fc239e85df 103
ClementBreteau 15:c2fc239e85df 104 /** Servo control class, based on a PwmOut
ClementBreteau 15:c2fc239e85df 105 *
ClementBreteau 15:c2fc239e85df 106 * Example:
ClementBreteau 15:c2fc239e85df 107 * @code
ClementBreteau 15:c2fc239e85df 108 * #include "mbed.h"
ClementBreteau 15:c2fc239e85df 109 * #include "AX12.h"
ClementBreteau 15:c2fc239e85df 110 *
ClementBreteau 15:c2fc239e85df 111 * int main() {
ClementBreteau 15:c2fc239e85df 112 *
ClementBreteau 15:c2fc239e85df 113 * AX12 myax12 (p9, p10, 1);
ClementBreteau 15:c2fc239e85df 114 *
ClementBreteau 15:c2fc239e85df 115 * while (1) {
ClementBreteau 15:c2fc239e85df 116 * myax12.SetGoal(0); // go to 0 degrees
ClementBreteau 15:c2fc239e85df 117 * wait (2.0);
ClementBreteau 15:c2fc239e85df 118 * myax12.SetGoal(300); // go to 300 degrees
ClementBreteau 15:c2fc239e85df 119 * wait (2.0);
ClementBreteau 15:c2fc239e85df 120 * }
ClementBreteau 15:c2fc239e85df 121 * }
ClementBreteau 15:c2fc239e85df 122 * @endcode
ClementBreteau 15:c2fc239e85df 123 */
ClementBreteau 15:c2fc239e85df 124 class AX12
ClementBreteau 15:c2fc239e85df 125 {
ClementBreteau 15:c2fc239e85df 126
ClementBreteau 15:c2fc239e85df 127 public:
ClementBreteau 15:c2fc239e85df 128
ClementBreteau 15:c2fc239e85df 129 /** Create an AX12 servo object connected to the specified serial port, with the specified ID
ClementBreteau 15:c2fc239e85df 130 *
ClementBreteau 15:c2fc239e85df 131 * @param pin tx pin
ClementBreteau 15:c2fc239e85df 132 * @param pin rx pin
ClementBreteau 15:c2fc239e85df 133 * @param int ID, the Bus ID of the servo 1-255
ClementBreteau 15:c2fc239e85df 134 */
ClementBreteau 15:c2fc239e85df 135 AX12(PinName tx, PinName rx, int ID, int baud=1000000);
ClementBreteau 15:c2fc239e85df 136
ClementBreteau 15:c2fc239e85df 137 /** Nouvelle fonction de commande de position du servomoteur avec sécurité d'arriver à la bonne position
ClementBreteau 15:c2fc239e85df 138 Si une erreur se produit et que le servo ne recoit vraiment rien cette fonction dispose d'une sortie en timeout error;
ClementBreteau 15:c2fc239e85df 139 */
ClementBreteau 15:c2fc239e85df 140 int Set_Secure_Goal(int degres);
ClementBreteau 15:c2fc239e85df 141
ClementBreteau 15:c2fc239e85df 142 /** Retourne le temps d'attente avant l'envoi de la trame de retour par l'actionneur ( en micro seconde )
ClementBreteau 15:c2fc239e85df 143 */
ClementBreteau 15:c2fc239e85df 144 int Get_Return_Delay_Time(void);
ClementBreteau 15:c2fc239e85df 145
ClementBreteau 15:c2fc239e85df 146
ClementBreteau 15:c2fc239e85df 147 /** Retourne la vitesse de communication de l'actionneur ( en Bits/seconde )
ClementBreteau 15:c2fc239e85df 148 */
ClementBreteau 15:c2fc239e85df 149 int Get_Baud_Rate(void);
ClementBreteau 15:c2fc239e85df 150
ClementBreteau 15:c2fc239e85df 151
ClementBreteau 15:c2fc239e85df 152 /** Reglage du courant minimum necessaire au bon fonctionnement de l'actionneur
ClementBreteau 15:c2fc239e85df 153 // minimum >> Ox000 >> decimal 0
ClementBreteau 15:c2fc239e85df 154 // maximum >> 0x3FF >> decimal 1023
ClementBreteau 15:c2fc239e85df 155 // deflaut >> 0x20 >> decimal 32
ClementBreteau 15:c2fc239e85df 156 */
ClementBreteau 15:c2fc239e85df 157 int Set_Punch(int punch);
ClementBreteau 15:c2fc239e85df 158
ClementBreteau 15:c2fc239e85df 159
ClementBreteau 15:c2fc239e85df 160 /** Retourne le courant minimum au fonctionnement de l'actionneur
ClementBreteau 15:c2fc239e85df 161 */
ClementBreteau 15:c2fc239e85df 162 int Get_Punch (void);
ClementBreteau 15:c2fc239e85df 163
ClementBreteau 15:c2fc239e85df 164
ClementBreteau 15:c2fc239e85df 165 /** Retourne l'ampleur de la charge sur l'actionneur
ClementBreteau 15:c2fc239e85df 166 */
ClementBreteau 15:c2fc239e85df 167 int Get_Load_Value (void);
ClementBreteau 15:c2fc239e85df 168
ClementBreteau 15:c2fc239e85df 169 void read_all_info(unsigned char, unsigned char);
ClementBreteau 15:c2fc239e85df 170
ClementBreteau 15:c2fc239e85df 171 /** Reset
ClementBreteau 15:c2fc239e85df 172 */
ClementBreteau 15:c2fc239e85df 173 int Reset(int);
ClementBreteau 15:c2fc239e85df 174
ClementBreteau 15:c2fc239e85df 175 /** Retourne la direction de la charge sur l'actionneur
ClementBreteau 15:c2fc239e85df 176 */
ClementBreteau 15:c2fc239e85df 177 int Get_Load_Direction (void);
ClementBreteau 15:c2fc239e85df 178
ClementBreteau 15:c2fc239e85df 179
ClementBreteau 15:c2fc239e85df 180 /** Retourne la vitesse angulaire actuelle de l'actionneur
ClementBreteau 15:c2fc239e85df 181 */
ClementBreteau 15:c2fc239e85df 182 int Get_Present_Speed (void);
ClementBreteau 15:c2fc239e85df 183
ClementBreteau 15:c2fc239e85df 184
ClementBreteau 15:c2fc239e85df 185 /** Retourne la valeur en degres du registre CCW angle limit qui est l'angle limite maximum de l'actionneur
ClementBreteau 15:c2fc239e85df 186 */
ClementBreteau 15:c2fc239e85df 187 int Get_CCW_Angle_Limit (void);
ClementBreteau 15:c2fc239e85df 188
ClementBreteau 15:c2fc239e85df 189
ClementBreteau 15:c2fc239e85df 190 /** Retourne la valeur en degres du registre CW angle limit qui est l'angle limite minimum de l'actionneur
ClementBreteau 15:c2fc239e85df 191 */
ClementBreteau 15:c2fc239e85df 192 int Get_CW_Angle_Limit (void);
ClementBreteau 15:c2fc239e85df 193
ClementBreteau 15:c2fc239e85df 194
ClementBreteau 15:c2fc239e85df 195 /** Retourne la valeur du registre Torque Enable
ClementBreteau 15:c2fc239e85df 196 */
ClementBreteau 15:c2fc239e85df 197 int Get_Torque_Enable(void);
ClementBreteau 15:c2fc239e85df 198
ClementBreteau 15:c2fc239e85df 199
ClementBreteau 15:c2fc239e85df 200 /**
ClementBreteau 15:c2fc239e85df 201 1 >>>
ClementBreteau 15:c2fc239e85df 202 0 >>>
ClementBreteau 15:c2fc239e85df 203 */
ClementBreteau 15:c2fc239e85df 204 int Set_Torque_Enable(int etat);
ClementBreteau 15:c2fc239e85df 205
ClementBreteau 15:c2fc239e85df 206
ClementBreteau 15:c2fc239e85df 207 /** Retourne les données de compensation des différences entre les potentiomètres
ClementBreteau 15:c2fc239e85df 208 utilisés dans l'AX12 (Up) ????????
ClementBreteau 15:c2fc239e85df 209 */
ClementBreteau 15:c2fc239e85df 210 int Get_Up_Calibration (void);
ClementBreteau 15:c2fc239e85df 211
ClementBreteau 15:c2fc239e85df 212
ClementBreteau 15:c2fc239e85df 213 /** Retourne les données de compensation des différences entre les potentiomètres
ClementBreteau 15:c2fc239e85df 214 utilisés dans l'AX12 (Dowm) ????????
ClementBreteau 15:c2fc239e85df 215 */
ClementBreteau 15:c2fc239e85df 216 int Get_Down_Calibration(void);
ClementBreteau 15:c2fc239e85df 217
ClementBreteau 15:c2fc239e85df 218
ClementBreteau 15:c2fc239e85df 219 /** Retourne l'ID de l'AX_12 avec lequel on dialogue
ClementBreteau 15:c2fc239e85df 220 utile seulement dans le cas d'un broadcast ID
ClementBreteau 15:c2fc239e85df 221 */
ClementBreteau 15:c2fc239e85df 222 int Get_ID(void);
ClementBreteau 15:c2fc239e85df 223
ClementBreteau 15:c2fc239e85df 224
ClementBreteau 15:c2fc239e85df 225 /** Reglage du couple maximum de l'actionneur
ClementBreteau 15:c2fc239e85df 226 // minimum >> Ox000 >> decimal 0
ClementBreteau 15:c2fc239e85df 227 // maximum >> 0x3FF >> decimal 1023
ClementBreteau 15:c2fc239e85df 228 // deflaut >> >> decimal
ClementBreteau 15:c2fc239e85df 229 */
ClementBreteau 15:c2fc239e85df 230 int Set_Max_Torque(int torque);
ClementBreteau 15:c2fc239e85df 231
ClementBreteau 15:c2fc239e85df 232
ClementBreteau 15:c2fc239e85df 233 /** Reglage de la desactivation des actionneurs si une erreur le concernant se produit
ClementBreteau 15:c2fc239e85df 234 Bit Function
ClementBreteau 15:c2fc239e85df 235 Bit 7 0
ClementBreteau 15:c2fc239e85df 236 Bit 6 If set to 1, torque off when an Instruction Error occurs
ClementBreteau 15:c2fc239e85df 237 Bit 5 If set to 1, torque off when an Overload Error occurs
ClementBreteau 15:c2fc239e85df 238 Bit 4 If set to 1, torque off when a Checksum Error occurs
ClementBreteau 15:c2fc239e85df 239 Bit 3 If set to 1, torque off when a Range Error occurs
ClementBreteau 15:c2fc239e85df 240 Bit 2 If set to 1, torque off when an Overheating Error occurs
ClementBreteau 15:c2fc239e85df 241 Bit 1 If set to 1, torque off when an Angle Limit Error occurs
ClementBreteau 15:c2fc239e85df 242 Bit 0 If set to 1, torque off when an Input Voltage Error occurs
ClementBreteau 15:c2fc239e85df 243 */
ClementBreteau 15:c2fc239e85df 244 int Set_Alarm_Shutdown(int valeur);
ClementBreteau 15:c2fc239e85df 245
ClementBreteau 15:c2fc239e85df 246
ClementBreteau 15:c2fc239e85df 247 /** Reglage de l'activation de l'alarme
ClementBreteau 15:c2fc239e85df 248 Bit Function
ClementBreteau 15:c2fc239e85df 249 Bit 7 0
ClementBreteau 15:c2fc239e85df 250 Bit 6 If set to 1, the LED blinks when an Instruction Error occurs
ClementBreteau 15:c2fc239e85df 251 Bit 5 If set to 1, the LED blinks when an Overload Error occurs
ClementBreteau 15:c2fc239e85df 252 Bit 4 If set to 1, the LED blinks when a Checksum Error occurs
ClementBreteau 15:c2fc239e85df 253 Bit 3 If set to 1, the LED blinks when a Range Error occurs
ClementBreteau 15:c2fc239e85df 254 Bit 2 If set to 1, the LED blinks when an Overheating Error occurs
ClementBreteau 15:c2fc239e85df 255 Bit 1 If set to 1, the LED blinks when an Angle Limit Error occurs
ClementBreteau 15:c2fc239e85df 256 Bit 0 If set to 1, the LED blinks when an Input Voltage Error occurs
ClementBreteau 15:c2fc239e85df 257 */
ClementBreteau 15:c2fc239e85df 258 int Set_Alarm_LED(int valeur);
ClementBreteau 15:c2fc239e85df 259
ClementBreteau 15:c2fc239e85df 260
ClementBreteau 15:c2fc239e85df 261 /** Reglage de la réponse à une instruction
ClementBreteau 15:c2fc239e85df 262 * @param mode
ClementBreteau 15:c2fc239e85df 263 * 0 >> ne repond a aucune instructions
ClementBreteau 15:c2fc239e85df 264 * 1 >> repond seulement aux instructions READ_DATA
ClementBreteau 15:c2fc239e85df 265 * 2 >> repond à toutes les instructions
ClementBreteau 15:c2fc239e85df 266 */
ClementBreteau 15:c2fc239e85df 267 int Set_Status_Return_Level(int etat);
ClementBreteau 15:c2fc239e85df 268
ClementBreteau 15:c2fc239e85df 269
ClementBreteau 15:c2fc239e85df 270 /** Reglage de la tension minimale
ClementBreteau 15:c2fc239e85df 271 * @param mode
ClementBreteau 15:c2fc239e85df 272 * minimum >> 0x32 >> decimal 50
ClementBreteau 15:c2fc239e85df 273 * maximum >> 0xFA >> decimal 250
ClementBreteau 15:c2fc239e85df 274 * deflaut >> 0x3C >> decimal 60
ClementBreteau 15:c2fc239e85df 275 */
ClementBreteau 15:c2fc239e85df 276 int Set_Lowest_Voltage(int val_lowest_voltage);
ClementBreteau 15:c2fc239e85df 277
ClementBreteau 15:c2fc239e85df 278
ClementBreteau 15:c2fc239e85df 279 /** Reglage de la tension maximale
ClementBreteau 15:c2fc239e85df 280 * @param mode
ClementBreteau 15:c2fc239e85df 281 * minimum >> Ox32 >> decimal 50
ClementBreteau 15:c2fc239e85df 282 * maximum >> 0xFA >> decimal 250
ClementBreteau 15:c2fc239e85df 283 * deflaut >> 0xBE >> decimal 190
ClementBreteau 15:c2fc239e85df 284 */
ClementBreteau 15:c2fc239e85df 285 int Set_Highest_Voltage(int val_highest_voltage);
ClementBreteau 15:c2fc239e85df 286
ClementBreteau 15:c2fc239e85df 287
ClementBreteau 15:c2fc239e85df 288 // Reglage du return time delay EN MICRO SECONDE 2uSec * val_delay_time
ClementBreteau 15:c2fc239e85df 289 // minimum >> 0 us
ClementBreteau 15:c2fc239e85df 290 // maximum >> 508 us
ClementBreteau 15:c2fc239e85df 291 // deflaut >> 125 us
ClementBreteau 15:c2fc239e85df 292 int Set_Delay_Time (int val_delay_time );
ClementBreteau 15:c2fc239e85df 293
ClementBreteau 15:c2fc239e85df 294
ClementBreteau 15:c2fc239e85df 295 /** Set Highest Limit Temperature
ClementBreteau 15:c2fc239e85df 296 * @param mode
ClementBreteau 15:c2fc239e85df 297 * minimum >> Ox00 >> decimal 0
ClementBreteau 15:c2fc239e85df 298 * maximum >> 0x96 >> decimal 150
ClementBreteau 15:c2fc239e85df 299 */
ClementBreteau 15:c2fc239e85df 300 int Set_Temperature_Max (int val_temperature );
ClementBreteau 15:c2fc239e85df 301
ClementBreteau 15:c2fc239e85df 302
ClementBreteau 15:c2fc239e85df 303
ClementBreteau 15:c2fc239e85df 304 /** Set the state of LED
ClementBreteau 15:c2fc239e85df 305 * @param mode
ClementBreteau 15:c2fc239e85df 306 * 0 = off, default
ClementBreteau 15:c2fc239e85df 307 * 1 = on
ClementBreteau 15:c2fc239e85df 308 */
ClementBreteau 15:c2fc239e85df 309 int Set_Etat_LED(int etat);
ClementBreteau 15:c2fc239e85df 310
ClementBreteau 15:c2fc239e85df 311
ClementBreteau 15:c2fc239e85df 312
ClementBreteau 15:c2fc239e85df 313 /** Set the mode of the servo
ClementBreteau 15:c2fc239e85df 314 * @param mode
ClementBreteau 15:c2fc239e85df 315 * 0 = Positional, default
ClementBreteau 15:c2fc239e85df 316 * 1 = Continuous rotation
ClementBreteau 15:c2fc239e85df 317 */
ClementBreteau 15:c2fc239e85df 318 int Set_Mode(int mode);
ClementBreteau 15:c2fc239e85df 319
ClementBreteau 15:c2fc239e85df 320 /** Set baud rate of all attached servos
ClementBreteau 15:c2fc239e85df 321 * @param mode
ClementBreteau 15:c2fc239e85df 322 * 0x01 = 1,000,000 bps
ClementBreteau 15:c2fc239e85df 323 * 0x03 = 500,000 bps
ClementBreteau 15:c2fc239e85df 324 * 0x04 = 400,000 bps
ClementBreteau 15:c2fc239e85df 325 * 0x07 = 250,000 bps
ClementBreteau 15:c2fc239e85df 326 * 0x09 = 200,000 bps
ClementBreteau 15:c2fc239e85df 327 * 0x10 = 115,200 bps
ClementBreteau 15:c2fc239e85df 328 * 0x22 = 57,600 bps
ClementBreteau 15:c2fc239e85df 329 * 0x67 = 19,200 bps
ClementBreteau 15:c2fc239e85df 330 * 0xCF = 9,600 bp
ClementBreteau 15:c2fc239e85df 331 */
ClementBreteau 15:c2fc239e85df 332 int Set_Baud(int baud);
ClementBreteau 15:c2fc239e85df 333
ClementBreteau 15:c2fc239e85df 334
ClementBreteau 15:c2fc239e85df 335 /** Set goal angle in integer degrees, in positional mode
ClementBreteau 15:c2fc239e85df 336 *
ClementBreteau 15:c2fc239e85df 337 * @param degrees 0-300
ClementBreteau 15:c2fc239e85df 338 * @param flags, defaults to 0
ClementBreteau 15:c2fc239e85df 339 * flags[0] = blocking, return when goal position reached
ClementBreteau 15:c2fc239e85df 340 * flags[1] = register, activate with a broadcast trigger
ClementBreteau 15:c2fc239e85df 341 *
ClementBreteau 15:c2fc239e85df 342 */
ClementBreteau 15:c2fc239e85df 343 int Set_Goal(int degrees, int flags = 0);
ClementBreteau 15:c2fc239e85df 344
ClementBreteau 15:c2fc239e85df 345 int Set_Goal_speed(int degrees, int flags = 0);
ClementBreteau 15:c2fc239e85df 346
ClementBreteau 15:c2fc239e85df 347 /** Set the speed of the servo in continuous rotation mode
ClementBreteau 15:c2fc239e85df 348 *
ClementBreteau 15:c2fc239e85df 349 * @param speed, -1.0 to 1.0
ClementBreteau 15:c2fc239e85df 350 * -1.0 = full speed counter clock wise
ClementBreteau 15:c2fc239e85df 351 * 1.0 = full speed clock wise
ClementBreteau 15:c2fc239e85df 352 */
ClementBreteau 15:c2fc239e85df 353 int Set_CR_Speed(float speed);
ClementBreteau 15:c2fc239e85df 354
ClementBreteau 15:c2fc239e85df 355
ClementBreteau 15:c2fc239e85df 356 /** Permet de définir l'angle limite minimum de l'actionneur ( prend une valeur d'entrée en degres )
ClementBreteau 15:c2fc239e85df 357 // minimum >> 0°
ClementBreteau 15:c2fc239e85df 358 // maximum >> 300°
ClementBreteau 15:c2fc239e85df 359 // deflaut >> 0°
ClementBreteau 15:c2fc239e85df 360 */
ClementBreteau 15:c2fc239e85df 361 int Set_CW_Angle_Limit(int degrees);
ClementBreteau 15:c2fc239e85df 362
ClementBreteau 15:c2fc239e85df 363 /** Permet de définir l'angle limite maximum de l'actionneur ( prend une valeur d'entrée en degres )
ClementBreteau 15:c2fc239e85df 364 // minimum >> 0°
ClementBreteau 15:c2fc239e85df 365 // maximum >> 300°
ClementBreteau 15:c2fc239e85df 366 // deflaut >> 300°
ClementBreteau 15:c2fc239e85df 367 */
ClementBreteau 15:c2fc239e85df 368 int Set_CCW_Angle_Limit(int degrees);
ClementBreteau 15:c2fc239e85df 369
ClementBreteau 15:c2fc239e85df 370 // Change the ID
ClementBreteau 15:c2fc239e85df 371
ClementBreteau 15:c2fc239e85df 372 /** Change the ID of a servo
ClementBreteau 15:c2fc239e85df 373 *
ClementBreteau 15:c2fc239e85df 374 * @param CurentID 1-255
ClementBreteau 15:c2fc239e85df 375 * @param NewID 1-255
ClementBreteau 15:c2fc239e85df 376 *
ClementBreteau 15:c2fc239e85df 377 * If a servo ID is not know, the broadcast address of 0 can be used for CurrentID.
ClementBreteau 15:c2fc239e85df 378 * In this situation, only one servo should be connected to the bus
ClementBreteau 15:c2fc239e85df 379 */
ClementBreteau 15:c2fc239e85df 380 int Set_ID(int CurrentID, int NewID);
ClementBreteau 15:c2fc239e85df 381
ClementBreteau 15:c2fc239e85df 382
ClementBreteau 15:c2fc239e85df 383 /** Poll to see if the servo is moving
ClementBreteau 15:c2fc239e85df 384 *
ClementBreteau 15:c2fc239e85df 385 * @returns true is the servo is moving
ClementBreteau 15:c2fc239e85df 386 */
ClementBreteau 15:c2fc239e85df 387 int isMoving(void);
ClementBreteau 15:c2fc239e85df 388
ClementBreteau 15:c2fc239e85df 389 /** Send the broadcast "trigger" command, to activate any outstanding registered commands
ClementBreteau 15:c2fc239e85df 390 */
ClementBreteau 15:c2fc239e85df 391 void trigger(void);
ClementBreteau 15:c2fc239e85df 392
ClementBreteau 15:c2fc239e85df 393 /** Send the "reset" command, to activate any outstanding registered commands
ClementBreteau 15:c2fc239e85df 394 */
ClementBreteau 15:c2fc239e85df 395 void reset();
ClementBreteau 15:c2fc239e85df 396
ClementBreteau 15:c2fc239e85df 397 /** Read the current angle of the servo
ClementBreteau 15:c2fc239e85df 398 *
ClementBreteau 15:c2fc239e85df 399 * @returns float in the range 0.0-300.0
ClementBreteau 15:c2fc239e85df 400 */
ClementBreteau 15:c2fc239e85df 401 float Get_Position();
ClementBreteau 15:c2fc239e85df 402
ClementBreteau 15:c2fc239e85df 403 /** Read the temperature of the servo
ClementBreteau 15:c2fc239e85df 404 *
ClementBreteau 15:c2fc239e85df 405 * @returns float temperature
ClementBreteau 15:c2fc239e85df 406 */
ClementBreteau 15:c2fc239e85df 407 float Get_Temp(void);
ClementBreteau 15:c2fc239e85df 408
ClementBreteau 15:c2fc239e85df 409 /** Read the supply voltage of the servo
ClementBreteau 15:c2fc239e85df 410 *
ClementBreteau 15:c2fc239e85df 411 * @returns float voltage
ClementBreteau 15:c2fc239e85df 412 */
ClementBreteau 15:c2fc239e85df 413 float Get_Volts(void);
ClementBreteau 15:c2fc239e85df 414
ClementBreteau 15:c2fc239e85df 415 // Lecture du couple maximum ( retourne la valeur du registre Max Torque de l'AX12 )
ClementBreteau 15:c2fc239e85df 416 int Get_Max_Torque (void);
ClementBreteau 15:c2fc239e85df 417
ClementBreteau 15:c2fc239e85df 418
ClementBreteau 15:c2fc239e85df 419 int read(int ID, int start, int length, char* data);
ClementBreteau 15:c2fc239e85df 420 int write(int ID, int start, int length, char* data, int flag=0);
ClementBreteau 15:c2fc239e85df 421 void multiple_goal_and_speed(int number_ax12,char* tab);
ClementBreteau 15:c2fc239e85df 422 float read_and_test(float angle,char* Tab);
ClementBreteau 15:c2fc239e85df 423
ClementBreteau 15:c2fc239e85df 424 private :
ClementBreteau 15:c2fc239e85df 425
ClementBreteau 15:c2fc239e85df 426 SerialHalfDuplex _ax12;
ClementBreteau 15:c2fc239e85df 427 int _ID;
ClementBreteau 15:c2fc239e85df 428 int _baud;
ClementBreteau 15:c2fc239e85df 429
ClementBreteau 15:c2fc239e85df 430
ClementBreteau 15:c2fc239e85df 431 };
ClementBreteau 15:c2fc239e85df 432
ClementBreteau 15:c2fc239e85df 433 #endif