![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
足回りプログラム
Dependencies: mbed SBDBT arrc_mbed
PIDcontrol.hpp@0:4f39632d7a42, 2022-01-17 (annotated)
- Committer:
- kazumayamanaka
- Date:
- Mon Jan 17 02:40:16 2022 +0000
- Revision:
- 0:4f39632d7a42
this program is to motor control;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kazumayamanaka | 0:4f39632d7a42 | 1 | #ifndef PID_CONTROL_H |
kazumayamanaka | 0:4f39632d7a42 | 2 | #define PID_CONTROL_H |
kazumayamanaka | 0:4f39632d7a42 | 3 | #include "mbed.h" |
kazumayamanaka | 0:4f39632d7a42 | 4 | #define co (108*3.1415926535897)/500 |
kazumayamanaka | 0:4f39632d7a42 | 5 | |
kazumayamanaka | 0:4f39632d7a42 | 6 | class PIDcontrol{ |
kazumayamanaka | 0:4f39632d7a42 | 7 | public: |
kazumayamanaka | 0:4f39632d7a42 | 8 | double spd;//速度 |
kazumayamanaka | 0:4f39632d7a42 | 9 | double error_n,error_b;//現在の誤差、過去の誤差 |
kazumayamanaka | 0:4f39632d7a42 | 10 | double P,I,D;//pid制御のそれぞれの値 |
kazumayamanaka | 0:4f39632d7a42 | 11 | double pwm,v1p_set,v1m_set;//モータに入れる値 |
kazumayamanaka | 0:4f39632d7a42 | 12 | double integral;//誤差の面積 |
kazumayamanaka | 0:4f39632d7a42 | 13 | double finish,pulse,pal;//パルス関係 |
kazumayamanaka | 0:4f39632d7a42 | 14 | double target;//目標値 |
kazumayamanaka | 0:4f39632d7a42 | 15 | PIDcontrol();//コンストラクタ |
kazumayamanaka | 0:4f39632d7a42 | 16 | void motor_control(double var_1,double var_2,PinName pin_a,PinName pin_b);//pwmをreturnする関数 |
kazumayamanaka | 0:4f39632d7a42 | 17 | double get_spd();//spdをreturnする関数 |
kazumayamanaka | 0:4f39632d7a42 | 18 | private: |
kazumayamanaka | 0:4f39632d7a42 | 19 | void speed();//spd計算 |
kazumayamanaka | 0:4f39632d7a42 | 20 | void control();//PID制御 |
kazumayamanaka | 0:4f39632d7a42 | 21 | double dt;//dt=0.05 |
kazumayamanaka | 0:4f39632d7a42 | 22 | double Kp,Ki,Kd;//PID制御 |
kazumayamanaka | 0:4f39632d7a42 | 23 | }; |
kazumayamanaka | 0:4f39632d7a42 | 24 | |
kazumayamanaka | 0:4f39632d7a42 | 25 | #endif |
kazumayamanaka | 0:4f39632d7a42 | 26 | |
kazumayamanaka | 0:4f39632d7a42 | 27 | |
kazumayamanaka | 0:4f39632d7a42 | 28 |