yotaro morizumi / Mbed 2 deprecated zoomy_customLibrary

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers IMC_motorDrive.hpp Source File

IMC_motorDrive.hpp

00001 #pragma once
00002 #include<mbed.h>
00003 #include <portSet.hpp>
00004 #include <rotary_inc_sp.hpp>
00005 
00006 #ifdef constrain
00007 inline double constrain(double x,double minimum,double maximum){
00008     return (x < minimum ? minimum : x > maximum ? maximum : x);
00009 }
00010 #endif
00011 
00012 class IMC_motor
00013 {
00014 public:
00015     IMC_motor(Port encoder,int resolution,double wheel_ensyu,Port motor_,double K_,double Tau_,double dt_,bool CW_flag);
00016     void IMCdrive(double target);
00017     void IMCreset();
00018     void drive(int pwm);
00019     RotaryInc motor_enc;
00020 private: 
00021     double imc_out(double target);
00022     double imc_controler(double y);
00023     double process_model(double x,double mv);
00024     double process_model_val;
00025     double out_pwm;
00026     double K;
00027     double Tau;
00028     double dt;
00029     bool cw_flag;
00030     Port motor;
00031 };