Voili voilou

Dependencies:   RoboClaw StepperMotor mbed

Fork of Robot2016_2-0 by ARES

Committer:
sype
Date:
Wed Apr 13 11:43:10 2016 +0000
Revision:
44:b1fd7489369f
Parent:
43:d5aaff7d2bec
Child:
45:b53ae54062c6
Refonte du swag du code

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sype 41:b5a2fbc20beb 1 #include "func.h"
sype 0:ad9600df4a70 2
sype 0:ad9600df4a70 3 #define dt 10000
sype 10:ae3178aa94e9 4 #define ATTENTE 0
sype 10:ae3178aa94e9 5 #define GO 1
sype 10:ae3178aa94e9 6 #define STOP 2
sype 0:ad9600df4a70 7
sype 41:b5a2fbc20beb 8 /* Déclaration des différents éléments de l'IHM */
sype 10:ae3178aa94e9 9 InterruptIn mybutton(USER_BUTTON);
sype 10:ae3178aa94e9 10 DigitalIn button(USER_BUTTON);
sype 2:abdf8c6823a1 11 DigitalOut led(LED1);
sype 41:b5a2fbc20beb 12 DigitalOut bleu(PC_5);
sype 41:b5a2fbc20beb 13 DigitalOut blanc(PC_6);
sype 41:b5a2fbc20beb 14 DigitalOut rouge(PC_8);
sype 41:b5a2fbc20beb 15
sype 41:b5a2fbc20beb 16 /* AX12 */
sype 41:b5a2fbc20beb 17 AX12 left_hand(PA_15, PB_7, 4, 250000);
sype 41:b5a2fbc20beb 18 AX12 right_hand(PA_15, PB_7, 1, 250000);
sype 41:b5a2fbc20beb 19
sype 41:b5a2fbc20beb 20 /* Sharp */
sype 41:b5a2fbc20beb 21 AnalogIn capt1(PA_4);
sype 41:b5a2fbc20beb 22 AnalogIn capt2(PB_0);
sype 41:b5a2fbc20beb 23 AnalogIn capt3(PC_1);
sype 41:b5a2fbc20beb 24 AnalogIn capt4(PC_0);
sype 41:b5a2fbc20beb 25
sype 41:b5a2fbc20beb 26 /* Moteurs pas à pas */
sype 41:b5a2fbc20beb 27 Stepper RMot(NC, PB_10, PA_8);
sype 41:b5a2fbc20beb 28 Stepper ZMot(NC, PB_5, PB_4);
sype 41:b5a2fbc20beb 29 Stepper LMot(NC, PB_3, PA_10);
sype 41:b5a2fbc20beb 30 /* Fins de course */
sype 41:b5a2fbc20beb 31 InterruptIn EndR(PB_15);
sype 41:b5a2fbc20beb 32 InterruptIn EndZ(PB_14);
sype 41:b5a2fbc20beb 33 InterruptIn EndL(PB_13);
sype 41:b5a2fbc20beb 34
sype 0:ad9600df4a70 35 Ticker ticker;
sype 41:b5a2fbc20beb 36
sype 41:b5a2fbc20beb 37 Serial logger(USBTX, USBRX);
sype 41:b5a2fbc20beb 38 //Serial logger(PA_9, PA_10);
sype 10:ae3178aa94e9 39 RoboClaw roboclaw(460800, PA_11, PA_12);
IceTeam 39:309f38d1e49c 40 Odometry odo(61.7, 61.8, ENTRAXE, 4096, roboclaw);
sype 10:ae3178aa94e9 41
sype 41:b5a2fbc20beb 42 int i = 0, state = 0;
sype 41:b5a2fbc20beb 43 bool EL = false, EZ = false, ER = false;
sype 0:ad9600df4a70 44
sype 0:ad9600df4a70 45 void update_main(void);
sype 2:abdf8c6823a1 46 void init(void);
sype 0:ad9600df4a70 47
sype 43:d5aaff7d2bec 48 /* Debut du programme */
sype 0:ad9600df4a70 49 int main(void)
sype 10:ae3178aa94e9 50 {
sype 38:da3a2c781672 51 init();
sype 44:b1fd7489369f 52 while(1) JPO();
sype 2:abdf8c6823a1 53 }
sype 2:abdf8c6823a1 54
sype 2:abdf8c6823a1 55 void init(void)
sype 0:ad9600df4a70 56 {
sype 38:da3a2c781672 57 roboclaw.ForwardM1(ADR, 0);
sype 38:da3a2c781672 58 roboclaw.ForwardM2(ADR, 0);
sype 38:da3a2c781672 59 logger.baud(9600);
sype 38:da3a2c781672 60 logger.printf("Hello from main !\n\r");
sype 10:ae3178aa94e9 61 wait_ms(500);
sype 44:b1fd7489369f 62 bleu = 1, blanc = 1, rouge = 1;
sype 41:b5a2fbc20beb 63 wait_ms(1000);
sype 44:b1fd7489369f 64 bleu = 0, blanc = 0, rouge = 0;
sype 10:ae3178aa94e9 65
sype 10:ae3178aa94e9 66 while(button);
sype 10:ae3178aa94e9 67 wait(1);
sype 44:b1fd7489369f 68
sype 44:b1fd7489369f 69 init_ax12();
sype 44:b1fd7489369f 70 init_interrupt();
sype 41:b5a2fbc20beb 71 wait_ms(100);
IceTeam 39:309f38d1e49c 72 logger.printf("End init\n\r");
sype 0:ad9600df4a70 73 }
sype 0:ad9600df4a70 74
sype 0:ad9600df4a70 75 void update_main(void)
sype 0:ad9600df4a70 76 {
sype 0:ad9600df4a70 77 odo.update_odo();
sype 41:b5a2fbc20beb 78 checkAround();
sype 10:ae3178aa94e9 79 }