2024-04-16 18:17:30 +08:00
|
|
|
#ifndef _BY_MOTION_H__
|
|
|
|
|
#define _BY_MOTION_H__
|
|
|
|
|
|
|
|
|
|
#include "at32f413.h"
|
|
|
|
|
|
2024-04-26 16:13:07 +08:00
|
|
|
typedef struct by_motor_param {
|
|
|
|
|
float Kp;
|
|
|
|
|
float Ki;
|
|
|
|
|
float Kd;
|
|
|
|
|
float real_speed;
|
|
|
|
|
float target_speed;
|
|
|
|
|
float out_pwm;
|
|
|
|
|
} by_motor_param;
|
|
|
|
|
|
2024-05-10 10:54:06 +08:00
|
|
|
#define BY_MOTION_DEFAULT_KP_M1 (10.0f)
|
|
|
|
|
#define BY_MOTION_DEFAULT_KI_M1 (80.0f)
|
|
|
|
|
#define BY_MOTION_DEFAULT_KD_M1 (0.08f)
|
2024-04-26 16:13:07 +08:00
|
|
|
#define BY_MOTION_DEFAULT_KP_M2 (5.0f)
|
|
|
|
|
#define BY_MOTION_DEFAULT_KI_M2 (100.0f)
|
|
|
|
|
#define BY_MOTION_DEFAULT_KD_M2 (0.0f)
|
|
|
|
|
|
2024-04-19 17:16:24 +08:00
|
|
|
extern void by_motion_init(void);
|
2024-04-26 16:13:07 +08:00
|
|
|
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);
|
2024-04-19 17:16:24 +08:00
|
|
|
extern int16_t by_motion_get_speed_m1(void);
|
|
|
|
|
extern int16_t by_motion_get_speed_m2(void);
|
2024-04-26 16:13:07 +08:00
|
|
|
extern void by_motion_set_speed_m1(int16_t speed);
|
|
|
|
|
extern void by_motion_set_speed_m2(int16_t speed);
|
|
|
|
|
extern void by_motion_can_handle(uint16_t stdd_id, const uint8_t *data, uint8_t len);
|
2024-04-19 17:16:24 +08:00
|
|
|
|
2024-04-26 16:13:07 +08:00
|
|
|
extern by_motor_param param_m1;
|
|
|
|
|
extern by_motor_param param_m2;
|
2024-04-16 18:17:30 +08:00
|
|
|
|
|
|
|
|
#endif
|