![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
my new gear...
actuator/IMC_motorDrive.hpp@22:394337a4205a, 22 months ago (annotated)
- Committer:
- yootee
- Date:
- Sat Oct 15 07:52:25 2022 +0000
- Revision:
- 22:394337a4205a
- Parent:
- 8:1ca5a2052b0c
upgrade
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 | 2:e7b09385d197 | 6 | #ifdef constrain |
yootee | 0:1456b6f84c75 | 7 | inline double constrain(double x,double minimum,double maximum){ |
yootee | 0:1456b6f84c75 | 8 | return (x < minimum ? minimum : x > maximum ? maximum : x); |
yootee | 0:1456b6f84c75 | 9 | } |
yootee | 2:e7b09385d197 | 10 | #endif |
yootee | 0:1456b6f84c75 | 11 | |
yootee | 0:1456b6f84c75 | 12 | class IMC_motor |
yootee | 0:1456b6f84c75 | 13 | { |
yootee | 0:1456b6f84c75 | 14 | public: |
yootee | 8:1ca5a2052b0c | 15 | IMC_motor(Port encoder,int resolution,double wheel_ensyu,Port motor_,double K_,double Tau_,double dt_,bool CW_flag); |
yootee | 0:1456b6f84c75 | 16 | void IMCdrive(double target); |
yootee | 0:1456b6f84c75 | 17 | void IMCreset(); |
yootee | 0:1456b6f84c75 | 18 | void drive(int pwm); |
yootee | 0:1456b6f84c75 | 19 | RotaryInc motor_enc; |
yootee | 0:1456b6f84c75 | 20 | private: |
yootee | 0:1456b6f84c75 | 21 | double imc_out(double target); |
yootee | 0:1456b6f84c75 | 22 | double imc_controler(double y); |
yootee | 0:1456b6f84c75 | 23 | double process_model(double x,double mv); |
yootee | 0:1456b6f84c75 | 24 | double process_model_val; |
yootee | 0:1456b6f84c75 | 25 | double out_pwm; |
yootee | 0:1456b6f84c75 | 26 | double K; |
yootee | 0:1456b6f84c75 | 27 | double Tau; |
yootee | 0:1456b6f84c75 | 28 | double dt; |
yootee | 8:1ca5a2052b0c | 29 | bool cw_flag; |
yootee | 0:1456b6f84c75 | 30 | Port motor; |
yootee | 0:1456b6f84c75 | 31 | }; |