towa ngo
/
okmtjidouki
ohhungooooooo
Fork of Jidouki by
main.cpp
- Committer:
- okmt
- Date:
- 2015-09-14
- Revision:
- 9:cccfe63e5d4c
- Parent:
- 8:834e3af75af8
File content as of revision 9:cccfe63e5d4c:
#include "mbed.h" #include "QEI.h" #include "main_new.h" int main() { while(true){ int c =0; //cはスイッチによって値うける、cの値を3パターン規定し、n,mに加算減算することで使えるものにする(または単純に定義してもいいか) int s = c; int m = c; Motor01(1.0); Motor02(1.0); /* mypwm.period_ms(10); mypwm.pulsewidth_ms(1); */ for(int i = s; i < wheel01.getPulses();) { if(wheel01.getPulses()>wheel02.getPulses()) {Motor01(1-pid_sample(wheel01.getPulses(),wheel02.getPulses()));} else {Motor02(1-pid_sample(wheel02.getPulses(),wheel01.getPulses()));} if(mypwm012<=0.1f&&mypwm022<=0.1f) {mypwm012=mypwm012-0.1f;mypwm022=mypwm022-0.1f;} } Motor03(0.0); wheel01.reset(); wheel02.reset(); //パルス値の初期化 Motor01(-1.0); //逆転 Motor02(-1.0); //逆転 for(int i = m; i > wheel01.getPulses();) {if(wheel01.getPulses()>wheel02.getPulses()) {Motor01(1-pid_sample(wheel01.getPulses(),wheel02.getPulses()));} else {Motor02(1-pid_sample(wheel02.getPulses(),wheel01.getPulses()));} if(mypwm011>=0.1f&&mypwm021>=0.1f) {mypwm011=mypwm011-0.1f;mypwm022=mypwm022-0.1f;} } myled = 1; //パルスがmの値にいくまで Motor01(0.0); Motor02(0.0); wheel01.reset(); wheel02.reset(); //パルス値の初期化 } }