10/25/2015
Dependencies: PID mbed MaxSonar eeprom iSerial Fork_Boss_Communication_Robot
Diff: main.cpp
- Revision:
- 4:e6ab360e7de6
- Parent:
- 3:365615fa646e
- Child:
- 5:68b740d113e6
--- a/main.cpp Fri Oct 23 17:05:09 2015 +0000 +++ b/main.cpp Fri Oct 23 18:40:26 2015 +0000 @@ -3,12 +3,12 @@ #include "PID.h" DigitalOut led1(LED1); -InterruptIn encoderA(D6); -InterruptIn encoderB(D5); +InterruptIn encoderA(D10); +InterruptIn encoderB(D11); Timer timerStart; Timeout timecount; move m1; -PID P1(0.001,0,0,0.1); +PID P1(0.005,0.005,0,0.1); //DigitalIn encoderB(D5); @@ -46,31 +46,39 @@ void getRPM() { valocity=count; + pc.printf("%f \n",valocity); count=0; + timerStart.reset(); } int main() { - + pc.baud(115200); encoderA.rise(&EncoderA); timerStart.start(); P1.setMode(1); - P1.setProcessValue(0.7); - P1.setSetPoint(0.8); + + P1.setSetPoint(20); P1.setBias(0); pc.printf("READY \n"); + led1=1; while(1) { - led1=1; - timecount.attach(&getRPM, 60); + if(timerStart.read()==60) + { + getRPM(); + } + //timecount.attach(&getRPM, 60); + P1.setProcessValue(valocity); // m1.movespeed(1,1.0); - // outPID=P1.compute(); - // pc.printf("%f \n",valocity); + outPID=P1.compute(); + m1.movespeed(1,outPID); + wait(0.1); // pc.printf("%d \n",Encoderpos);