![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Signa-bot code for project BioRobotics, at University of Twente.
Dependencies: mbed QEI MODSERIAL FastPWM ttmath Math
Diff: Motor_tryout.cpp
- Revision:
- 26:432d3519ba86
- Parent:
- 25:eb3204e45d33
- Child:
- 27:3eb181cbe183
diff -r eb3204e45d33 -r 432d3519ba86 Motor_tryout.cpp --- a/Motor_tryout.cpp Tue Oct 29 08:48:48 2019 +0000 +++ b/Motor_tryout.cpp Tue Oct 29 10:05:50 2019 +0000 @@ -202,25 +202,20 @@ if (steps1 <= 0) { if(counts1<=steps1) { - pulses1.detach(); pc.printf("\n 1 is false"); - motor1_pwm.write(0); check1=false; } if (counts2<=steps2) { - pulses2.detach(); pc.printf("\n 2 is false"); motor2_pwm.write(0); check2=false; } if (counts3>=abs(steps3)) { - pulses3.detach(); pc.printf("\n 3 is false"); motor3_pwm.write(0); check3=false; - //pc.printf("\n\rsteps %f, counts %f", steps3, counts3); - pc.printf("\n\rsteps3 %f", steps3); + pc.printf("\n\rsteps3 %f", steps3); pc.printf("\n\rcounts3 %i", counts3); } } @@ -243,7 +238,7 @@ } } - //Encoder1.reset(); + wait(1.0); pc.printf("\n\rcounts1 %i, counts2 %i, counts3 %i", counts1, counts2, counts3); } @@ -252,15 +247,20 @@ pulses1.attach(&getpulses1, 1.0/1000); pulses2.attach(&getpulses2, 1.0/1000); pulses3.attach(&getpulses3, 1.0/1000); - Encoder1.reset(); - Encoder2.reset(); - Encoder3.reset(); - + pc.baud(115200); char cc = pc.getc(); while(true) { + + Encoder1.reset(); + Encoder2.reset(); + Encoder3.reset(); + counts1 = Encoder1.getPulses(); + counts2 = Encoder2.getPulses(); + counts3 = Encoder3.getPulses(); + delta_calcinverse(x0,y0,z0);