pour trouver l'automate de reception can
Fork of CRAC-Strat_copy by
Diff: AX12-V2/AX12-V2.h
- Revision:
- 0:ad97421fb1fb
- Child:
- 1:116040d14164
diff -r 000000000000 -r ad97421fb1fb AX12-V2/AX12-V2.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/AX12-V2/AX12-V2.h Wed Apr 13 22:04:54 2016 +0000 @@ -0,0 +1,127 @@ +#ifndef CRAC_AX12 +#define CRAC_AX12 + +#include "global.h" + +#define MAX_AX12 30 + + +#define AX12_REG_ID 0x03 +#define AX12_REG_BAUD 0x04 +#define AX12_REG_DELAY_TIME 0x05 +#define AX12_REG_CW_LIMIT 0x06 +#define AX12_REG_CCW_LIMIT 0x08 +#define AX12_REG_TEMP_MAX 0x0B +#define AX12_REG_LOWEST_VOLTAGE 0x0C +#define AX12_REG_HIGHEST_VOLTAGE 0x0D +#define AX12_REG_MAX_TORQUE 0x0E +#define AX12_REG_SATUS_RETURN 0x10 +#define AX12_REG_ALARM_LED 0x11 +#define AX12_REG_ALARM_SHUTDOWN 0x12 +#define AX12_REG_DOWN_CALIBRATION 0x14 +#define AX12_REG_UP_CALIBRATION 0x16 +#define AX12_REG_TORQUE_ENABLE 0x18 +#define AX12_REG_LED 0x19 +#define AX12_REG_CW_MARGIN 0x1A +#define AX12_REG_CCW_MARGIN 0x1B +#define AX12_REG_CW_SLOPE 0x1C +#define AX12_REG_CCW_SLOPE 0x1D +#define AX12_REG_GOAL_POSITION 0x1E +#define AX12_REG_MOVING_SPEED 0x20 +#define AX12_REG_TORQUE_LIMIT 0x22 +#define AX12_REG_POSITION 0x24 +#define AX12_REG_PRESENT_SPEED 0x26 +#define AX12_REG_PRESENT_LOAD 0x28 +#define AX12_REG_VOLTS 0x2A +#define AX12_REG_TEMP 0x2B +#define AX12_REG_INSTRUCTION 0x2C +#define AX12_REG_MOVING 0x2E +#define AX12_REG_LOCK 0x2F +#define AX12_REG_PUNCH 0x30 + + +#define AX12_MODE_POSITION 0 +#define AX12_MODE_ROTATION 1 + +#define AX12_CW 1 +#define AX12_CCW 0 + +//--- Instruction --- +#define INST_PING 0x01 +#define INST_READ 0x02 +#define INST_WRITE 0x03 +#define INST_REG_WRITE 0x04 +#define INST_ACTION 0x05 +#define INST_RESET 0x06 +#define INST_DIGITAL_RESET 0x07 +#define INST_SYSTEM_READ 0x0C +#define INST_SYSTEM_WRITE 0x0D +#define INST_SYNC_WRITE 0x83 +#define INST_SYNC_REG_WRITE 0x84 + +#define DEFAULT_RETURN_PACKET_SIZE 6 + +#define BROADCASTING_ID 0xfe + +#define MAX_TIMEOUT 5000 + +struct S_AX12 { + unsigned char id;//L'id de l'AX12 + unsigned short goal;//La position ou doit aller le robot + unsigned short speed;//La vitesse de déplacement du bras + unsigned char isUsingCAN;//Indique si il faut envoyer les information via CAN (0=>non | autre=>oui) + unsigned char needToUpdate;//Indique qu'il faut mettre à jour la position +}; + +/****************************************************************************************/ +/* FUNCTION NAME: AX12_register */ +/* DESCRIPTION : Indiquer qu'un AX12 est connecté à la carte */ +/****************************************************************************************/ +void AX12_register(unsigned char id, unsigned short speed = 0x3FF); + +/****************************************************************************************/ +/* FUNCTION NAME: AX12_setGoal */ +/* DESCRIPTION : Definir la position d'un ax12, !!Ne déclanche pas le mouvement */ +/****************************************************************************************/ +void AX12_setGoal(unsigned char id, unsigned short goal, unsigned short speed = 0x3FF); + +/****************************************************************************************/ +/* FUNCTION NAME: AX12_isLocal */ +/* DESCRIPTION : Savoir si un AX12 est enregistré sur la carte */ +/****************************************************************************************/ +unsigned char AX12_isLocal(unsigned char id); + +/****************************************************************************************/ +/* FUNCTION NAME: AX12_getLocalID */ +/* DESCRIPTION : Obtenir les info sur un AX12 ou l'initialiser si non présent */ +/****************************************************************************************/ +int AX12_getLocalID(unsigned char id); + +/****************************************************************************************/ +/* FUNCTION NAME: AX12_doLoop */ +/* DESCRIPTION : Boucle de vérification de la position des AX12 */ +/****************************************************************************************/ +void AX12_doLoop(void); + + +/****************************************************************************************/ +/* FUNCTION NAME: AX12_processChange */ +/* DESCRIPTION : Permet de prendre en compte les changement d'instruction des AX12 */ +/* Début du mouvement à partir de l'appel de cette fonction */ +/****************************************************************************************/ +void AX12_processChange(void); + +/****************************************************************************************/ +/* FUNCTION NAME: AX12_syncWrite */ +/* DESCRIPTION : Fonction pour envoyer des trames aux AX12 en mode syncWrite */ +/****************************************************************************************/ +int AX12_syncWrite(int start, int bytes, char* data); + +/****************************************************************************************/ +/* FUNCTION NAME: AX12_write */ +/* DESCRIPTION : Fonction pour envoyer des trames aux AX12 */ +/****************************************************************************************/ +int AX12_write(int ID, int start, int bytes, char* data, int flag=0); + +#endif +