PID motor controll for the biorobotics project.

Dependencies:   FastPWM QEI

Dependents:   PID_example Motor_calibration Demo_mode Demo_mode ... more

Revision:
4:5353c5d0d2ed
Parent:
2:b30a467e90d3
Child:
5:5537072b0e2e
diff -r f1067b5bb5af -r 5353c5d0d2ed motor.h
--- a/motor.h	Mon Oct 29 15:27:56 2018 +0000
+++ b/motor.h	Wed Oct 31 06:13:15 2018 +0000
@@ -7,8 +7,6 @@
 
 #include "pid.h"
 
-const float PI = 3.14159265359;
-
 // Amount of motor encoder pulses per rotation. When using X4 encoding.
 const int PULSES_PER_ROTATION = 6533;
 
@@ -19,6 +17,8 @@
     /// Rotates a motor to a given angle using PID control.
     /// Sets the pwm frequency to 60 HZ.
 private:
+    const float PI = 3.14159265359;
+
     Ticker motor_ticker;
 
     FastPWM pwm_out;
@@ -44,6 +44,9 @@
     // Starts the motor controller with the specified update period.
     void start(float period);
     
+    // Stops the motor immediately.
+    void stop();
+    
     // Returns the current angle of the motor.
     double get_current_angle();