35 lines
874 B
C
35 lines
874 B
C
|
|
#ifndef _BY_MOTION_H__
|
||
|
|
#define _BY_MOTION_H__
|
||
|
|
|
||
|
|
#include "at32f413.h"
|
||
|
|
|
||
|
|
typedef struct by_motor_param {
|
||
|
|
float Kp;
|
||
|
|
float Ki;
|
||
|
|
float Kd;
|
||
|
|
float real_speed;
|
||
|
|
float target_speed;
|
||
|
|
float out_pwm;
|
||
|
|
} by_motor_param;
|
||
|
|
|
||
|
|
#define BY_MOTION_DEFAULT_KP_M1 (13.0f)
|
||
|
|
#define BY_MOTION_DEFAULT_KI_M1 (5.0f)
|
||
|
|
#define BY_MOTION_DEFAULT_KD_M1 (0.1f)
|
||
|
|
#define BY_MOTION_DEFAULT_KP_M2 (1.0f)
|
||
|
|
#define BY_MOTION_DEFAULT_KI_M2 (0.0f)
|
||
|
|
#define BY_MOTION_DEFAULT_KD_M2 (0.0f)
|
||
|
|
|
||
|
|
extern void by_motion_init(void);
|
||
|
|
extern void by_motion_run(void);
|
||
|
|
extern void by_motion_set_pwm_m1(int32_t pwm_duty);
|
||
|
|
extern void by_motion_set_pwm_m2(int32_t pwm_duty);
|
||
|
|
extern int16_t by_motion_get_speed_m1(void);
|
||
|
|
extern int16_t by_motion_get_speed_m2(void);
|
||
|
|
extern void by_motion_set_speed_m1(int16_t speed);
|
||
|
|
extern void by_motion_set_speed_m2(int16_t speed);
|
||
|
|
|
||
|
|
extern int16_t speed_m1;
|
||
|
|
extern int16_t speed_m2;
|
||
|
|
|
||
|
|
#endif
|