2018 HongoMechaTech A

Dependencies:   mbed

MDPIDSpeed/MDPIDSpeed.h

Committer:
Komazawa_sun
Date:
2018-09-18
Revision:
0:e83b840a5f86

File content as of revision 0:e83b840a5f86:

/*
 * 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_ */