
motor aansturing moet lineair zijn is het niet
Dependencies: MODSERIAL Encoder mbed HIDScope
Diff: main.cpp
- Revision:
- 6:3031e8abb052
- Parent:
- 5:46dae55f0ab0
- Child:
- 7:eb239942830d
--- a/main.cpp Mon Sep 28 10:24:31 2015 +0000 +++ b/main.cpp Mon Sep 28 11:56:06 2015 +0000 @@ -36,44 +36,44 @@ void move_mot1(float left) { - if(left < 0.4) + if(left < 0.400) { float calc1 = left - 1; float calc2 = abs(calc1); - float leftin = (calc2-0.6)*2.5 ; - motor1_aan.write(leftin); + float leftin1 = (calc2-0.6)*2.5 ; + motor1_aan.write(leftin1); motor1_rich.write(0); } - else if(left > 0.4 && left < 0.6) + else if(left > 0.4000 && left < 0.6000) { motor1_aan.write(0); } - else if(left > 0.6) + else if(left > 0.6000) { - float leftin = (left-0.6)*2.5; - motor1_aan.write(leftin); + float leftin2 = (left-0.6)*2.5; + motor1_aan.write(leftin2); motor1_rich.write(1); } } void move_mot2(float right) { - if(right < 0.4) + if(right < 0.4000) { float calc3 = right - 1; float calc4 = abs(calc3); - float rightin = (calc4-0.6)*2.5 ; - motor2_aan.write(rightin); + float rightin1 = (calc4-0.6)*2.5 ; + motor2_aan.write(rightin1); motor2_rich.write(0); } - else if(right > 0.4 && right < 0.6) + else if(right > 0.4000 && right < 0.6000) { motor2_aan.write(0); } - else if(right > 0.6) + else if(right > 0.6000) { - float rightin = (right-0.6)*2.5; - motor2_aan.write(rightin); + float rightin2 = (right-0.6)*2.5; + motor2_aan.write(rightin2); motor2_rich.write(1); } } @@ -95,13 +95,14 @@ { float left = potleft.read(); float right = potright.read(); + // pc.printf("%f \n",left); move_mot1(left); move_mot2(right); - if(button.read() == button_on) - { - motor1_enc.reset(); - motor2_enc.reset(); - } + //if(button.read() == button_on) + //{ + // motor1_enc.reset(); + // motor2_enc.reset(); + //} } }