37 lines
1017 B
C
37 lines
1017 B
C
#ifndef _BY_MOTION_H__
|
|
#define _BY_MOTION_H__
|
|
|
|
#include "at32f425.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 (5.0f)
|
|
#define BY_MOTION_DEFAULT_KI_M1 (600.0f)
|
|
#define BY_MOTION_DEFAULT_KD_M1 (0.0f)
|
|
#define BY_MOTION_DEFAULT_KP_M2 (5.0f)
|
|
#define BY_MOTION_DEFAULT_KI_M2 (100.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 void by_motion_can_handle(uint16_t stdd_id, const uint8_t *data, uint8_t len);
|
|
extern void by_motion_tmr_handle(void);
|
|
|
|
extern by_motor_param param_m1;
|
|
extern by_motor_param param_m2;
|
|
|
|
#endif
|