programme ines avce xbee
Dependencies: MMA8451Q mbed xbee_lib
Fork of Programme_course by
shield.cpp@1:4a9196bcf97a, 2017-02-08 (annotated)
- Committer:
- inesmas3
- Date:
- Wed Feb 08 15:16:04 2017 +0000
- Revision:
- 1:4a9196bcf97a
- Parent:
- 0:3ec7fc598e48
- Child:
- 2:ddf9879f0e25
modif de ines updated au 8 fev 17
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Freescale_cup | 0:3ec7fc598e48 | 1 | #include "Mlib.h" |
Freescale_cup | 0:3ec7fc598e48 | 2 | |
Freescale_cup | 0:3ec7fc598e48 | 3 | /***************SHIELD*****************/ |
Freescale_cup | 0:3ec7fc598e48 | 4 | |
Freescale_cup | 0:3ec7fc598e48 | 5 | |
Freescale_cup | 0:3ec7fc598e48 | 6 | void moteurs_arriere() |
Freescale_cup | 0:3ec7fc598e48 | 7 | { |
Freescale_cup | 0:3ec7fc598e48 | 8 | vitesse_virage = new_bari/2; |
Freescale_cup | 0:3ec7fc598e48 | 9 | |
inesmas3 | 1:4a9196bcf97a | 10 | ajust_vitesse = ajust_vit_bosse +((ligne_droite*5)/2); |
inesmas3 | 1:4a9196bcf97a | 11 | |
inesmas3 | 1:4a9196bcf97a | 12 | pc.printf("%hi\n", ajust_vit_bosse); |
inesmas3 | 1:4a9196bcf97a | 13 | |
inesmas3 | 1:4a9196bcf97a | 14 | while(bosse==1) {PWM_motor(100,100);} // acceleration à diminuer pour la competition |
inesmas3 | 1:4a9196bcf97a | 15 | |
inesmas3 | 1:4a9196bcf97a | 16 | while(bosse==3) {PWM_motor(30,30);} |
inesmas3 | 1:4a9196bcf97a | 17 | |
Freescale_cup | 0:3ec7fc598e48 | 18 | if(VIT == 0) |
Freescale_cup | 0:3ec7fc598e48 | 19 | { |
Freescale_cup | 0:3ec7fc598e48 | 20 | PWM_motor(0,0); |
Freescale_cup | 0:3ec7fc598e48 | 21 | } |
Freescale_cup | 0:3ec7fc598e48 | 22 | else if(ralentire == 1) |
Freescale_cup | 0:3ec7fc598e48 | 23 | { |
Freescale_cup | 0:3ec7fc598e48 | 24 | if(vitesse_virage > 0) |
Freescale_cup | 0:3ec7fc598e48 | 25 | { |
inesmas3 | 1:4a9196bcf97a | 26 | PWM_motor((VIT+ajust_vitesse) - vitesse_virage,(VIT+ajust_vitesse)+ 4*vitesse_virage); // ajust_vitesse seulemnt sur le moteur gauche????? |
Freescale_cup | 0:3ec7fc598e48 | 27 | } |
Freescale_cup | 0:3ec7fc598e48 | 28 | else |
Freescale_cup | 0:3ec7fc598e48 | 29 | { |
inesmas3 | 1:4a9196bcf97a | 30 | PWM_motor((VIT+ajust_vitesse)- 4*vitesse_virage, (VIT+ajust_vitesse) + vitesse_virage); |
Freescale_cup | 0:3ec7fc598e48 | 31 | } |
Freescale_cup | 0:3ec7fc598e48 | 32 | } |
Freescale_cup | 0:3ec7fc598e48 | 33 | else |
Freescale_cup | 0:3ec7fc598e48 | 34 | { |
inesmas3 | 1:4a9196bcf97a | 35 | PWM_motor((VIT+ajust_vitesse)- vitesse_virage, (VIT+ajust_vitesse) + vitesse_virage); |
inesmas3 | 1:4a9196bcf97a | 36 | |
Freescale_cup | 0:3ec7fc598e48 | 37 | } |
Freescale_cup | 0:3ec7fc598e48 | 38 | |
Freescale_cup | 0:3ec7fc598e48 | 39 | } |
Freescale_cup | 0:3ec7fc598e48 | 40 | |
Freescale_cup | 0:3ec7fc598e48 | 41 | void test_servo(int time) |
Freescale_cup | 0:3ec7fc598e48 | 42 | { |
Freescale_cup | 0:3ec7fc598e48 | 43 | Timer debut_fct; |
Freescale_cup | 0:3ec7fc598e48 | 44 | debut_fct.start(); |
Freescale_cup | 0:3ec7fc598e48 | 45 | while(debut_fct.read() < time) |
Freescale_cup | 0:3ec7fc598e48 | 46 | { |
Freescale_cup | 0:3ec7fc598e48 | 47 | for(int i = -30; i < 30; i++) |
Freescale_cup | 0:3ec7fc598e48 | 48 | { |
Freescale_cup | 0:3ec7fc598e48 | 49 | angle_servo_moteur(i); |
Freescale_cup | 0:3ec7fc598e48 | 50 | wait(0.01); |
Freescale_cup | 0:3ec7fc598e48 | 51 | } |
Freescale_cup | 0:3ec7fc598e48 | 52 | for(int i = 30; i > -30; i--) |
Freescale_cup | 0:3ec7fc598e48 | 53 | { |
Freescale_cup | 0:3ec7fc598e48 | 54 | angle_servo_moteur(i); |
Freescale_cup | 0:3ec7fc598e48 | 55 | wait(0.01); |
Freescale_cup | 0:3ec7fc598e48 | 56 | } |
Freescale_cup | 0:3ec7fc598e48 | 57 | } |
Freescale_cup | 0:3ec7fc598e48 | 58 | angle_servo_moteur(0); |
Freescale_cup | 0:3ec7fc598e48 | 59 | } |
Freescale_cup | 0:3ec7fc598e48 | 60 | |
Freescale_cup | 0:3ec7fc598e48 | 61 | void Get_pot_value() |
Freescale_cup | 0:3ec7fc598e48 | 62 | { |
Freescale_cup | 0:3ec7fc598e48 | 63 | VIT = 0, KP = 0; |
Freescale_cup | 0:3ec7fc598e48 | 64 | for(int i = 0; i < 10; i++) |
Freescale_cup | 0:3ec7fc598e48 | 65 | { |
Freescale_cup | 0:3ec7fc598e48 | 66 | VIT += ((pot1.read()+1)*(25.0)); |
Freescale_cup | 0:3ec7fc598e48 | 67 | KP += ((pot2.read()+1)*100); |
Freescale_cup | 0:3ec7fc598e48 | 68 | } |
Freescale_cup | 0:3ec7fc598e48 | 69 | VIT /= 10; |
inesmas3 | 1:4a9196bcf97a | 70 | pc.printf("VIT=%d\nKP=%d\n",VIT,KP); |
Freescale_cup | 0:3ec7fc598e48 | 71 | } |