![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
my new gear...
IMC_motorDrive.hpp@0:1456b6f84c75, 2022-02-25 (annotated)
- Committer:
- yootee
- Date:
- Fri Feb 25 05:20:11 2022 +0000
- Revision:
- 0:1456b6f84c75
my_custom
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
yootee | 0:1456b6f84c75 | 1 | #pragma once |
yootee | 0:1456b6f84c75 | 2 | #include<mbed.h> |
yootee | 0:1456b6f84c75 | 3 | #include <portSet.hpp> |
yootee | 0:1456b6f84c75 | 4 | #include <rotary_inc_sp.hpp> |
yootee | 0:1456b6f84c75 | 5 | |
yootee | 0:1456b6f84c75 | 6 | inline double constrain(double x,double minimum,double maximum){ |
yootee | 0:1456b6f84c75 | 7 | return (x < minimum ? minimum : x > maximum ? maximum : x); |
yootee | 0:1456b6f84c75 | 8 | } |
yootee | 0:1456b6f84c75 | 9 | |
yootee | 0:1456b6f84c75 | 10 | class IMC_motor |
yootee | 0:1456b6f84c75 | 11 | { |
yootee | 0:1456b6f84c75 | 12 | public: |
yootee | 0:1456b6f84c75 | 13 | IMC_motor(Port encoder,int resolution,double wheel_ensyu,Port motor_,double K_,double Tau_,double dt_); |
yootee | 0:1456b6f84c75 | 14 | void IMCdrive(double target); |
yootee | 0:1456b6f84c75 | 15 | void IMCreset(); |
yootee | 0:1456b6f84c75 | 16 | void drive(int pwm); |
yootee | 0:1456b6f84c75 | 17 | RotaryInc motor_enc; |
yootee | 0:1456b6f84c75 | 18 | private: |
yootee | 0:1456b6f84c75 | 19 | double imc_out(double target); |
yootee | 0:1456b6f84c75 | 20 | double imc_controler(double y); |
yootee | 0:1456b6f84c75 | 21 | double process_model(double x,double mv); |
yootee | 0:1456b6f84c75 | 22 | double process_model_val; |
yootee | 0:1456b6f84c75 | 23 | double out_pwm; |
yootee | 0:1456b6f84c75 | 24 | double K; |
yootee | 0:1456b6f84c75 | 25 | double Tau; |
yootee | 0:1456b6f84c75 | 26 | double dt; |
yootee | 0:1456b6f84c75 | 27 | Port motor; |
yootee | 0:1456b6f84c75 | 28 | }; |