![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
init
fct.cpp@0:98d2bcd7ae29, 2017-06-09 (annotated)
- Committer:
- qj604184
- Date:
- Fri Jun 09 23:20:19 2017 +0000
- Revision:
- 0:98d2bcd7ae29
cachanNRC
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
qj604184 | 0:98d2bcd7ae29 | 1 | #include "mbed.h" |
qj604184 | 0:98d2bcd7ae29 | 2 | #include "fct.h" |
qj604184 | 0:98d2bcd7ae29 | 3 | |
qj604184 | 0:98d2bcd7ae29 | 4 | void Vitmoteur(float VitG, float VitD) |
qj604184 | 0:98d2bcd7ae29 | 5 | { |
qj604184 | 0:98d2bcd7ae29 | 6 | if(VitG<0) { |
qj604184 | 0:98d2bcd7ae29 | 7 | VitG=-1*VitG; |
qj604184 | 0:98d2bcd7ae29 | 8 | cmdI2C=cmdI2C&0xfe; //passe le moteur gauche en marche arriere 00000001 |
qj604184 | 0:98d2bcd7ae29 | 9 | } else { |
qj604184 | 0:98d2bcd7ae29 | 10 | cmdI2C=cmdI2C|0x01; // marche avant 11110111 mot gauche |
qj604184 | 0:98d2bcd7ae29 | 11 | } |
qj604184 | 0:98d2bcd7ae29 | 12 | if(VitD<0) { |
qj604184 | 0:98d2bcd7ae29 | 13 | VitD=-1*VitD; |
qj604184 | 0:98d2bcd7ae29 | 14 | cmdI2C=cmdI2C&0xfd; //passe le moteur gauche en marche arriere 00000100 |
qj604184 | 0:98d2bcd7ae29 | 15 | } else { |
qj604184 | 0:98d2bcd7ae29 | 16 | cmdI2C=cmdI2C|0x02;//marche avant 11111011 mot droit |
qj604184 | 0:98d2bcd7ae29 | 17 | } |
qj604184 | 0:98d2bcd7ae29 | 18 | monI2C.write(ADR_PCF,&cmdI2C,1); |
qj604184 | 0:98d2bcd7ae29 | 19 | MotG.pulsewidth(((100-VitG)/100.0)*PERIOD); |
qj604184 | 0:98d2bcd7ae29 | 20 | MotD.pulsewidth(((100-VitD)/100.0)*PERIOD); |
qj604184 | 0:98d2bcd7ae29 | 21 | } |
qj604184 | 0:98d2bcd7ae29 | 22 | void init(void) |
qj604184 | 0:98d2bcd7ae29 | 23 | { |
qj604184 | 0:98d2bcd7ae29 | 24 | if(C1.read()>0.5) { |
qj604184 | 0:98d2bcd7ae29 | 25 | captL1=0; |
qj604184 | 0:98d2bcd7ae29 | 26 | } else { |
qj604184 | 0:98d2bcd7ae29 | 27 | captL1=1; |
qj604184 | 0:98d2bcd7ae29 | 28 | } |
qj604184 | 0:98d2bcd7ae29 | 29 | if(C3.read()>0.5) { |
qj604184 | 0:98d2bcd7ae29 | 30 | captL3=0; |
qj604184 | 0:98d2bcd7ae29 | 31 | } else { |
qj604184 | 0:98d2bcd7ae29 | 32 | captL3=1; |
qj604184 | 0:98d2bcd7ae29 | 33 | } |
qj604184 | 0:98d2bcd7ae29 | 34 | |
qj604184 | 0:98d2bcd7ae29 | 35 | |
qj604184 | 0:98d2bcd7ae29 | 36 | |
qj604184 | 0:98d2bcd7ae29 | 37 | } |