3輪オムニホイール制御 GNCT, B team
Dependencies: nucleo_rotary_encoder
speed_control/speed_control.hpp@0:3bd8aecadafc, 2017-09-28 (annotated)
- Committer:
- sawai
- Date:
- Thu Sep 28 10:50:37 2017 +0000
- Revision:
- 0:3bd8aecadafc
?????????xy?????; ???????????????
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sawai | 0:3bd8aecadafc | 1 | #ifndef __SPEED_CONTROL__ |
sawai | 0:3bd8aecadafc | 2 | #define __SPEED_CONTROL__ |
sawai | 0:3bd8aecadafc | 3 | |
sawai | 0:3bd8aecadafc | 4 | #include "mbed.h" |
sawai | 0:3bd8aecadafc | 5 | #include "rotary_encoder_ab_phase.hpp" |
sawai | 0:3bd8aecadafc | 6 | |
sawai | 0:3bd8aecadafc | 7 | class speed_control |
sawai | 0:3bd8aecadafc | 8 | { |
sawai | 0:3bd8aecadafc | 9 | private: |
sawai | 0:3bd8aecadafc | 10 | rotary_encoder_ab_phase *e; |
sawai | 0:3bd8aecadafc | 11 | Timer t; |
sawai | 0:3bd8aecadafc | 12 | float kp, ki, kd; |
sawai | 0:3bd8aecadafc | 13 | float f1, f2, diff[2], m, dm, j; |
sawai | 0:3bd8aecadafc | 14 | float pulse_per_revol, cy_ms; |
sawai | 0:3bd8aecadafc | 15 | float target_value, sensor_value; |
sawai | 0:3bd8aecadafc | 16 | unsigned long time_counter; |
sawai | 0:3bd8aecadafc | 17 | int32_t e_value[10], pre_counts; |
sawai | 0:3bd8aecadafc | 18 | char duty; |
sawai | 0:3bd8aecadafc | 19 | bool rev; |
sawai | 0:3bd8aecadafc | 20 | |
sawai | 0:3bd8aecadafc | 21 | public: |
sawai | 0:3bd8aecadafc | 22 | speed_control(TIM_TypeDef *timer_type, float _pulse_per_revol, float _cy_ms); |
sawai | 0:3bd8aecadafc | 23 | void change_direction(bool _rev); |
sawai | 0:3bd8aecadafc | 24 | void set_speed(float _target_value); |
sawai | 0:3bd8aecadafc | 25 | void set_pid(float _kp, float _ki, float _kd); |
sawai | 0:3bd8aecadafc | 26 | bool check_get_speed(); |
sawai | 0:3bd8aecadafc | 27 | char get_duty(); |
sawai | 0:3bd8aecadafc | 28 | float get_speed(); |
sawai | 0:3bd8aecadafc | 29 | }; |
sawai | 0:3bd8aecadafc | 30 | |
sawai | 0:3bd8aecadafc | 31 | #endif |