Library version for DC_Stepper_Controller_Lib with PWM speed control

Dependencies:   mbed QEI PID

Dependents:   DR-ArmServoTest Auto_DC_pick_class MBed_TR1 ros_button_2021

Revision:
13:675456f1f401
Parent:
10:fe56f6800a72
Child:
14:c9611cf036ad
diff -r 3949fd23be49 -r 675456f1f401 DC_Motor_Controller.h
--- a/DC_Motor_Controller.h	Wed May 26 07:43:28 2021 +0000
+++ b/DC_Motor_Controller.h	Thu May 27 05:43:48 2021 +0000
@@ -1,16 +1,12 @@
 #include "mbed.h"
 #include "QEI.h"
-#include <cmath>
+#include "pid.h"
 
 #ifndef DC_MOTOR_CONTROLLER_H
 #define DC_MOTOR_CONTROLLER_H
 
-class DC_Motor_Controller {
-
-    private:
-        PwmOut out1, out2; 
-        QEI dc_motor;
-        void goto_pulse(int tar_pulse, float speed = 1);
+class DC_Motor_Controller
+{
     public:
         DC_Motor_Controller(PinName out_M1, PinName out_M2, PinName in_A, PinName in_B, int PPR);        
         void goto_angle(int angle, float speed = 1);
@@ -18,5 +14,31 @@
         void move_angle(int angle, float speed = 1);
         void set_out(float a, float b);
         int get_pulse();
+    
+    protected:
+        PwmOut out1, out2; 
+        QEI dc_motor;
+        virtual void goto_pulse(int tar_pulse, float speed = 1) = 0;
 };
+
+class DC_Motor_On_Off: public DC_Motor_Controller 
+{
+    public:
+        DC_Motor_On_Off(PinName out_M1, PinName out_M2, PinName in_A, PinName in_B, int PPR):DC_Motor_Controller(out_M1, out_M2, in_A, in_B, PPR){};   
+    protected:
+        void goto_pulse(int tar_pulse, float speed = 1);
+};
+    
+class DC_Motor_PID: public DC_Motor_Controller 
+{
+    private:
+        PID* pid;
+    protected:
+        void goto_pulse(int tar_pulse, float placeholder = 0);
+    public:
+        DC_Motor_PID(PinName out_M1, PinName out_M2, PinName in_A, PinName in_B, int PPR):DC_Motor_Controller(out_M1, out_M2, in_A, in_B, PPR){};  
+        void set_pid(double Kp, double Ki, double Kd);
+};
+
+
 #endif
\ No newline at end of file