Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
CAN_asser.h@5:34048faec367, 2019-05-09 (annotated)
- Committer:
- Wael_H
- Date:
- Thu May 09 12:35:11 2019 +0000
- Revision:
- 5:34048faec367
- Child:
- 7:753e901d441b
bib can asser
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Wael_H | 5:34048faec367 | 1 | #ifndef CAN_ASSER_H |
| Wael_H | 5:34048faec367 | 2 | #define CAN_ASSER_H |
| Wael_H | 5:34048faec367 | 3 | |
| Wael_H | 5:34048faec367 | 4 | #include "mbed.h" |
| Wael_H | 5:34048faec367 | 5 | |
| Wael_H | 5:34048faec367 | 6 | #define TE_100US 100 |
| Wael_H | 5:34048faec367 | 7 | #define TE (TE_100US*0.0001) |
| Wael_H | 5:34048faec367 | 8 | |
| Wael_H | 5:34048faec367 | 9 | #define ASSERVISSEMENT_STOP 0x001 // Stop moteur |
| Wael_H | 5:34048faec367 | 10 | #define ASSERVISSEMENT_SPEED_DANGER 0x006 // Vitesse de danger |
| Wael_H | 5:34048faec367 | 11 | #define ASSERVISSEMENT_XYT 0x020 // Asservissement (x,y,theta) (0 : au choix 1 : avant -1 : arrière) |
| Wael_H | 5:34048faec367 | 12 | #define ASSERVISSEMENT_COURBURE 0x021 // Asservissement rayon de courbure (+ gauche, - droite , sens : 1avt , -1arr; enchainement => 1 oui, 0 => non, 2=>derniére instruction de l'enchainement) |
| Wael_H | 5:34048faec367 | 13 | #define ASSERVISSEMENT_CONFIG 0x022 // Asservissement paramètre (définir les valeurs de vitesse max et d'eccélération max) |
| Wael_H | 5:34048faec367 | 14 | #define ASSERVISSEMENT_ROTATION 0x023 // Asservissement rotation |
| Wael_H | 5:34048faec367 | 15 | #define ASSERVISSEMENT_RECALAGE 0x024 // Moteur tout droit (recalage : 0 mouvement seul, 1 x, 2y valeur : coordonnée à laquelle est recalé x/y; enchainement => 1 oui, 0 => non) |
| Wael_H | 5:34048faec367 | 16 | #define ASSERVISSEMENT_CONFIG_DECEL 0x019 |
| Wael_H | 5:34048faec367 | 17 | |
| Wael_H | 5:34048faec367 | 18 | #define ASSERVISSEMENT_ENABLE 0x1F7 // Activation asservissement (0 : désactivation, 1 : activation) |
| Wael_H | 5:34048faec367 | 19 | |
| Wael_H | 5:34048faec367 | 20 | #define ASSERVISSEMENT_CONFIG_KPP_DROITE 0x1F1 |
| Wael_H | 5:34048faec367 | 21 | #define ASSERVISSEMENT_CONFIG_KPI_DROITE 0x1F2 |
| Wael_H | 5:34048faec367 | 22 | #define ASSERVISSEMENT_CONFIG_KPD_DROITE 0x1F3 |
| Wael_H | 5:34048faec367 | 23 | #define ASSERVISSEMENT_CONFIG_KPP_GAUCHE 0x1F4 |
| Wael_H | 5:34048faec367 | 24 | #define ASSERVISSEMENT_CONFIG_KPI_GAUCHE 0x1F5 |
| Wael_H | 5:34048faec367 | 25 | #define ASSERVISSEMENT_CONFIG_KPD_GAUCHE 0x1F6 |
| Wael_H | 5:34048faec367 | 26 | |
| Wael_H | 5:34048faec367 | 27 | #define ODOMETRIE_POSITION 0x26 |
| Wael_H | 5:34048faec367 | 28 | |
| Wael_H | 5:34048faec367 | 29 | extern double KppD; |
| Wael_H | 5:34048faec367 | 30 | extern double KipD; |
| Wael_H | 5:34048faec367 | 31 | extern double KdpD; |
| Wael_H | 5:34048faec367 | 32 | |
| Wael_H | 5:34048faec367 | 33 | extern double KppG; |
| Wael_H | 5:34048faec367 | 34 | extern double KipG; |
| Wael_H | 5:34048faec367 | 35 | extern double KdpG; |
| Wael_H | 5:34048faec367 | 36 | |
| Wael_H | 5:34048faec367 | 37 | extern unsigned char pt_lecture_can, pt_ecriture_can; |
| Wael_H | 5:34048faec367 | 38 | extern int nb_msg_can; |
| Wael_H | 5:34048faec367 | 39 | extern CANMessage msg_can[256]; |
| Wael_H | 5:34048faec367 | 40 | extern short pos[3]; |
| Wael_H | 5:34048faec367 | 41 | extern int flagFinDpl; |
| Wael_H | 5:34048faec367 | 42 | |
| Wael_H | 5:34048faec367 | 43 | void isr_can(); |
| Wael_H | 5:34048faec367 | 44 | |
| Wael_H | 5:34048faec367 | 45 | void trait_can(); |
| Wael_H | 5:34048faec367 | 46 | |
| Wael_H | 5:34048faec367 | 47 | void can_init(void); |
| Wael_H | 5:34048faec367 | 48 | |
| Wael_H | 5:34048faec367 | 49 | void get_pos(CANMessage msg_pos, short* position); |
| Wael_H | 5:34048faec367 | 50 | |
| Wael_H | 5:34048faec367 | 51 | int compare_tab(short* t1, short* t2, int size); |
| Wael_H | 5:34048faec367 | 52 | |
| Wael_H | 5:34048faec367 | 53 | void remonter_tab_can(CANMessage* tab, int taille); |
| Wael_H | 5:34048faec367 | 54 | |
| Wael_H | 5:34048faec367 | 55 | void SendCoefK (unsigned short id, double K); |
| Wael_H | 5:34048faec367 | 56 | |
| Wael_H | 5:34048faec367 | 57 | /*********************************************************************************************************/ |
| Wael_H | 5:34048faec367 | 58 | |
| Wael_H | 5:34048faec367 | 59 | /* FUNCTION NAME: SendRawId */ |
| Wael_H | 5:34048faec367 | 60 | /* DESCRIPTION : Envoie un message sans donnée, c'est-à-dire contenant uniquement un ID, sur le bus CAN */ |
| Wael_H | 5:34048faec367 | 61 | /*********************************************************************************************************/ |
| Wael_H | 5:34048faec367 | 62 | void SendRawId (unsigned short id); |
| Wael_H | 5:34048faec367 | 63 | |
| Wael_H | 5:34048faec367 | 64 | /*********************************************************************************************/ |
| Wael_H | 5:34048faec367 | 65 | |
| Wael_H | 5:34048faec367 | 66 | /* FUNCTION NAME: SendAck */ |
| Wael_H | 5:34048faec367 | 67 | |
| Wael_H | 5:34048faec367 | 68 | /* DESCRIPTION : Envoyer un acknowledge */ |
| Wael_H | 5:34048faec367 | 69 | /*********************************************************************************************/ |
| Wael_H | 5:34048faec367 | 70 | void SendAck(unsigned short id, unsigned short from); |
| Wael_H | 5:34048faec367 | 71 | |
| Wael_H | 5:34048faec367 | 72 | /*********************************************************************************************/ |
| Wael_H | 5:34048faec367 | 73 | |
| Wael_H | 5:34048faec367 | 74 | /* FUNCTION NAME: GoToPosition */ |
| Wael_H | 5:34048faec367 | 75 | /* DESCRIPTION : Transmission CAN correspondant à un asservissement en position (x,y,theta) */ |
| Wael_H | 5:34048faec367 | 76 | /*********************************************************************************************/ |
| Wael_H | 5:34048faec367 | 77 | |
| Wael_H | 5:34048faec367 | 78 | void GoToPosition (unsigned short x,unsigned short y,signed short theta,signed char sens); |
| Wael_H | 5:34048faec367 | 79 | |
| Wael_H | 5:34048faec367 | 80 | /****************************************************************************************/ |
| Wael_H | 5:34048faec367 | 81 | |
| Wael_H | 5:34048faec367 | 82 | /* FUNCTION NAME: Rotate */ |
| Wael_H | 5:34048faec367 | 83 | |
| Wael_H | 5:34048faec367 | 84 | /* DESCRIPTION : Transmission CAN correspondant à une rotation */ |
| Wael_H | 5:34048faec367 | 85 | /****************************************************************************************/ |
| Wael_H | 5:34048faec367 | 86 | |
| Wael_H | 5:34048faec367 | 87 | void Rotate (signed short angle); |
| Wael_H | 5:34048faec367 | 88 | |
| Wael_H | 5:34048faec367 | 89 | /******************************************************************************************** |
| Wael_H | 5:34048faec367 | 90 | FUNCTION NAME: GoStraight |
| Wael_H | 5:34048faec367 | 91 | DESCRIPTION : Transmission CAN correspondant à une ligne droite, avec ou sans recalage |
| Wael_H | 5:34048faec367 | 92 | |
| Wael_H | 5:34048faec367 | 93 | recalage : 0 => pas de recalage |
| Wael_H | 5:34048faec367 | 94 | |
| Wael_H | 5:34048faec367 | 95 | 1 => recalage en X |
| Wael_H | 5:34048faec367 | 96 | |
| Wael_H | 5:34048faec367 | 97 | 2 => Recalage en Y |
| Wael_H | 5:34048faec367 | 98 | |
| Wael_H | 5:34048faec367 | 99 | newValue : Uniquement en cas de recalage, indique la nouvelle valeur de l'odo |
| Wael_H | 5:34048faec367 | 100 | |
| Wael_H | 5:34048faec367 | 101 | isEnchainement : Indique si il faut executer l'instruction en enchainement |
| Wael_H | 5:34048faec367 | 102 | |
| Wael_H | 5:34048faec367 | 103 | 0 => non |
| Wael_H | 5:34048faec367 | 104 | |
| Wael_H | 5:34048faec367 | 105 | 1 => oui |
| Wael_H | 5:34048faec367 | 106 | |
| Wael_H | 5:34048faec367 | 107 | 2 => dernière instruction de l'enchainement |
| Wael_H | 5:34048faec367 | 108 | ********************************************************************************************/ |
| Wael_H | 5:34048faec367 | 109 | void GoStraight (signed short distance,unsigned char recalage, unsigned short newValue, unsigned char isEnchainement); |
| Wael_H | 5:34048faec367 | 110 | |
| Wael_H | 5:34048faec367 | 111 | /********************************************************************************************/ |
| Wael_H | 5:34048faec367 | 112 | |
| Wael_H | 5:34048faec367 | 113 | /* FUNCTION NAME: BendRadius */ |
| Wael_H | 5:34048faec367 | 114 | |
| Wael_H | 5:34048faec367 | 115 | /* DESCRIPTION : Transmission CAN correspondant à un rayon de courbure */ |
| Wael_H | 5:34048faec367 | 116 | /********************************************************************************************/ |
| Wael_H | 5:34048faec367 | 117 | void BendRadius (unsigned short rayon,signed short angle,signed char sens, unsigned char enchainement); |
| Wael_H | 5:34048faec367 | 118 | |
| Wael_H | 5:34048faec367 | 119 | void SetOdometrie (unsigned short canId, unsigned short x,unsigned short y,signed short theta); |
| Wael_H | 5:34048faec367 | 120 | |
| Wael_H | 5:34048faec367 | 121 | /****************************************************************************************/ |
| Wael_H | 5:34048faec367 | 122 | |
| Wael_H | 5:34048faec367 | 123 | /* FUNCTION NAME: setAsservissementEtat */ |
| Wael_H | 5:34048faec367 | 124 | |
| Wael_H | 5:34048faec367 | 125 | /* DESCRIPTION : Activer ou désactiver l'asservissement */ |
| Wael_H | 5:34048faec367 | 126 | /****************************************************************************************/ |
| Wael_H | 5:34048faec367 | 127 | void setAsservissementEtat(unsigned char enable); |
| Wael_H | 5:34048faec367 | 128 | |
| Wael_H | 5:34048faec367 | 129 | /****************************************************************************************/ |
| Wael_H | 5:34048faec367 | 130 | |
| Wael_H | 5:34048faec367 | 131 | /* FUNCTION NAME: SendSpeed */ |
| Wael_H | 5:34048faec367 | 132 | |
| Wael_H | 5:34048faec367 | 133 | /* DESCRIPTION : Envoie un asservissement paramètre retournant à une vitesse */ |
| Wael_H | 5:34048faec367 | 134 | /****************************************************************************************/ |
| Wael_H | 5:34048faec367 | 135 | void SendSpeed (unsigned short vitesse, unsigned short acceleration); |
| Wael_H | 5:34048faec367 | 136 | /****************************************************************************************/ |
| Wael_H | 5:34048faec367 | 137 | |
| Wael_H | 5:34048faec367 | 138 | /* FUNCTION NAME: SendSpeedDecel */ |
| Wael_H | 5:34048faec367 | 139 | |
| Wael_H | 5:34048faec367 | 140 | /* DESCRIPTION : Envoie un asservissement paramètre retournant à une vitesse */ |
| Wael_H | 5:34048faec367 | 141 | /****************************************************************************************/ |
| Wael_H | 5:34048faec367 | 142 | void SendSpeedDecel (unsigned short vitesse, unsigned short deceleration); |
| Wael_H | 5:34048faec367 | 143 | |
| Wael_H | 5:34048faec367 | 144 | |
| Wael_H | 5:34048faec367 | 145 | #endif |