![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Basic example for PID library
Revision 0:8454aaf72e4c, committed 2018-08-14
- Comitter:
- jvfausto
- Date:
- Tue Aug 14 23:25:00 2018 +0000
- Commit message:
- PID basic example for pid library;
Changed in this revision
diff -r 000000000000 -r 8454aaf72e4c PID.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/PID.lib Tue Aug 14 23:25:00 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/jvfausto/code/PID/#58f3a6c65ad5
diff -r 000000000000 -r 8454aaf72e4c main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Aug 14 23:25:00 2018 +0000 @@ -0,0 +1,35 @@ + #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); + } +} +
diff -r 000000000000 -r 8454aaf72e4c mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Aug 14 23:25:00 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/a7c7b631e539 \ No newline at end of file