Assignment 1 compiled

Dependencies:   FastPWM MODSERIAL QEI mbed

Fork of gr14_assignment_PES by Marjolein Scheffers

Files at this revision

API Documentation at this revision

Comitter:
s1737619
Date:
Mon Oct 15 12:19:49 2018 +0000
Parent:
1:a602cde74178
Commit message:
Assigment 1, kan compilen

Changed in this revision

MODSERIAL.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
--- a/MODSERIAL.lib	Mon Oct 15 10:35:37 2018 +0000
+++ b/MODSERIAL.lib	Mon Oct 15 12:19:49 2018 +0000
@@ -1,1 +1,1 @@
-http://os.mbed.com/users/AjK/code/MODSERIAL/#ae0408ebdd68
+http://os.mbed.com/users/Sissors/code/MODSERIAL/#da0788f0bd77
--- a/main.cpp	Mon Oct 15 10:35:37 2018 +0000
+++ b/main.cpp	Mon Oct 15 12:19:49 2018 +0000
@@ -18,7 +18,7 @@
 
 Ticker MotorTicker;
 
-void read_pots(double &pot1_value, double &pot2_value) // read pot 1 en pot 2
+void read_pots(volatile double &pot1_value, volatile double &pot2_value) // read pot 1 en pot 2
 {
     pot1_value = pot1.read();
     pot2_value = pot2.read();
@@ -34,7 +34,7 @@
     return encoder1.getPulses()/32.0/131.25*2.0*3.1416;
 }
 
-double PID_controller (meas_pos, ref_pos, gain)
+double PID_controller (double meas_pos, double ref_pos, double gain)
 {
     double error = ref_pos - meas_pos;
     
@@ -48,7 +48,7 @@
             
         else if (u < -1.0)
             {
-                u = -1.0);
+                u = -1.0;
             }
     return u;
 }
@@ -72,7 +72,9 @@
 
 void Motor_control()
 {    
-    volatile double pot_value, volatile double gain;
+    volatile double pot_value;
+    
+    volatile double gain;
     
     read_pots(pot_value, gain);
     
@@ -88,7 +90,7 @@
     
     if (count == 400) // print 1x per seconde waardes.
     {
-        pc.printf("u = %d, measure position y = %d, reference position yref = %d, gain = %d", u, y, yref, gain);
+        pc.printf("u = %lf, measure position y = %lf, reference position yref = %lf, gain = %lf \n", u, y, yref, gain);
         count = 0;   
     }
 }