pour trouver l'automate de reception can
Fork of CRAC-Strat_copy by
AX12-V2/AX12-V2.h@0:ad97421fb1fb, 2016-04-13 (annotated)
- Committer:
- antbig
- Date:
- Wed Apr 13 22:04:54 2016 +0000
- Revision:
- 0:ad97421fb1fb
- Child:
- 1:116040d14164
Ajout interruption fin de match
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
antbig | 0:ad97421fb1fb | 1 | #ifndef CRAC_AX12 |
antbig | 0:ad97421fb1fb | 2 | #define CRAC_AX12 |
antbig | 0:ad97421fb1fb | 3 | |
antbig | 0:ad97421fb1fb | 4 | #include "global.h" |
antbig | 0:ad97421fb1fb | 5 | |
antbig | 0:ad97421fb1fb | 6 | #define MAX_AX12 30 |
antbig | 0:ad97421fb1fb | 7 | |
antbig | 0:ad97421fb1fb | 8 | |
antbig | 0:ad97421fb1fb | 9 | #define AX12_REG_ID 0x03 |
antbig | 0:ad97421fb1fb | 10 | #define AX12_REG_BAUD 0x04 |
antbig | 0:ad97421fb1fb | 11 | #define AX12_REG_DELAY_TIME 0x05 |
antbig | 0:ad97421fb1fb | 12 | #define AX12_REG_CW_LIMIT 0x06 |
antbig | 0:ad97421fb1fb | 13 | #define AX12_REG_CCW_LIMIT 0x08 |
antbig | 0:ad97421fb1fb | 14 | #define AX12_REG_TEMP_MAX 0x0B |
antbig | 0:ad97421fb1fb | 15 | #define AX12_REG_LOWEST_VOLTAGE 0x0C |
antbig | 0:ad97421fb1fb | 16 | #define AX12_REG_HIGHEST_VOLTAGE 0x0D |
antbig | 0:ad97421fb1fb | 17 | #define AX12_REG_MAX_TORQUE 0x0E |
antbig | 0:ad97421fb1fb | 18 | #define AX12_REG_SATUS_RETURN 0x10 |
antbig | 0:ad97421fb1fb | 19 | #define AX12_REG_ALARM_LED 0x11 |
antbig | 0:ad97421fb1fb | 20 | #define AX12_REG_ALARM_SHUTDOWN 0x12 |
antbig | 0:ad97421fb1fb | 21 | #define AX12_REG_DOWN_CALIBRATION 0x14 |
antbig | 0:ad97421fb1fb | 22 | #define AX12_REG_UP_CALIBRATION 0x16 |
antbig | 0:ad97421fb1fb | 23 | #define AX12_REG_TORQUE_ENABLE 0x18 |
antbig | 0:ad97421fb1fb | 24 | #define AX12_REG_LED 0x19 |
antbig | 0:ad97421fb1fb | 25 | #define AX12_REG_CW_MARGIN 0x1A |
antbig | 0:ad97421fb1fb | 26 | #define AX12_REG_CCW_MARGIN 0x1B |
antbig | 0:ad97421fb1fb | 27 | #define AX12_REG_CW_SLOPE 0x1C |
antbig | 0:ad97421fb1fb | 28 | #define AX12_REG_CCW_SLOPE 0x1D |
antbig | 0:ad97421fb1fb | 29 | #define AX12_REG_GOAL_POSITION 0x1E |
antbig | 0:ad97421fb1fb | 30 | #define AX12_REG_MOVING_SPEED 0x20 |
antbig | 0:ad97421fb1fb | 31 | #define AX12_REG_TORQUE_LIMIT 0x22 |
antbig | 0:ad97421fb1fb | 32 | #define AX12_REG_POSITION 0x24 |
antbig | 0:ad97421fb1fb | 33 | #define AX12_REG_PRESENT_SPEED 0x26 |
antbig | 0:ad97421fb1fb | 34 | #define AX12_REG_PRESENT_LOAD 0x28 |
antbig | 0:ad97421fb1fb | 35 | #define AX12_REG_VOLTS 0x2A |
antbig | 0:ad97421fb1fb | 36 | #define AX12_REG_TEMP 0x2B |
antbig | 0:ad97421fb1fb | 37 | #define AX12_REG_INSTRUCTION 0x2C |
antbig | 0:ad97421fb1fb | 38 | #define AX12_REG_MOVING 0x2E |
antbig | 0:ad97421fb1fb | 39 | #define AX12_REG_LOCK 0x2F |
antbig | 0:ad97421fb1fb | 40 | #define AX12_REG_PUNCH 0x30 |
antbig | 0:ad97421fb1fb | 41 | |
antbig | 0:ad97421fb1fb | 42 | |
antbig | 0:ad97421fb1fb | 43 | #define AX12_MODE_POSITION 0 |
antbig | 0:ad97421fb1fb | 44 | #define AX12_MODE_ROTATION 1 |
antbig | 0:ad97421fb1fb | 45 | |
antbig | 0:ad97421fb1fb | 46 | #define AX12_CW 1 |
antbig | 0:ad97421fb1fb | 47 | #define AX12_CCW 0 |
antbig | 0:ad97421fb1fb | 48 | |
antbig | 0:ad97421fb1fb | 49 | //--- Instruction --- |
antbig | 0:ad97421fb1fb | 50 | #define INST_PING 0x01 |
antbig | 0:ad97421fb1fb | 51 | #define INST_READ 0x02 |
antbig | 0:ad97421fb1fb | 52 | #define INST_WRITE 0x03 |
antbig | 0:ad97421fb1fb | 53 | #define INST_REG_WRITE 0x04 |
antbig | 0:ad97421fb1fb | 54 | #define INST_ACTION 0x05 |
antbig | 0:ad97421fb1fb | 55 | #define INST_RESET 0x06 |
antbig | 0:ad97421fb1fb | 56 | #define INST_DIGITAL_RESET 0x07 |
antbig | 0:ad97421fb1fb | 57 | #define INST_SYSTEM_READ 0x0C |
antbig | 0:ad97421fb1fb | 58 | #define INST_SYSTEM_WRITE 0x0D |
antbig | 0:ad97421fb1fb | 59 | #define INST_SYNC_WRITE 0x83 |
antbig | 0:ad97421fb1fb | 60 | #define INST_SYNC_REG_WRITE 0x84 |
antbig | 0:ad97421fb1fb | 61 | |
antbig | 0:ad97421fb1fb | 62 | #define DEFAULT_RETURN_PACKET_SIZE 6 |
antbig | 0:ad97421fb1fb | 63 | |
antbig | 0:ad97421fb1fb | 64 | #define BROADCASTING_ID 0xfe |
antbig | 0:ad97421fb1fb | 65 | |
antbig | 0:ad97421fb1fb | 66 | #define MAX_TIMEOUT 5000 |
antbig | 0:ad97421fb1fb | 67 | |
antbig | 0:ad97421fb1fb | 68 | struct S_AX12 { |
antbig | 0:ad97421fb1fb | 69 | unsigned char id;//L'id de l'AX12 |
antbig | 0:ad97421fb1fb | 70 | unsigned short goal;//La position ou doit aller le robot |
antbig | 0:ad97421fb1fb | 71 | unsigned short speed;//La vitesse de déplacement du bras |
antbig | 0:ad97421fb1fb | 72 | unsigned char isUsingCAN;//Indique si il faut envoyer les information via CAN (0=>non | autre=>oui) |
antbig | 0:ad97421fb1fb | 73 | unsigned char needToUpdate;//Indique qu'il faut mettre à jour la position |
antbig | 0:ad97421fb1fb | 74 | }; |
antbig | 0:ad97421fb1fb | 75 | |
antbig | 0:ad97421fb1fb | 76 | /****************************************************************************************/ |
antbig | 0:ad97421fb1fb | 77 | /* FUNCTION NAME: AX12_register */ |
antbig | 0:ad97421fb1fb | 78 | /* DESCRIPTION : Indiquer qu'un AX12 est connecté à la carte */ |
antbig | 0:ad97421fb1fb | 79 | /****************************************************************************************/ |
antbig | 0:ad97421fb1fb | 80 | void AX12_register(unsigned char id, unsigned short speed = 0x3FF); |
antbig | 0:ad97421fb1fb | 81 | |
antbig | 0:ad97421fb1fb | 82 | /****************************************************************************************/ |
antbig | 0:ad97421fb1fb | 83 | /* FUNCTION NAME: AX12_setGoal */ |
antbig | 0:ad97421fb1fb | 84 | /* DESCRIPTION : Definir la position d'un ax12, !!Ne déclanche pas le mouvement */ |
antbig | 0:ad97421fb1fb | 85 | /****************************************************************************************/ |
antbig | 0:ad97421fb1fb | 86 | void AX12_setGoal(unsigned char id, unsigned short goal, unsigned short speed = 0x3FF); |
antbig | 0:ad97421fb1fb | 87 | |
antbig | 0:ad97421fb1fb | 88 | /****************************************************************************************/ |
antbig | 0:ad97421fb1fb | 89 | /* FUNCTION NAME: AX12_isLocal */ |
antbig | 0:ad97421fb1fb | 90 | /* DESCRIPTION : Savoir si un AX12 est enregistré sur la carte */ |
antbig | 0:ad97421fb1fb | 91 | /****************************************************************************************/ |
antbig | 0:ad97421fb1fb | 92 | unsigned char AX12_isLocal(unsigned char id); |
antbig | 0:ad97421fb1fb | 93 | |
antbig | 0:ad97421fb1fb | 94 | /****************************************************************************************/ |
antbig | 0:ad97421fb1fb | 95 | /* FUNCTION NAME: AX12_getLocalID */ |
antbig | 0:ad97421fb1fb | 96 | /* DESCRIPTION : Obtenir les info sur un AX12 ou l'initialiser si non présent */ |
antbig | 0:ad97421fb1fb | 97 | /****************************************************************************************/ |
antbig | 0:ad97421fb1fb | 98 | int AX12_getLocalID(unsigned char id); |
antbig | 0:ad97421fb1fb | 99 | |
antbig | 0:ad97421fb1fb | 100 | /****************************************************************************************/ |
antbig | 0:ad97421fb1fb | 101 | /* FUNCTION NAME: AX12_doLoop */ |
antbig | 0:ad97421fb1fb | 102 | /* DESCRIPTION : Boucle de vérification de la position des AX12 */ |
antbig | 0:ad97421fb1fb | 103 | /****************************************************************************************/ |
antbig | 0:ad97421fb1fb | 104 | void AX12_doLoop(void); |
antbig | 0:ad97421fb1fb | 105 | |
antbig | 0:ad97421fb1fb | 106 | |
antbig | 0:ad97421fb1fb | 107 | /****************************************************************************************/ |
antbig | 0:ad97421fb1fb | 108 | /* FUNCTION NAME: AX12_processChange */ |
antbig | 0:ad97421fb1fb | 109 | /* DESCRIPTION : Permet de prendre en compte les changement d'instruction des AX12 */ |
antbig | 0:ad97421fb1fb | 110 | /* Début du mouvement à partir de l'appel de cette fonction */ |
antbig | 0:ad97421fb1fb | 111 | /****************************************************************************************/ |
antbig | 0:ad97421fb1fb | 112 | void AX12_processChange(void); |
antbig | 0:ad97421fb1fb | 113 | |
antbig | 0:ad97421fb1fb | 114 | /****************************************************************************************/ |
antbig | 0:ad97421fb1fb | 115 | /* FUNCTION NAME: AX12_syncWrite */ |
antbig | 0:ad97421fb1fb | 116 | /* DESCRIPTION : Fonction pour envoyer des trames aux AX12 en mode syncWrite */ |
antbig | 0:ad97421fb1fb | 117 | /****************************************************************************************/ |
antbig | 0:ad97421fb1fb | 118 | int AX12_syncWrite(int start, int bytes, char* data); |
antbig | 0:ad97421fb1fb | 119 | |
antbig | 0:ad97421fb1fb | 120 | /****************************************************************************************/ |
antbig | 0:ad97421fb1fb | 121 | /* FUNCTION NAME: AX12_write */ |
antbig | 0:ad97421fb1fb | 122 | /* DESCRIPTION : Fonction pour envoyer des trames aux AX12 */ |
antbig | 0:ad97421fb1fb | 123 | /****************************************************************************************/ |
antbig | 0:ad97421fb1fb | 124 | int AX12_write(int ID, int start, int bytes, char* data, int flag=0); |
antbig | 0:ad97421fb1fb | 125 | |
antbig | 0:ad97421fb1fb | 126 | #endif |
antbig | 0:ad97421fb1fb | 127 |