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

Committer:
stivending
Date:
Thu May 27 05:43:48 2021 +0000
Revision:
13:675456f1f401
Parent:
10:fe56f6800a72
Child:
14:c9611cf036ad
PID supported, read manual first

Who changed what in which revision?

UserRevisionLine numberNew contents of line
stivending 5:c040faf21e07 1 #include "mbed.h"
stivending 5:c040faf21e07 2 #include "QEI.h"
stivending 13:675456f1f401 3 #include "pid.h"
stivending 5:c040faf21e07 4
stivending 5:c040faf21e07 5 #ifndef DC_MOTOR_CONTROLLER_H
stivending 5:c040faf21e07 6 #define DC_MOTOR_CONTROLLER_H
stivending 5:c040faf21e07 7
stivending 13:675456f1f401 8 class DC_Motor_Controller
stivending 13:675456f1f401 9 {
stivending 5:c040faf21e07 10 public:
stivending 10:fe56f6800a72 11 DC_Motor_Controller(PinName out_M1, PinName out_M2, PinName in_A, PinName in_B, int PPR);
stivending 10:fe56f6800a72 12 void goto_angle(int angle, float speed = 1);
stivending 9:49b59b308767 13 void reset();
stivending 10:fe56f6800a72 14 void move_angle(int angle, float speed = 1);
stivending 10:fe56f6800a72 15 void set_out(float a, float b);
stivending 9:49b59b308767 16 int get_pulse();
stivending 13:675456f1f401 17
stivending 13:675456f1f401 18 protected:
stivending 13:675456f1f401 19 PwmOut out1, out2;
stivending 13:675456f1f401 20 QEI dc_motor;
stivending 13:675456f1f401 21 virtual void goto_pulse(int tar_pulse, float speed = 1) = 0;
stivending 5:c040faf21e07 22 };
stivending 13:675456f1f401 23
stivending 13:675456f1f401 24 class DC_Motor_On_Off: public DC_Motor_Controller
stivending 13:675456f1f401 25 {
stivending 13:675456f1f401 26 public:
stivending 13:675456f1f401 27 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){};
stivending 13:675456f1f401 28 protected:
stivending 13:675456f1f401 29 void goto_pulse(int tar_pulse, float speed = 1);
stivending 13:675456f1f401 30 };
stivending 13:675456f1f401 31
stivending 13:675456f1f401 32 class DC_Motor_PID: public DC_Motor_Controller
stivending 13:675456f1f401 33 {
stivending 13:675456f1f401 34 private:
stivending 13:675456f1f401 35 PID* pid;
stivending 13:675456f1f401 36 protected:
stivending 13:675456f1f401 37 void goto_pulse(int tar_pulse, float placeholder = 0);
stivending 13:675456f1f401 38 public:
stivending 13:675456f1f401 39 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){};
stivending 13:675456f1f401 40 void set_pid(double Kp, double Ki, double Kd);
stivending 13:675456f1f401 41 };
stivending 13:675456f1f401 42
stivending 13:675456f1f401 43
stivending 5:c040faf21e07 44 #endif