Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
IMC_motorDrive.hpp
- Committer:
- yootee
- Date:
- 2022-02-25
- Revision:
- 0:1456b6f84c75
File content as of revision 0:1456b6f84c75:
#pragma once
#include<mbed.h>
#include <portSet.hpp>
#include <rotary_inc_sp.hpp>
inline double constrain(double x,double minimum,double maximum){
return (x < minimum ? minimum : x > maximum ? maximum : x);
}
class IMC_motor
{
public:
IMC_motor(Port encoder,int resolution,double wheel_ensyu,Port motor_,double K_,double Tau_,double dt_);
void IMCdrive(double target);
void IMCreset();
void drive(int pwm);
RotaryInc motor_enc;
private:
double imc_out(double target);
double imc_controler(double y);
double process_model(double x,double mv);
double process_model_val;
double out_pwm;
double K;
double Tau;
double dt;
Port motor;
};