![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
version 3.0
Dependencies: mbed
Fork of Robot_a_cables_v2_6_5 by
main.cpp@8:1e6d3d9ae1d3, 2018-05-15 (annotated)
- Committer:
- protongamer
- Date:
- Tue May 15 10:02:20 2018 +0000
- Revision:
- 8:1e6d3d9ae1d3
- Parent:
- 7:e87feff62bfd
- Child:
- 9:0f63d4cb5613
v2.6;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
LouisReynier | 0:1ab5fdb4fa56 | 1 | #include "mbed.h" |
protongamer | 6:ffffa9dfadfc | 2 | #include "parameters.h" |
protongamer | 3:86e21a36eecb | 3 | /* |
protongamer | 3:86e21a36eecb | 4 | Projet BTS SN - Robot à câbles - Lycée Georges Cabanis |
protongamer | 3:86e21a36eecb | 5 | Enzo Niro - Erwin Sazio |
protongamer | 3:86e21a36eecb | 6 | Transmission par Bus CAN(protocol CANOpen) |
protongamer | 3:86e21a36eecb | 7 | |
protongamer | 3:86e21a36eecb | 8 | */ |
LouisReynier | 0:1ab5fdb4fa56 | 9 | |
protongamer | 8:1e6d3d9ae1d3 | 10 | #define DEGRAD 0 |
protongamer | 8:1e6d3d9ae1d3 | 11 | #define NORMAL 1 |
protongamer | 1:4d70e593345f | 12 | |
protongamer | 8:1e6d3d9ae1d3 | 13 | #define ALPHA 425000 |
protongamer | 3:86e21a36eecb | 14 | |
protongamer | 3:86e21a36eecb | 15 | DigitalOut MOTOR1_OP(LED1); |
protongamer | 3:86e21a36eecb | 16 | DigitalOut MOTOR2_OP(LED2); |
protongamer | 3:86e21a36eecb | 17 | DigitalOut DEB_MOD_DEG(LED3); |
protongamer | 3:86e21a36eecb | 18 | DigitalOut DEB_MOD_NOR(LED4); |
protongamer | 7:e87feff62bfd | 19 | DigitalOut MOD_DEG(p25); |
protongamer | 7:e87feff62bfd | 20 | DigitalOut MOD_NOR(p26); |
protongamer | 3:86e21a36eecb | 21 | DigitalIn SWH(p5); |
protongamer | 3:86e21a36eecb | 22 | DigitalIn SWV(p6); |
protongamer | 3:86e21a36eecb | 23 | DigitalIn BPO(p7); |
Ringslev | 5:d5a021bbe81b | 24 | AnalogIn joystick_ctr(p15); // Pin 2 (fil vert) Center Tap Reference |
Ringslev | 5:d5a021bbe81b | 25 | AnalogIn joystick_x(p16); // Pin 4 (fil jaune) |
Ringslev | 5:d5a021bbe81b | 26 | AnalogIn joystick_y(p17); // Pin 5 (fil bleu) |
protongamer | 3:86e21a36eecb | 27 | |
Ringslev | 5:d5a021bbe81b | 28 | CAN can2(p30, p29, 1000000); // on definit pin et debit |
Ringslev | 5:d5a021bbe81b | 29 | CANMessage msg; |
Ringslev | 5:d5a021bbe81b | 30 | Serial pc(USBTX, USBRX); |
protongamer | 4:3fd7c53d31c1 | 31 | |
Ringslev | 5:d5a021bbe81b | 32 | uint8_t mode = 0; |
Ringslev | 5:d5a021bbe81b | 33 | int x,y,ctr_x,ctr_y; // Variables de joystick |
Ringslev | 5:d5a021bbe81b | 34 | uint8_t ping = 0; //variable pour etat de processus |
Ringslev | 5:d5a021bbe81b | 35 | uint8_t done = 0; |
Ringslev | 5:d5a021bbe81b | 36 | char command[8]; //word to send command |
protongamer | 7:e87feff62bfd | 37 | uint16_t timer_process_read; //counter to make mbed read actual position |
protongamer | 7:e87feff62bfd | 38 | double dy = 1262, dx = 492.5;//coordinates values when origin is done |
protongamer | 6:ffffa9dfadfc | 39 | //these positions are in counters |
protongamer | 6:ffffa9dfadfc | 40 | int32_t p1, p2; //motors positions |
protongamer | 7:e87feff62bfd | 41 | int32_t p_actual, p_actual2, p_pom, p_pom2; //p_actual position read by can, p_pom position done when origin is made |
protongamer | 6:ffffa9dfadfc | 42 | |
protongamer | 6:ffffa9dfadfc | 43 | //longueur câbles |
protongamer | 6:ffffa9dfadfc | 44 | //lx = longueur entre les point des moteurs |
protongamer | 6:ffffa9dfadfc | 45 | //l1 = longueur moteur gauche à l'effecteur |
protongamer | 6:ffffa9dfadfc | 46 | //l2 = longueur moteur droite à l'effecteur |
protongamer | 7:e87feff62bfd | 47 | int32_t lx, l1, l2; |
protongamer | 8:1e6d3d9ae1d3 | 48 | float pVx, pVy; // variables pour afficher les vélocitées appliquées sur le moniteur |
protongamer | 6:ffffa9dfadfc | 49 | |
protongamer | 6:ffffa9dfadfc | 50 | |
protongamer | 6:ffffa9dfadfc | 51 | |
protongamer | 1:4d70e593345f | 52 | |
Ringslev | 5:d5a021bbe81b | 53 | void display_mode() |
Ringslev | 5:d5a021bbe81b | 54 | { |
protongamer | 8:1e6d3d9ae1d3 | 55 | if(mode == DEGRAD) // MODE DEGRADE |
Ringslev | 5:d5a021bbe81b | 56 | { |
Ringslev | 5:d5a021bbe81b | 57 | MOD_DEG = 1; |
Ringslev | 5:d5a021bbe81b | 58 | MOD_NOR = 0; |
Ringslev | 5:d5a021bbe81b | 59 | } |
protongamer | 8:1e6d3d9ae1d3 | 60 | else if(mode == NORMAL) // MODE NORMAL |
Ringslev | 5:d5a021bbe81b | 61 | { |
Ringslev | 5:d5a021bbe81b | 62 | MOD_DEG = 0; |
Ringslev | 5:d5a021bbe81b | 63 | MOD_NOR = 1; |
Ringslev | 5:d5a021bbe81b | 64 | } |
Ringslev | 5:d5a021bbe81b | 65 | } |
protongamer | 1:4d70e593345f | 66 | |
protongamer | 1:4d70e593345f | 67 | void send(int id, char octet_emis[], char RouD, char longueur ) |
protongamer | 1:4d70e593345f | 68 | { |
protongamer | 1:4d70e593345f | 69 | int emis_ok = 0 ; |
LouisReynier | 0:1ab5fdb4fa56 | 70 | |
protongamer | 4:3fd7c53d31c1 | 71 | MOTOR1_OP = 1; |
protongamer | 4:3fd7c53d31c1 | 72 | MOTOR1_OP = 0; |
protongamer | 4:3fd7c53d31c1 | 73 | |
protongamer | 1:4d70e593345f | 74 | if (RouD == 'D') |
protongamer | 1:4d70e593345f | 75 | { emis_ok = can2.write(CANMessage(id, octet_emis, longueur, CANData, CANStandard )) ; |
protongamer | 3:86e21a36eecb | 76 | //pc.printf("id: %x, %c L = %d, \nData : %x:%x:%x:%x ... \n", id,RouD,longueur,octet_emis[0],octet_emis[1], octet_emis[2], octet_emis[3] ); |
protongamer | 1:4d70e593345f | 77 | }// c'ets la valeur retournée par la fonction write |
protongamer | 1:4d70e593345f | 78 | else |
protongamer | 1:4d70e593345f | 79 | { emis_ok = can2.write(CANMessage(id, octet_emis, longueur, CANRemote, CANStandard )); |
protongamer | 3:86e21a36eecb | 80 | //pc.printf("id: %x, %c L = %d, \nData : %x:%x:%x:%x ... \n", id,RouD,longueur,octet_emis[0],octet_emis[1], octet_emis[2], octet_emis[3] ); |
protongamer | 1:4d70e593345f | 81 | } |
protongamer | 1:4d70e593345f | 82 | //lcd.locate(0,10); |
protongamer | 1:4d70e593345f | 83 | //lcd.printf("id: %x, %c L = %d, \nData : %x:%x:%x:%x ... \n", id,RouD,longueur,octet_emis[0],octet_emis[1], octet_emis[2], octet_emis[3] ); |
protongamer | 3:86e21a36eecb | 84 | /*if(emis_ok) { |
protongamer | 1:4d70e593345f | 85 | // ici octet emis n'a pas de sens car trame remote ! |
protongamer | 3:86e21a36eecb | 86 | //pc.printf("send \r \n"); |
protongamer | 3:86e21a36eecb | 87 | } */ |
LouisReynier | 0:1ab5fdb4fa56 | 88 | } |
protongamer | 1:4d70e593345f | 89 | |
Ringslev | 5:d5a021bbe81b | 90 | void initialisation() |
Ringslev | 5:d5a021bbe81b | 91 | { |
Ringslev | 5:d5a021bbe81b | 92 | pc.printf("starting...\r\n"); |
Ringslev | 5:d5a021bbe81b | 93 | MOD_DEG = 1; |
Ringslev | 5:d5a021bbe81b | 94 | MOD_NOR = 0; |
Ringslev | 5:d5a021bbe81b | 95 | wait(0.1); |
Ringslev | 5:d5a021bbe81b | 96 | MOD_DEG = 0; |
Ringslev | 5:d5a021bbe81b | 97 | MOD_NOR = 1; |
Ringslev | 5:d5a021bbe81b | 98 | wait(0.1); |
Ringslev | 5:d5a021bbe81b | 99 | MOD_DEG = 1; |
Ringslev | 5:d5a021bbe81b | 100 | MOD_NOR = 0; |
Ringslev | 5:d5a021bbe81b | 101 | wait(0.1); |
Ringslev | 5:d5a021bbe81b | 102 | MOD_DEG = 0; |
Ringslev | 5:d5a021bbe81b | 103 | MOD_NOR = 1; |
Ringslev | 5:d5a021bbe81b | 104 | wait(0.1); |
Ringslev | 5:d5a021bbe81b | 105 | MOD_DEG = 1; |
Ringslev | 5:d5a021bbe81b | 106 | MOD_NOR = 0; |
Ringslev | 5:d5a021bbe81b | 107 | wait(0.1); |
Ringslev | 5:d5a021bbe81b | 108 | MOD_DEG = 0; |
Ringslev | 5:d5a021bbe81b | 109 | MOD_NOR = 0; |
Ringslev | 5:d5a021bbe81b | 110 | wait(0.1); |
Ringslev | 5:d5a021bbe81b | 111 | |
protongamer | 6:ffffa9dfadfc | 112 | command[0] = DRIVER_R1; |
Ringslev | 5:d5a021bbe81b | 113 | command[1] = DRIVER_R2; |
Ringslev | 5:d5a021bbe81b | 114 | |
Ringslev | 5:d5a021bbe81b | 115 | while(ping == 0) // INIT MOTEUR DROIT |
Ringslev | 5:d5a021bbe81b | 116 | { |
Ringslev | 5:d5a021bbe81b | 117 | pc.printf("ping droite ...\r\n"); |
Ringslev | 5:d5a021bbe81b | 118 | send(INITOP, command, 'D', 2); //send word to put pluto driver in operational mode |
Ringslev | 5:d5a021bbe81b | 119 | MOD_NOR = 1; |
Ringslev | 5:d5a021bbe81b | 120 | if(can2.read(msg)) |
Ringslev | 5:d5a021bbe81b | 121 | { |
Ringslev | 5:d5a021bbe81b | 122 | for(int i = 0; i < msg.len; i++) |
Ringslev | 5:d5a021bbe81b | 123 | { |
Ringslev | 5:d5a021bbe81b | 124 | pc.printf("0x%x ",msg.data[i]); |
Ringslev | 5:d5a021bbe81b | 125 | ping = 1; |
Ringslev | 5:d5a021bbe81b | 126 | }//end of for |
Ringslev | 5:d5a021bbe81b | 127 | pc.printf("\r \n"); |
Ringslev | 5:d5a021bbe81b | 128 | }//can.read(msg) |
Ringslev | 5:d5a021bbe81b | 129 | wait(0.1); |
Ringslev | 5:d5a021bbe81b | 130 | MOD_NOR = 0; |
Ringslev | 5:d5a021bbe81b | 131 | wait(0.9); |
Ringslev | 5:d5a021bbe81b | 132 | } |
Ringslev | 5:d5a021bbe81b | 133 | |
Ringslev | 5:d5a021bbe81b | 134 | ping =0; |
Ringslev | 5:d5a021bbe81b | 135 | command[0] = DRIVER_L1; |
Ringslev | 5:d5a021bbe81b | 136 | command[1] = DRIVER_L2; |
Ringslev | 5:d5a021bbe81b | 137 | |
Ringslev | 5:d5a021bbe81b | 138 | while(ping == 0) // INIT MOTEUR GAUCHE |
Ringslev | 5:d5a021bbe81b | 139 | { |
Ringslev | 5:d5a021bbe81b | 140 | pc.printf("ping gauche ...\r\n"); |
Ringslev | 5:d5a021bbe81b | 141 | send(INITOP, command, 'D', 2); //send word to put pluto driver in operational mode |
protongamer | 3:86e21a36eecb | 142 | MOD_DEG = 1; |
protongamer | 3:86e21a36eecb | 143 | if(can2.read(msg)) { |
protongamer | 4:3fd7c53d31c1 | 144 | for(int i = 0; i < msg.len; i++){ |
protongamer | 4:3fd7c53d31c1 | 145 | pc.printf("0x%x ",msg.data[i]); |
protongamer | 4:3fd7c53d31c1 | 146 | ping = 1; |
protongamer | 4:3fd7c53d31c1 | 147 | }//end of for |
protongamer | 4:3fd7c53d31c1 | 148 | pc.printf("\r \n"); |
protongamer | 4:3fd7c53d31c1 | 149 | }//can.read(msg) |
protongamer | 3:86e21a36eecb | 150 | wait(0.1); |
Ringslev | 5:d5a021bbe81b | 151 | MOD_DEG = 0; |
protongamer | 3:86e21a36eecb | 152 | wait(0.9); |
Ringslev | 5:d5a021bbe81b | 153 | } |
Ringslev | 5:d5a021bbe81b | 154 | } // fin initialisation |
Ringslev | 5:d5a021bbe81b | 155 | |
protongamer | 6:ffffa9dfadfc | 156 | |
protongamer | 6:ffffa9dfadfc | 157 | |
protongamer | 6:ffffa9dfadfc | 158 | void read_position(){ |
protongamer | 6:ffffa9dfadfc | 159 | |
protongamer | 8:1e6d3d9ae1d3 | 160 | //timer_process_read++;//var used to set time for reading value |
protongamer | 8:1e6d3d9ae1d3 | 161 | l1 = LENGTH_L1_PO - (p1/2545); //Length 1 |
protongamer | 8:1e6d3d9ae1d3 | 162 | l2 = LENGTH_L2_PO - (p2/2545); //Length 2 |
protongamer | 8:1e6d3d9ae1d3 | 163 | lx = LENGTH_MOTOR; |
protongamer | 8:1e6d3d9ae1d3 | 164 | dx = (((double) l1*(double) l1) - ((double) l2*(double) l2) + ((double) lx*(double) lx))/(2*(double) lx); |
protongamer | 8:1e6d3d9ae1d3 | 165 | dy = sqrt(((double) l1*(double) l1) - (dx*dx)); |
protongamer | 8:1e6d3d9ae1d3 | 166 | |
protongamer | 8:1e6d3d9ae1d3 | 167 | if(BPO == 0){ |
protongamer | 7:e87feff62bfd | 168 | |
protongamer | 8:1e6d3d9ae1d3 | 169 | p_pom = p_actual; |
protongamer | 8:1e6d3d9ae1d3 | 170 | p_pom2 = p_actual2; |
protongamer | 8:1e6d3d9ae1d3 | 171 | mode = !mode; //Change mode |
protongamer | 8:1e6d3d9ae1d3 | 172 | wait(1.0); |
protongamer | 8:1e6d3d9ae1d3 | 173 | } |
protongamer | 6:ffffa9dfadfc | 174 | |
protongamer | 8:1e6d3d9ae1d3 | 175 | p1 = p_pom - p_actual; |
protongamer | 8:1e6d3d9ae1d3 | 176 | p2 = p_pom2 - p_actual2; |
protongamer | 8:1e6d3d9ae1d3 | 177 | |
protongamer | 8:1e6d3d9ae1d3 | 178 | //Left motor |
protongamer | 8:1e6d3d9ae1d3 | 179 | send(TPDO1_L, command, 'R', 0); //Ask position for second length |
protongamer | 8:1e6d3d9ae1d3 | 180 | if(can2.read(msg)){ |
protongamer | 8:1e6d3d9ae1d3 | 181 | p_actual = msg.data[3]; |
protongamer | 8:1e6d3d9ae1d3 | 182 | p_actual = p_actual << 8; |
protongamer | 8:1e6d3d9ae1d3 | 183 | p_actual = p_actual | msg.data[2]; |
protongamer | 8:1e6d3d9ae1d3 | 184 | p_actual = p_actual << 8; |
protongamer | 8:1e6d3d9ae1d3 | 185 | p_actual = p_actual | msg.data[1]; |
protongamer | 8:1e6d3d9ae1d3 | 186 | p_actual = p_actual << 8; |
protongamer | 8:1e6d3d9ae1d3 | 187 | p_actual = p_actual | msg.data[0]; |
protongamer | 8:1e6d3d9ae1d3 | 188 | } |
protongamer | 8:1e6d3d9ae1d3 | 189 | //timer_process_read = 1; |
protongamer | 8:1e6d3d9ae1d3 | 190 | wait(0.0005); |
protongamer | 8:1e6d3d9ae1d3 | 191 | send(TPDO1_R, command, 'R', 0); //Ask position for first length |
protongamer | 8:1e6d3d9ae1d3 | 192 | if(can2.read(msg)){ |
protongamer | 8:1e6d3d9ae1d3 | 193 | p_actual2 = msg.data[3]; |
protongamer | 8:1e6d3d9ae1d3 | 194 | p_actual2 = p_actual2 << 8; |
protongamer | 8:1e6d3d9ae1d3 | 195 | p_actual2 = p_actual2 | msg.data[2]; |
protongamer | 8:1e6d3d9ae1d3 | 196 | p_actual2 = p_actual2 << 8; |
protongamer | 8:1e6d3d9ae1d3 | 197 | p_actual2 = p_actual2 | msg.data[1]; |
protongamer | 8:1e6d3d9ae1d3 | 198 | p_actual2 = p_actual2 << 8; |
protongamer | 8:1e6d3d9ae1d3 | 199 | p_actual2 = p_actual2 | msg.data[0]; |
protongamer | 8:1e6d3d9ae1d3 | 200 | } |
protongamer | 8:1e6d3d9ae1d3 | 201 | |
protongamer | 6:ffffa9dfadfc | 202 | |
protongamer | 6:ffffa9dfadfc | 203 | }//fin de fonction |
protongamer | 6:ffffa9dfadfc | 204 | |
protongamer | 6:ffffa9dfadfc | 205 | |
protongamer | 6:ffffa9dfadfc | 206 | |
Ringslev | 5:d5a021bbe81b | 207 | void control_Moteur() |
Ringslev | 5:d5a021bbe81b | 208 | { |
Ringslev | 5:d5a021bbe81b | 209 | ///////////// CONTROLE MOTEUR ////////////////////////////////////////////////////////////////////////////// |
Ringslev | 5:d5a021bbe81b | 210 | // LECTURE Joystick + stockage valeurs dans x, y |
Ringslev | 5:d5a021bbe81b | 211 | ctr_x = int(-((joystick_ctr.read()*100)-50)); |
Ringslev | 5:d5a021bbe81b | 212 | ctr_y = int((joystick_ctr.read()*100)-50); |
Ringslev | 5:d5a021bbe81b | 213 | if(SWH){x = int(-((joystick_x.read()*100)-50))+ctr_x;}else{x=0;} // Detection x avec correction ctr de -42 à +42 |
Ringslev | 5:d5a021bbe81b | 214 | if(SWV){y = int((joystick_y.read()*100)-50)+ctr_y;}else{y=0;} // Detection y avec correction ctr |
protongamer | 8:1e6d3d9ae1d3 | 215 | float VX; // Calcule brut vélocité x, y |
protongamer | 8:1e6d3d9ae1d3 | 216 | float VY; |
protongamer | 8:1e6d3d9ae1d3 | 217 | long int VM_L; // Calcule des vélocités exactes de chaques moteurs |
protongamer | 8:1e6d3d9ae1d3 | 218 | long int VM_R; |
protongamer | 8:1e6d3d9ae1d3 | 219 | |
Ringslev | 5:d5a021bbe81b | 220 | if(mode ==0) |
Ringslev | 5:d5a021bbe81b | 221 | { |
Ringslev | 5:d5a021bbe81b | 222 | ///////////// MODE DEGRADE ///////////////////////////////////// |
protongamer | 8:1e6d3d9ae1d3 | 223 | VX = (float(x)/42)*425000; // Calcule brut vélocité x, y |
protongamer | 8:1e6d3d9ae1d3 | 224 | VY = (float(y)/42)*425000; |
protongamer | 8:1e6d3d9ae1d3 | 225 | VM_L = VX - VY; // Calcule des vélocités exactes de chaques moteurs |
protongamer | 8:1e6d3d9ae1d3 | 226 | VM_R = -VX - VY; |
Ringslev | 5:d5a021bbe81b | 227 | |
Ringslev | 5:d5a021bbe81b | 228 | command[0]= (VM_L & 0x000000FF); // Masque + décalage pour translation big vers little endian |
Ringslev | 5:d5a021bbe81b | 229 | command[1]= (VM_L & 0x0000FF00)>>8; |
Ringslev | 5:d5a021bbe81b | 230 | command[2]= (VM_L & 0x00FF0000)>>16; |
Ringslev | 5:d5a021bbe81b | 231 | command[3]= (VM_L & 0xFF000000)>>24; |
Ringslev | 5:d5a021bbe81b | 232 | send(RPDO1_L, command, 'D', 4); // Controle moteur gauche |
Ringslev | 5:d5a021bbe81b | 233 | |
Ringslev | 5:d5a021bbe81b | 234 | command[0]= (VM_R & 0x000000FF); |
Ringslev | 5:d5a021bbe81b | 235 | command[1]= (VM_R & 0x0000FF00)>>8; |
Ringslev | 5:d5a021bbe81b | 236 | command[2]= (VM_R & 0x00FF0000)>>16; |
Ringslev | 5:d5a021bbe81b | 237 | command[3]= (VM_R & 0xFF000000)>>24; |
Ringslev | 5:d5a021bbe81b | 238 | send(RPDO1_R, command, 'D', 4); // Controle moteur droit |
Ringslev | 5:d5a021bbe81b | 239 | //////////////////////////////////////////////////////////////// |
Ringslev | 5:d5a021bbe81b | 240 | } |
Ringslev | 5:d5a021bbe81b | 241 | else if(mode ==1) |
Ringslev | 5:d5a021bbe81b | 242 | { |
protongamer | 8:1e6d3d9ae1d3 | 243 | ///////////// MODE NORMAL ////////////////////////////////////// |
protongamer | 8:1e6d3d9ae1d3 | 244 | VX = x; |
protongamer | 8:1e6d3d9ae1d3 | 245 | VY = y; |
protongamer | 8:1e6d3d9ae1d3 | 246 | VM_L = (ALPHA/42); |
protongamer | 8:1e6d3d9ae1d3 | 247 | VM_L = (VM_L/l1)*((dx*VX)-(dy*VY)); |
protongamer | 8:1e6d3d9ae1d3 | 248 | VM_R = (ALPHA/42); |
protongamer | 8:1e6d3d9ae1d3 | 249 | VM_R = (VM_R/l2)*((-(lx-dx)*VX)-(dy*VY)); |
protongamer | 8:1e6d3d9ae1d3 | 250 | |
protongamer | 8:1e6d3d9ae1d3 | 251 | command[0]= (VM_L & 0x000000FF); // Masque + décalage pour translation big vers little endian |
protongamer | 8:1e6d3d9ae1d3 | 252 | command[1]= (VM_L & 0x0000FF00)>>8; |
protongamer | 8:1e6d3d9ae1d3 | 253 | command[2]= (VM_L & 0x00FF0000)>>16; |
protongamer | 8:1e6d3d9ae1d3 | 254 | command[3]= (VM_L & 0xFF000000)>>24; |
protongamer | 8:1e6d3d9ae1d3 | 255 | send(RPDO1_L, command, 'D', 4); // Controle moteur gauche |
protongamer | 8:1e6d3d9ae1d3 | 256 | |
protongamer | 8:1e6d3d9ae1d3 | 257 | command[0]= (VM_R & 0x000000FF); |
protongamer | 8:1e6d3d9ae1d3 | 258 | command[1]= (VM_R & 0x0000FF00)>>8; |
protongamer | 8:1e6d3d9ae1d3 | 259 | command[2]= (VM_R & 0x00FF0000)>>16; |
protongamer | 8:1e6d3d9ae1d3 | 260 | command[3]= (VM_R & 0xFF000000)>>24; |
protongamer | 8:1e6d3d9ae1d3 | 261 | send(RPDO1_R, command, 'D', 4); // Controle moteur droit |
Ringslev | 5:d5a021bbe81b | 262 | } |
protongamer | 8:1e6d3d9ae1d3 | 263 | pVx = VM_R; |
protongamer | 8:1e6d3d9ae1d3 | 264 | pVy = VM_L; |
Ringslev | 5:d5a021bbe81b | 265 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
Ringslev | 5:d5a021bbe81b | 266 | } |
Ringslev | 5:d5a021bbe81b | 267 | |
Ringslev | 5:d5a021bbe81b | 268 | int main() { |
Ringslev | 5:d5a021bbe81b | 269 | |
Ringslev | 5:d5a021bbe81b | 270 | //define Pullup switch |
Ringslev | 5:d5a021bbe81b | 271 | SWH.mode(PullUp); |
Ringslev | 5:d5a021bbe81b | 272 | SWV.mode(PullUp); |
Ringslev | 5:d5a021bbe81b | 273 | BPO.mode(PullUp); |
Ringslev | 5:d5a021bbe81b | 274 | |
Ringslev | 5:d5a021bbe81b | 275 | initialisation(); // Mise en mode opérationnel des moteurs |
Ringslev | 5:d5a021bbe81b | 276 | |
protongamer | 6:ffffa9dfadfc | 277 | |
protongamer | 6:ffffa9dfadfc | 278 | |
protongamer | 8:1e6d3d9ae1d3 | 279 | |
Ringslev | 5:d5a021bbe81b | 280 | while(1) |
Ringslev | 5:d5a021bbe81b | 281 | { |
protongamer | 7:e87feff62bfd | 282 | |
protongamer | 7:e87feff62bfd | 283 | |
protongamer | 7:e87feff62bfd | 284 | pc.printf("L1 = %d", l1); |
protongamer | 7:e87feff62bfd | 285 | pc.printf("\t L2 = %d", l2); |
protongamer | 7:e87feff62bfd | 286 | pc.printf("\t x = %f", dx); |
protongamer | 8:1e6d3d9ae1d3 | 287 | pc.printf("\t y = %f", dy); |
protongamer | 8:1e6d3d9ae1d3 | 288 | pc.printf("\t VM_L = %f", pVx); |
protongamer | 8:1e6d3d9ae1d3 | 289 | pc.printf("\t VM_R = %f \r\n", pVy); |
protongamer | 4:3fd7c53d31c1 | 290 | |
protongamer | 7:e87feff62bfd | 291 | |
protongamer | 8:1e6d3d9ae1d3 | 292 | read_position(); |
Ringslev | 5:d5a021bbe81b | 293 | control_Moteur(); // Controle du meteur mode degradé et normal |
Ringslev | 5:d5a021bbe81b | 294 | display_mode(); // Controle des led affichant le mode |
protongamer | 1:4d70e593345f | 295 | |
protongamer | 1:4d70e593345f | 296 | }// fin while(1) |
protongamer | 1:4d70e593345f | 297 | |
protongamer | 1:4d70e593345f | 298 | } // fin main |
protongamer | 4:3fd7c53d31c1 | 299 | |
protongamer | 4:3fd7c53d31c1 | 300 | |
protongamer | 4:3fd7c53d31c1 | 301 | |
protongamer | 1:4d70e593345f | 302 | |
protongamer | 3:86e21a36eecb | 303 |