2018F3RC3班
/
f3rc_3_auto_encode
f3rc 3班のエンコーダのプログラムです。
Revision 6:e332ebb90091, committed 2018-09-04
- Comitter:
- nobu0103
- Date:
- Tue Sep 04 07:28:06 2018 +0000
- Parent:
- 5:7d50cbf6674b
- Commit message:
- f3rc ??????
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 7d50cbf6674b -r e332ebb90091 main.cpp --- a/main.cpp Tue Sep 04 07:13:44 2018 +0000 +++ b/main.cpp Tue Sep 04 07:28:06 2018 +0000 @@ -15,8 +15,8 @@ DigitalOut motor1cw(p27); DigitalOut motor2cw(p28); -EC ec1 (p12,p11,NC,500,0.05) -EC ec2 (p14,p13,NC,500,0.05) +Ec ec1 (p12,p11,NC,500,0.05) +Ec ec2 (p14,p13,NC,500,0.05) /*直進用*/ void straight(int x) //x=車輪の移動距離(mm) @@ -25,9 +25,10 @@ mortor2.period_us(50); ec1.setDiameter_mm(150); ec2.setDiameter_mm(150); + ec1.reset(); + ec2.reset(); double EC1_distance = ec1.getDistance_mm (); double EC2_distance = ec2.getDistance_mm (); - while(fabs(EC1_distance) <= x && fabs(EC2_distance) <= x) { motor1 = ; //モータ1への出力 motor2 = ; //モータ2への出力 @@ -43,9 +44,10 @@ mortor2.period_us(50); ec1.setDiameter_mm(150); ec2.setDiameter_mm(150); + ec1.reset(); + ec2.reset(); double EC1_distance = ec1.getDistance_mm (); double EC2_distance = ec2.getDistance_mm (); - while(fabs(EC1_distance) <= x && fabs(EC2_distance) <= x) { motor1 = ; //モータ1への出力 motor2 = ; //モータ2への出力 @@ -61,9 +63,10 @@ mortor2.period_us(50); ec1.setDiameter_mm(150); ec2.setDiameter_mm(150); + ec1.reset(); + ec2.reset(); double EC1_distance = ec1.getDistance_mm (); double EC2_distance = ec2.getDistance_mm (); - while(fabs(EC1_distance) <= x && fabs(EC2_distance) <= x) { motor1 = ; //モータ1への出力 motor2 = ; //モータ2への出力 @@ -79,9 +82,10 @@ mortor2.period_us(50); ec1.setDiameter_mm(150); ec2.setDiameter_mm(150); + ec1.reset(); + ec2.reset(); double EC1_distance = ec1.getDistance_mm (); double EC2_distance = ec2.getDistance_mm (); - while(fabs(EC1_distance) <= x && fabs(EC2_distance) <= x) { motor1 = ; //モータ1への出力 motor2 = ; //モータ2への出力