Biblio à utiliser pour communiquer avec la carte moteur
Dependents: Asserv_mot Asserv_mot
Asservissement.cpp@2:dc3ec8d77b6a, 2019-05-27 (annotated)
- Committer:
- kyxstark
- Date:
- Mon May 27 09:54:41 2019 +0000
- Revision:
- 2:dc3ec8d77b6a
- Parent:
- 1:162aa6608ffe
v2019
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kyxstark | 2:dc3ec8d77b6a | 1 | |
kkoichy | 0:3a1f19e51eb2 | 2 | #include "Asservissement.h" |
kkoichy | 0:3a1f19e51eb2 | 3 | |
kkoichy | 0:3a1f19e51eb2 | 4 | /*********************************************************************************************************/ |
kkoichy | 0:3a1f19e51eb2 | 5 | /* FUNCTION NAME: SendRawId */ |
kkoichy | 0:3a1f19e51eb2 | 6 | /* DESCRIPTION : Envoie un message sans donnée, c'est-à-dire contenant uniquement un ID, sur le bus CAN */ |
kkoichy | 0:3a1f19e51eb2 | 7 | /*********************************************************************************************************/ |
kkoichy | 0:3a1f19e51eb2 | 8 | void SendRawId (unsigned short id) |
kkoichy | 0:3a1f19e51eb2 | 9 | { |
kkoichy | 0:3a1f19e51eb2 | 10 | CANMessage msgTx=CANMessage(); |
kkoichy | 0:3a1f19e51eb2 | 11 | msgTx.id=id; |
kkoichy | 0:3a1f19e51eb2 | 12 | msgTx.len=0; |
kyxstark | 2:dc3ec8d77b6a | 13 | can.write(msgTx); |
kyxstark | 2:dc3ec8d77b6a | 14 | wait_us(200); |
kkoichy | 0:3a1f19e51eb2 | 15 | } |
kkoichy | 0:3a1f19e51eb2 | 16 | |
kkoichy | 0:3a1f19e51eb2 | 17 | /*********************************************************************************************/ |
kkoichy | 0:3a1f19e51eb2 | 18 | /* FUNCTION NAME: SendAck */ |
kkoichy | 0:3a1f19e51eb2 | 19 | /* DESCRIPTION : Envoyer un acknowledge */ |
kkoichy | 0:3a1f19e51eb2 | 20 | /*********************************************************************************************/ |
kkoichy | 0:3a1f19e51eb2 | 21 | void SendAck(unsigned short id, unsigned short from) |
kkoichy | 0:3a1f19e51eb2 | 22 | { |
kkoichy | 0:3a1f19e51eb2 | 23 | CANMessage msgTx=CANMessage(); |
kkoichy | 0:3a1f19e51eb2 | 24 | msgTx.id=id; |
kkoichy | 0:3a1f19e51eb2 | 25 | msgTx.len=2; |
kkoichy | 0:3a1f19e51eb2 | 26 | msgTx.format=CANStandard; |
kkoichy | 0:3a1f19e51eb2 | 27 | msgTx.type=CANData; |
kkoichy | 0:3a1f19e51eb2 | 28 | // from sur 2 octets |
kkoichy | 0:3a1f19e51eb2 | 29 | msgTx.data[0]=(unsigned char)from; |
kkoichy | 0:3a1f19e51eb2 | 30 | msgTx.data[1]=(unsigned char)(from>>8); |
kkoichy | 0:3a1f19e51eb2 | 31 | |
kyxstark | 2:dc3ec8d77b6a | 32 | can.write(msgTx); |
kyxstark | 2:dc3ec8d77b6a | 33 | } |
kyxstark | 2:dc3ec8d77b6a | 34 | |
kyxstark | 2:dc3ec8d77b6a | 35 | |
kyxstark | 2:dc3ec8d77b6a | 36 | void Send2Short(unsigned short id, unsigned short d1, unsigned short d2) |
kyxstark | 2:dc3ec8d77b6a | 37 | { |
kyxstark | 2:dc3ec8d77b6a | 38 | CANMessage msgTx=CANMessage(); |
kyxstark | 2:dc3ec8d77b6a | 39 | msgTx.id=id; |
kyxstark | 2:dc3ec8d77b6a | 40 | msgTx.len=4; |
kyxstark | 2:dc3ec8d77b6a | 41 | msgTx.format=CANStandard; |
kyxstark | 2:dc3ec8d77b6a | 42 | msgTx.type=CANData; |
kyxstark | 2:dc3ec8d77b6a | 43 | // from sur 2 octets |
kyxstark | 2:dc3ec8d77b6a | 44 | msgTx.data[0]=(unsigned char)d1; |
kyxstark | 2:dc3ec8d77b6a | 45 | msgTx.data[1]=(unsigned char)(d1>>8); |
kyxstark | 2:dc3ec8d77b6a | 46 | msgTx.data[2]=(unsigned char)d2; |
kyxstark | 2:dc3ec8d77b6a | 47 | msgTx.data[3]=(unsigned char)(d2>>8); |
kyxstark | 2:dc3ec8d77b6a | 48 | |
kyxstark | 2:dc3ec8d77b6a | 49 | can.write(msgTx); |
kkoichy | 0:3a1f19e51eb2 | 50 | } |
kkoichy | 0:3a1f19e51eb2 | 51 | |
kyxstark | 2:dc3ec8d77b6a | 52 | void SendMsgCan(unsigned short id, unsigned char* data, int len) |
kyxstark | 2:dc3ec8d77b6a | 53 | { |
kyxstark | 2:dc3ec8d77b6a | 54 | CANMessage msgTx=CANMessage(); |
kyxstark | 2:dc3ec8d77b6a | 55 | msgTx.id=id; |
kyxstark | 2:dc3ec8d77b6a | 56 | msgTx.len=len; |
kyxstark | 2:dc3ec8d77b6a | 57 | msgTx.format=CANStandard; |
kyxstark | 2:dc3ec8d77b6a | 58 | msgTx.type=CANData; |
kyxstark | 2:dc3ec8d77b6a | 59 | // from sur 2 octets |
kyxstark | 2:dc3ec8d77b6a | 60 | for(int i = 0; i<len; i++) |
kyxstark | 2:dc3ec8d77b6a | 61 | { |
kyxstark | 2:dc3ec8d77b6a | 62 | msgTx.data[i]=data[i]; |
kyxstark | 2:dc3ec8d77b6a | 63 | } |
kyxstark | 2:dc3ec8d77b6a | 64 | |
kyxstark | 2:dc3ec8d77b6a | 65 | can.write(msgTx); |
kyxstark | 2:dc3ec8d77b6a | 66 | } |
kyxstark | 2:dc3ec8d77b6a | 67 | void SendCharCan(unsigned short id, unsigned char data) |
kyxstark | 2:dc3ec8d77b6a | 68 | { |
kyxstark | 2:dc3ec8d77b6a | 69 | CANMessage msgTx=CANMessage(); |
kyxstark | 2:dc3ec8d77b6a | 70 | msgTx.id=id; |
kyxstark | 2:dc3ec8d77b6a | 71 | msgTx.len=1; |
kyxstark | 2:dc3ec8d77b6a | 72 | msgTx.format=CANStandard; |
kyxstark | 2:dc3ec8d77b6a | 73 | msgTx.type=CANData; |
kyxstark | 2:dc3ec8d77b6a | 74 | msgTx.data[0]=data; |
kyxstark | 2:dc3ec8d77b6a | 75 | |
kyxstark | 2:dc3ec8d77b6a | 76 | can.write(msgTx); |
kyxstark | 2:dc3ec8d77b6a | 77 | } |
kyxstark | 2:dc3ec8d77b6a | 78 | |
kyxstark | 2:dc3ec8d77b6a | 79 | |
kyxstark | 2:dc3ec8d77b6a | 80 | |
kkoichy | 0:3a1f19e51eb2 | 81 | /*********************************************************************************************/ |
kkoichy | 0:3a1f19e51eb2 | 82 | /* FUNCTION NAME: GoToPosition */ |
kkoichy | 0:3a1f19e51eb2 | 83 | /* DESCRIPTION : Transmission CAN correspondant à un asservissement en position (x,y,theta) */ |
kkoichy | 0:3a1f19e51eb2 | 84 | /*********************************************************************************************/ |
kkoichy | 0:3a1f19e51eb2 | 85 | void GoToPosition (unsigned short x,unsigned short y,signed short theta,signed char sens) |
kkoichy | 0:3a1f19e51eb2 | 86 | { |
kkoichy | 0:3a1f19e51eb2 | 87 | //id_to_expect=ACK_CONSIGNE; |
kkoichy | 0:3a1f19e51eb2 | 88 | |
kkoichy | 0:3a1f19e51eb2 | 89 | CANMessage msgTx=CANMessage(); |
kkoichy | 0:3a1f19e51eb2 | 90 | msgTx.id=ASSERVISSEMENT_XYT; // tx nouvelle position en (x,y,theta) |
kkoichy | 0:3a1f19e51eb2 | 91 | msgTx.len=7; |
kkoichy | 0:3a1f19e51eb2 | 92 | msgTx.format=CANStandard; |
kkoichy | 0:3a1f19e51eb2 | 93 | msgTx.type=CANData; |
kkoichy | 0:3a1f19e51eb2 | 94 | // x sur 2 octets |
kkoichy | 0:3a1f19e51eb2 | 95 | msgTx.data[0]=(unsigned char)x; |
kkoichy | 0:3a1f19e51eb2 | 96 | msgTx.data[1]=(unsigned char)(x>>8); |
kkoichy | 0:3a1f19e51eb2 | 97 | // y sur 2 octets |
kkoichy | 0:3a1f19e51eb2 | 98 | msgTx.data[2]=(unsigned char)y; |
kkoichy | 0:3a1f19e51eb2 | 99 | msgTx.data[3]=(unsigned char)(y>>8); |
kkoichy | 0:3a1f19e51eb2 | 100 | // theta signé sur 2 octets |
kkoichy | 0:3a1f19e51eb2 | 101 | msgTx.data[4]=(unsigned char)theta; |
kkoichy | 0:3a1f19e51eb2 | 102 | msgTx.data[5]=(unsigned char)(theta>>8); |
kkoichy | 0:3a1f19e51eb2 | 103 | msgTx.data[6]=sens; |
kkoichy | 0:3a1f19e51eb2 | 104 | |
kyxstark | 2:dc3ec8d77b6a | 105 | can.write(msgTx); |
kkoichy | 0:3a1f19e51eb2 | 106 | } |
kkoichy | 0:3a1f19e51eb2 | 107 | |
kkoichy | 0:3a1f19e51eb2 | 108 | /****************************************************************************************/ |
kkoichy | 0:3a1f19e51eb2 | 109 | /* FUNCTION NAME: Rotate */ |
kkoichy | 0:3a1f19e51eb2 | 110 | /* DESCRIPTION : Transmission CAN correspondant à une rotation */ |
kkoichy | 0:3a1f19e51eb2 | 111 | /****************************************************************************************/ |
kyxstark | 2:dc3ec8d77b6a | 112 | void Rotate (signed short angle) |
kkoichy | 0:3a1f19e51eb2 | 113 | { |
kkoichy | 0:3a1f19e51eb2 | 114 | CANMessage msgTx=CANMessage(); |
kkoichy | 0:3a1f19e51eb2 | 115 | msgTx.id=ASSERVISSEMENT_ROTATION; // Tx rotation autour du centre du robot |
kkoichy | 0:3a1f19e51eb2 | 116 | msgTx.len=2; |
kkoichy | 0:3a1f19e51eb2 | 117 | msgTx.format=CANStandard; |
kkoichy | 0:3a1f19e51eb2 | 118 | msgTx.type=CANData; |
kkoichy | 0:3a1f19e51eb2 | 119 | // Angle signé sur 2 octets |
kkoichy | 0:3a1f19e51eb2 | 120 | msgTx.data[0]=(unsigned char)angle; |
kkoichy | 0:3a1f19e51eb2 | 121 | msgTx.data[1]=(unsigned char)(angle>>8); |
kkoichy | 0:3a1f19e51eb2 | 122 | |
kyxstark | 2:dc3ec8d77b6a | 123 | can.write(msgTx); |
kkoichy | 0:3a1f19e51eb2 | 124 | } |
kkoichy | 0:3a1f19e51eb2 | 125 | |
kkoichy | 0:3a1f19e51eb2 | 126 | |
kkoichy | 0:3a1f19e51eb2 | 127 | /*********************************************************************************************/ |
kkoichy | 0:3a1f19e51eb2 | 128 | /* FUNCTION NAME: GoStraight */ |
kkoichy | 0:3a1f19e51eb2 | 129 | /* DESCRIPTION : Transmission CAN correspondant à une ligne droite, avec ou sans recalage */ |
kkoichy | 0:3a1f19e51eb2 | 130 | /* recalage : 0 => pas de recalage */ |
kkoichy | 0:3a1f19e51eb2 | 131 | /* 1 => recalage en X */ |
kkoichy | 0:3a1f19e51eb2 | 132 | /* 2 => Recalage en Y */ |
kkoichy | 0:3a1f19e51eb2 | 133 | /* newValue : Uniquement en cas de recalage, indique la nouvelle valeur de l'odo */ |
kkoichy | 0:3a1f19e51eb2 | 134 | /* isEnchainement : Indique si il faut executer l'instruction en enchainement */ |
kkoichy | 0:3a1f19e51eb2 | 135 | /* 0 => non */ |
kkoichy | 0:3a1f19e51eb2 | 136 | /* 1 => oui */ |
kkoichy | 0:3a1f19e51eb2 | 137 | /* 2 => dernière instruction de l'enchainement */ |
kkoichy | 0:3a1f19e51eb2 | 138 | /*********************************************************************************************/ |
kkoichy | 0:3a1f19e51eb2 | 139 | void GoStraight (signed short distance,unsigned char recalage, unsigned short newValue, unsigned char isEnchainement) |
kkoichy | 0:3a1f19e51eb2 | 140 | { |
kkoichy | 0:3a1f19e51eb2 | 141 | CANMessage msgTx=CANMessage(); |
kkoichy | 0:3a1f19e51eb2 | 142 | msgTx.id=ASSERVISSEMENT_RECALAGE; |
kkoichy | 0:3a1f19e51eb2 | 143 | msgTx.len=6; |
kkoichy | 0:3a1f19e51eb2 | 144 | msgTx.format=CANStandard; |
kkoichy | 0:3a1f19e51eb2 | 145 | msgTx.type=CANData; |
kkoichy | 0:3a1f19e51eb2 | 146 | // x sur 2 octets |
kkoichy | 0:3a1f19e51eb2 | 147 | msgTx.data[0]=(unsigned char)distance; |
kkoichy | 0:3a1f19e51eb2 | 148 | msgTx.data[1]=(unsigned char)(distance>>8); |
kkoichy | 0:3a1f19e51eb2 | 149 | //Recalage sur 1 octet |
kkoichy | 0:3a1f19e51eb2 | 150 | msgTx.data[2]=recalage; |
kkoichy | 0:3a1f19e51eb2 | 151 | //Valeur du recalage sur 2 octets |
kkoichy | 0:3a1f19e51eb2 | 152 | msgTx.data[3]=(unsigned char)newValue; |
kkoichy | 0:3a1f19e51eb2 | 153 | msgTx.data[4]=(unsigned char)(newValue>>8); |
kkoichy | 0:3a1f19e51eb2 | 154 | //Enchainement sur 1 octet |
kkoichy | 0:3a1f19e51eb2 | 155 | msgTx.data[5]=isEnchainement; |
kkoichy | 0:3a1f19e51eb2 | 156 | |
kyxstark | 2:dc3ec8d77b6a | 157 | can.write(msgTx); |
kkoichy | 0:3a1f19e51eb2 | 158 | //wait_ms(500); |
kkoichy | 0:3a1f19e51eb2 | 159 | } |
kkoichy | 0:3a1f19e51eb2 | 160 | |
kkoichy | 0:3a1f19e51eb2 | 161 | /********************************************************************************************/ |
kkoichy | 0:3a1f19e51eb2 | 162 | /* FUNCTION NAME: BendRadius */ |
kkoichy | 0:3a1f19e51eb2 | 163 | /* DESCRIPTION : Transmission CAN correspondant à un rayon de courbure */ |
kkoichy | 0:3a1f19e51eb2 | 164 | /********************************************************************************************/ |
kkoichy | 0:3a1f19e51eb2 | 165 | void BendRadius (unsigned short rayon,signed short angle,signed char sens, unsigned char enchainement) |
kkoichy | 0:3a1f19e51eb2 | 166 | { |
kkoichy | 0:3a1f19e51eb2 | 167 | CANMessage msgTx=CANMessage(); |
kkoichy | 0:3a1f19e51eb2 | 168 | msgTx.id=ASSERVISSEMENT_COURBURE; // tx asservissement rayon de courbure |
kkoichy | 0:3a1f19e51eb2 | 169 | msgTx.len=6; |
kkoichy | 0:3a1f19e51eb2 | 170 | msgTx.format=CANStandard; |
kkoichy | 0:3a1f19e51eb2 | 171 | msgTx.type=CANData; |
kkoichy | 0:3a1f19e51eb2 | 172 | // Rayon sur 2 octets |
kkoichy | 0:3a1f19e51eb2 | 173 | msgTx.data[0]=(unsigned char)rayon; |
kkoichy | 0:3a1f19e51eb2 | 174 | msgTx.data[1]=(unsigned char)(rayon>>8); |
kkoichy | 0:3a1f19e51eb2 | 175 | // Angle signé sur 2 octets |
kkoichy | 0:3a1f19e51eb2 | 176 | msgTx.data[2]=(unsigned char)angle; |
kkoichy | 0:3a1f19e51eb2 | 177 | msgTx.data[3]=(unsigned char)(angle>>8); |
kkoichy | 0:3a1f19e51eb2 | 178 | // Sens signé sur 1 octet |
kkoichy | 0:3a1f19e51eb2 | 179 | msgTx.data[4]=sens; |
kkoichy | 0:3a1f19e51eb2 | 180 | // Enchainement sur 1 octet |
kkoichy | 0:3a1f19e51eb2 | 181 | msgTx.data[5]=enchainement; |
kkoichy | 0:3a1f19e51eb2 | 182 | |
kyxstark | 2:dc3ec8d77b6a | 183 | can.write(msgTx); |
kkoichy | 0:3a1f19e51eb2 | 184 | } |
kkoichy | 0:3a1f19e51eb2 | 185 | |
kkoichy | 0:3a1f19e51eb2 | 186 | void SetOdometrie (unsigned short canId, unsigned short x,unsigned short y,signed short theta) |
kkoichy | 0:3a1f19e51eb2 | 187 | { |
kkoichy | 0:3a1f19e51eb2 | 188 | CANMessage msgTx=CANMessage(); |
kkoichy | 0:3a1f19e51eb2 | 189 | msgTx.id=canId; |
kkoichy | 0:3a1f19e51eb2 | 190 | msgTx.format=CANStandard; |
kkoichy | 0:3a1f19e51eb2 | 191 | msgTx.type=CANData; |
kkoichy | 0:3a1f19e51eb2 | 192 | msgTx.len=6; |
kkoichy | 0:3a1f19e51eb2 | 193 | |
kkoichy | 0:3a1f19e51eb2 | 194 | // x sur 2 octets |
kkoichy | 0:3a1f19e51eb2 | 195 | msgTx.data[0]=(unsigned char)x; |
kkoichy | 0:3a1f19e51eb2 | 196 | msgTx.data[1]=(unsigned char)(x>>8); |
kkoichy | 0:3a1f19e51eb2 | 197 | // y sur 2 octets |
kkoichy | 0:3a1f19e51eb2 | 198 | msgTx.data[2]=(unsigned char)y; |
kkoichy | 0:3a1f19e51eb2 | 199 | msgTx.data[3]=(unsigned char)(y>>8); |
kkoichy | 0:3a1f19e51eb2 | 200 | // theta signé sur 2 octets |
kkoichy | 0:3a1f19e51eb2 | 201 | msgTx.data[4]=(unsigned char)theta; |
kkoichy | 0:3a1f19e51eb2 | 202 | msgTx.data[5]=(unsigned char)(theta>>8); |
kkoichy | 0:3a1f19e51eb2 | 203 | |
kyxstark | 2:dc3ec8d77b6a | 204 | can.write(msgTx); |
kkoichy | 0:3a1f19e51eb2 | 205 | } |
kkoichy | 0:3a1f19e51eb2 | 206 | |
kkoichy | 0:3a1f19e51eb2 | 207 | /****************************************************************************************/ |
kkoichy | 0:3a1f19e51eb2 | 208 | /* FUNCTION NAME: setAsservissementEtat */ |
kkoichy | 0:3a1f19e51eb2 | 209 | /* DESCRIPTION : Activer ou désactiver l'asservissement */ |
kkoichy | 0:3a1f19e51eb2 | 210 | /****************************************************************************************/ |
kkoichy | 0:3a1f19e51eb2 | 211 | void setAsservissementEtat(unsigned char enable) |
kkoichy | 0:3a1f19e51eb2 | 212 | { |
kkoichy | 0:3a1f19e51eb2 | 213 | CANMessage msgTx=CANMessage(); |
kkoichy | 0:3a1f19e51eb2 | 214 | msgTx.id=ASSERVISSEMENT_ENABLE; // Tx rotation autour du centre du robot |
kkoichy | 0:3a1f19e51eb2 | 215 | msgTx.len=1; |
kkoichy | 0:3a1f19e51eb2 | 216 | msgTx.format=CANStandard; |
kkoichy | 0:3a1f19e51eb2 | 217 | msgTx.type=CANData; |
kkoichy | 0:3a1f19e51eb2 | 218 | // Angle signé sur 2 octets |
kkoichy | 0:3a1f19e51eb2 | 219 | msgTx.data[0]=(unsigned char)((enable==0)?0:1); |
kkoichy | 0:3a1f19e51eb2 | 220 | |
kyxstark | 2:dc3ec8d77b6a | 221 | can.write(msgTx); |
kkoichy | 0:3a1f19e51eb2 | 222 | } |
kkoichy | 0:3a1f19e51eb2 | 223 | |
kkoichy | 0:3a1f19e51eb2 | 224 | |
kkoichy | 0:3a1f19e51eb2 | 225 | /****************************************************************************************/ |
kyxstark | 2:dc3ec8d77b6a | 226 | /* FUNCTION NAME: SendSpeed accel decel */ |
kyxstark | 2:dc3ec8d77b6a | 227 | /* DESCRIPTION : Envoie un asservissement paramètre retournant à une vitesse */ |
kyxstark | 2:dc3ec8d77b6a | 228 | /****************************************************************************************/ |
kyxstark | 2:dc3ec8d77b6a | 229 | void SendSpeedAccelDecel (unsigned short vitesse, unsigned short acceleration,unsigned short deceleration) |
kyxstark | 2:dc3ec8d77b6a | 230 | { |
kyxstark | 2:dc3ec8d77b6a | 231 | CANMessage msgTx=CANMessage(); |
kyxstark | 2:dc3ec8d77b6a | 232 | msgTx.id=ASSERVISSEMENT_CONFIG; |
kyxstark | 2:dc3ec8d77b6a | 233 | msgTx.format=CANStandard; |
kyxstark | 2:dc3ec8d77b6a | 234 | msgTx.type=CANData; |
kyxstark | 2:dc3ec8d77b6a | 235 | msgTx.len=8; |
kyxstark | 2:dc3ec8d77b6a | 236 | msgTx.data[0]=(unsigned char)(vitesse&0x00FF); |
kyxstark | 2:dc3ec8d77b6a | 237 | msgTx.data[1]=(unsigned char)((vitesse&0xFF00)>>8); |
kyxstark | 2:dc3ec8d77b6a | 238 | |
kyxstark | 2:dc3ec8d77b6a | 239 | msgTx.data[2]=(unsigned char)(acceleration&0x00FF); |
kyxstark | 2:dc3ec8d77b6a | 240 | msgTx.data[3]=(unsigned char)((acceleration&0xFF00)>>8); |
kyxstark | 2:dc3ec8d77b6a | 241 | |
kyxstark | 2:dc3ec8d77b6a | 242 | msgTx.data[4]=(unsigned char)(deceleration&0x00FF); |
kyxstark | 2:dc3ec8d77b6a | 243 | msgTx.data[5]=(unsigned char)((deceleration&0xFF00)>>8); |
kyxstark | 2:dc3ec8d77b6a | 244 | |
kyxstark | 2:dc3ec8d77b6a | 245 | msgTx.data[6]=(unsigned char)(acceleration&0x00FF);//cloto |
kyxstark | 2:dc3ec8d77b6a | 246 | msgTx.data[7]=(unsigned char)((acceleration&0xFF00)>>8);//cloto |
kyxstark | 2:dc3ec8d77b6a | 247 | |
kyxstark | 2:dc3ec8d77b6a | 248 | can.write(msgTx); |
kyxstark | 2:dc3ec8d77b6a | 249 | |
kyxstark | 2:dc3ec8d77b6a | 250 | } |
kyxstark | 2:dc3ec8d77b6a | 251 | |
kyxstark | 2:dc3ec8d77b6a | 252 | /****************************************************************************************/ |
kkoichy | 0:3a1f19e51eb2 | 253 | /* FUNCTION NAME: SendSpeed */ |
kkoichy | 0:3a1f19e51eb2 | 254 | /* DESCRIPTION : Envoie un asservissement paramètre retournant à une vitesse */ |
kkoichy | 0:3a1f19e51eb2 | 255 | /****************************************************************************************/ |
kyxstark | 2:dc3ec8d77b6a | 256 | void SendSpeed (unsigned short vitesse) |
kyxstark | 2:dc3ec8d77b6a | 257 | { |
kyxstark | 2:dc3ec8d77b6a | 258 | CANMessage msgTx=CANMessage(); |
kyxstark | 2:dc3ec8d77b6a | 259 | msgTx.id=ASSERVISSEMENT_CONFIG_VIT; |
kyxstark | 2:dc3ec8d77b6a | 260 | msgTx.format=CANStandard; |
kyxstark | 2:dc3ec8d77b6a | 261 | msgTx.type=CANData; |
kyxstark | 2:dc3ec8d77b6a | 262 | msgTx.len=2; |
kyxstark | 2:dc3ec8d77b6a | 263 | msgTx.data[0]=(unsigned char)(vitesse&0x00FF); |
kyxstark | 2:dc3ec8d77b6a | 264 | msgTx.data[1]=(unsigned char)((vitesse&0xFF00)>>8); |
kyxstark | 2:dc3ec8d77b6a | 265 | |
kyxstark | 2:dc3ec8d77b6a | 266 | can.write(msgTx); |
kyxstark | 2:dc3ec8d77b6a | 267 | |
kyxstark | 2:dc3ec8d77b6a | 268 | } |
kyxstark | 2:dc3ec8d77b6a | 269 | |
kyxstark | 2:dc3ec8d77b6a | 270 | /****************************************************************************************/ |
kyxstark | 2:dc3ec8d77b6a | 271 | /* FUNCTION NAME: SendSpeed */ |
kyxstark | 2:dc3ec8d77b6a | 272 | /* DESCRIPTION : Envoie un asservissement paramètre retournant à une vitesse */ |
kyxstark | 2:dc3ec8d77b6a | 273 | /****************************************************************************************/ |
kyxstark | 2:dc3ec8d77b6a | 274 | void SendAccel(unsigned short acceleration,unsigned short deceleration) |
kkoichy | 0:3a1f19e51eb2 | 275 | { |
kkoichy | 0:3a1f19e51eb2 | 276 | CANMessage msgTx=CANMessage(); |
kyxstark | 2:dc3ec8d77b6a | 277 | msgTx.id=ASSERVISSEMENT_CONFIG_ACCEL; |
kyxstark | 2:dc3ec8d77b6a | 278 | msgTx.format=CANStandard; |
kyxstark | 2:dc3ec8d77b6a | 279 | msgTx.type=CANData; |
kyxstark | 2:dc3ec8d77b6a | 280 | msgTx.len=4; |
kyxstark | 2:dc3ec8d77b6a | 281 | msgTx.data[0]=(unsigned char)(acceleration&0x00FF); |
kyxstark | 2:dc3ec8d77b6a | 282 | msgTx.data[1]=(unsigned char)((acceleration&0xFF00)>>8); |
kyxstark | 2:dc3ec8d77b6a | 283 | |
kyxstark | 2:dc3ec8d77b6a | 284 | msgTx.data[2]=(unsigned char)(deceleration&0x00FF); |
kyxstark | 2:dc3ec8d77b6a | 285 | msgTx.data[3]=(unsigned char)((deceleration&0xFF00)>>8); |
kyxstark | 2:dc3ec8d77b6a | 286 | |
kyxstark | 2:dc3ec8d77b6a | 287 | can.write(msgTx); |
kyxstark | 2:dc3ec8d77b6a | 288 | |
kyxstark | 2:dc3ec8d77b6a | 289 | } |
kyxstark | 2:dc3ec8d77b6a | 290 | |
kyxstark | 2:dc3ec8d77b6a | 291 | /****************************************************************************************/ |
kyxstark | 2:dc3ec8d77b6a | 292 | /* FUNCTION NAME: SendSpeedDecel */ |
kyxstark | 2:dc3ec8d77b6a | 293 | /* DESCRIPTION : Envoie un asservissement paramètre retournant à une vitesse */ |
kyxstark | 2:dc3ec8d77b6a | 294 | /****************************************************************************************/ |
kyxstark | 2:dc3ec8d77b6a | 295 | /* |
kyxstark | 2:dc3ec8d77b6a | 296 | void SendSpeedDecel (unsigned short vitesse, unsigned short deceleration) |
kyxstark | 2:dc3ec8d77b6a | 297 | { |
kyxstark | 2:dc3ec8d77b6a | 298 | CANMessage msgTx=CANMessage(); |
kyxstark | 2:dc3ec8d77b6a | 299 | msgTx.id=ASSERVISSEMENT_CONFIG_DECEL; |
kkoichy | 0:3a1f19e51eb2 | 300 | msgTx.format=CANStandard; |
kkoichy | 0:3a1f19e51eb2 | 301 | msgTx.type=CANData; |
kkoichy | 0:3a1f19e51eb2 | 302 | msgTx.len=4; |
kkoichy | 0:3a1f19e51eb2 | 303 | msgTx.data[0]=(unsigned char)(vitesse&0x00FF); |
kkoichy | 0:3a1f19e51eb2 | 304 | msgTx.data[1]=(unsigned char)((vitesse&0xFF00)>>8); |
kyxstark | 2:dc3ec8d77b6a | 305 | msgTx.data[2]=(unsigned char)(deceleration&0x00FF); |
kyxstark | 2:dc3ec8d77b6a | 306 | msgTx.data[3]=(unsigned char)((deceleration&0xFF00)>>8); |
kyxstark | 2:dc3ec8d77b6a | 307 | |
kyxstark | 2:dc3ec8d77b6a | 308 | can.write(msgTx); |
kyxstark | 2:dc3ec8d77b6a | 309 | |
kyxstark | 2:dc3ec8d77b6a | 310 | }*/ |
kyxstark | 2:dc3ec8d77b6a | 311 | |
kyxstark | 2:dc3ec8d77b6a | 312 |