![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
10/25/2015
Dependencies: PID mbed MaxSonar eeprom iSerial Fork_Boss_Communication_Robot
main.cpp
- Committer:
- palmdotax
- Date:
- 2015-10-18
- Revision:
- 1:7c3dbf140bfc
- Parent:
- 0:f02641e3fb91
- Child:
- 2:933d3edf38da
File content as of revision 1:7c3dbf140bfc:
#include"mbed.h" #include "move.h" #include "PID.h" InterruptIn encoderA(D6); InterruptIn encoderB(D5); move m1; PID P1(0.001,0.005,0,0.1); //DigitalIn encoderB(D5); Serial pc(SERIAL_TX,SERIAL_RX); int Encoderpos = 0; float valocity =0; float outPID =0; void EncoderA() { if(encoderB==0) { Encoderpos = Encoderpos + 1;} else { Encoderpos = Encoderpos -1;} //Encoderpos = Encoderpos + 1; valocity+=1; // pc.printf("%d \n",Encoderpos); } void EncoderB() { if(encoderA==1) { Encoderpos = Encoderpos + 1;} else { Encoderpos = Encoderpos -1;} pc.printf("%d",Encoderpos); } int main() { pc.baud(115200); encoderA.rise(&EncoderA); //pc.printf("Encode\n"); P1.setMode(0); P1.setProcessValue(0.7); P1.setSetPoint(0.8); // P1.setBias(0); while(1) { P1.setProcessValue(0.7); P1.setSetPoint(0.8); outPID=P1.compute(); // pc.printf("palm \n"); pc.printf("%f \n",outPID); wait(1); // pc.printf("%d \n",Encoderpos); } }