![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
10/25/2015
Dependencies: PID mbed MaxSonar eeprom iSerial Fork_Boss_Communication_Robot
Diff: main.cpp
- Revision:
- 8:8fbc0c858875
- Parent:
- 7:2daffd310c71
- Child:
- 9:86701fec3f79
--- a/main.cpp Tue Oct 27 06:27:56 2015 +0000 +++ b/main.cpp Mon Dec 14 19:35:08 2015 +0000 @@ -9,9 +9,9 @@ Timeout timecount; move m1; PID P1(0.005,0.005,0,0.1); -double setp=0; +double setp1=0,setp2=0; //DigitalIn encoderB(D5); - +int times; Serial pc(SERIAL_TX,SERIAL_RX); int Encoderpos = 0; @@ -57,6 +57,40 @@ return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; } +void PID_m1() +{ + setp1=map(1.0,0.0,1.094,0.0,1.0); + P1.setSetPoint(setp1); + times=timerStart.read(); + if(times==1)// m/s + { + getvelo(); + //pc.printf("TIME \n"); + times=0; + pulse=0; + } + P1.setProcessValue(valocity); + outPID=P1.compute(); + //pc.printf("outPID=%f \n",outPID); + m1.movespeed_1(1,setp1,outPID); +} +void PID_m2() +{ + setp2=map(1.0,0.0,1.094,0.0,1.0); + P1.setSetPoint(setp2); + times=timerStart.read(); + if(times==1)// m/s + { + getvelo(); + //pc.printf("TIME \n"); + times=0; + pulse=0; + } + P1.setProcessValue(valocity); + outPID=P1.compute(); + //pc.printf("outPID=%f \n",outPID); + m1.movespeed_2(1,setp2,outPID); +} int main() { @@ -67,10 +101,10 @@ timerStart.start(); P1.setMode(1); //setp=map(1,0,1.0916,0,1); - setp=map(1.0,0.0,1.094,0.0,1.0); + // setp=map(1.0,0.0,1.094,0.0,1.0); // P1.setSetPoint(velocityreal);//setpont - P1.setSetPoint(setp);//setpont + // P1.setSetPoint(setp);//setpont P1.setBias(0); pc.printf("READY \n"); @@ -78,6 +112,9 @@ while(1) { + + + /* // pc.printf("%f \n",setp); times=timerStart.read(); if(times==1)// m/s @@ -96,7 +133,7 @@ // m1.movespeed(1,1,0); wait(0.1); - + */ }