Basic example for PID library

Dependencies:   PID mbed

Files at this revision

API Documentation at this revision

Comitter:
jvfausto
Date:
Tue Aug 14 23:25:00 2018 +0000
Commit message:
PID basic example for pid library;

Changed in this revision

PID.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
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