Jesus Fausto
/
Basic_PID
Basic example for PID library
main.cpp
- Committer:
- jvfausto
- Date:
- 2018-08-14
- Revision:
- 0:8454aaf72e4c
File content as of revision 0:8454aaf72e4c:
#include "mbed.h" #include "PID.h" Serial pc(USBTX,USBRX); //Define Variables we'll be connecting to double Input; double Output; double Setpoint; PwmOut pinOut(D0); DigitalIn a(D1); //Specify the links and initial tuning parameters double Kp=1, Ki=1, Kd=1; PID myPID(&Input, &Output, &Setpoint, Kp, Ki, Kd, P_ON_M, DIRECT); int main() { //initialize the variables we're linked to pinOut.period(.001f); Input = a.read(); Setpoint = 90; myPID.SetMode(AUTOMATIC); while(1) { Input = a.read(); myPID.Compute(); pinOut = Output; wait(.1); } }