10/25/2015
Dependencies: PID mbed MaxSonar eeprom iSerial Fork_Boss_Communication_Robot
Diff: main.cpp
- Revision:
- 7:2daffd310c71
- Parent:
- 6:9ed82a812ece
- Child:
- 8:8fbc0c858875
--- a/main.cpp Tue Oct 27 05:45:49 2015 +0000 +++ b/main.cpp Tue Oct 27 06:27:56 2015 +0000 @@ -9,7 +9,7 @@ Timeout timecount; move m1; PID P1(0.005,0.005,0,0.1); -float setp=0; +double setp=0; //DigitalIn encoderB(D5); @@ -48,11 +48,11 @@ void getvelo() { valocity=pulse*((2*3.14*r)/128); - // pc.printf("%f \n",valocity); + pc.printf("valocity=%f \n",valocity); count=0; timerStart.reset(); } -float map(long x, long in_min, long in_max, long out_min, long out_max) +double map(double x, double in_min, double in_max, double out_min, double out_max) { return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; @@ -70,7 +70,7 @@ setp=map(1.0,0.0,1.094,0.0,1.0); // P1.setSetPoint(velocityreal);//setpont - P1.setSetPoint(1);//setpont + P1.setSetPoint(setp);//setpont P1.setBias(0); pc.printf("READY \n"); @@ -78,7 +78,7 @@ while(1) { - pc.printf("%l \n",setp); + // pc.printf("%f \n",setp); times=timerStart.read(); if(times==1)// m/s { @@ -91,12 +91,13 @@ P1.setProcessValue(valocity); // m1.movespeed(1,1.0); outPID=P1.compute(); - //m1.movespeed(1,velocityreal,outPID); - m1.movespeed(1,1,0); + pc.printf("outPID=%f \n",outPID); + m1.movespeed(1,setp,outPID); + // m1.movespeed(1,1,0); wait(0.1); - // pc.printf("%d \n",Encoderpos); + } } \ No newline at end of file