taiyou komazawa
/
Nucleo_fliping_arm
2018 HongoMechaTech A
Diff: MDPIDSpeed/MDPIDSpeed.h
- Revision:
- 0:e83b840a5f86
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MDPIDSpeed/MDPIDSpeed.h Tue Sep 18 03:11:01 2018 +0000 @@ -0,0 +1,40 @@ +/* + * MDPIDSpeed.h + * + * Created on: 2018/08/31 + * Author: komazawataiyou + */ + +#ifndef NUCLEO_FLIPING_ARM_LIB_MD_PID_SPEED_MDPIDSPEED_H_ +#define NUCLEO_FLIPING_ARM_LIB_MD_PID_SPEED_MDPIDSPEED_H_ + +#include "mbed.h" +#include "MD.h" +#include "QEI.h" +#include "Timer_PID.h" + +class MD_PID_Speed: public MD, public Timer_PID{ +public: + MD_PID_Speed(MD *md, QEI *encorder, double kp, double ki, double kd); + virtual ~MD_PID_Speed(); + + virtual void drive(double rpm); + virtual void brake(double rpm); + virtual void free(); + + double get_duty(); + double get_current_rpm(); + + bool target_complete(float allowable_error); + + void reset(); +private: + MD *md; + QEI *encorder; + + double target_rpm_; + double rpm_log_[4]; + double duty_; +}; + +#endif /* NUCLEO_FLIPING_ARM_LIB_MD_PID_SPEED_MDPIDSPEED_H_ */