| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- #ifndef EBRAKE_CTRL_H__
- #define EBRAKE_CTRL_H__
- #include "os/os_types.h"
- #include "foc/core/ramp_ctrl.h"
- typedef struct {
- float start;
- float target;
- float interpolation;
- float step_val;
- }e_Ramp;
- typedef struct {
- u16 ebrk_time; //能量回收,时间越短,刹车性能或者回收越好
- u16 accl_time; //加速时间(ms),时间越短,加速性能越好
- u16 dec_time; //降速时间
- bool hw_brake;
- bool is_ebrake;
- u32 brake_ts;//检测到刹车开始时间
- e_Ramp current;
- e_Ramp torque;
- e_Ramp speed;
- u16 ebrk_shadow;
- u16 accl_shadow;
- u16 dec_shadow;
- float ebrake_current;
- float current_shadow;
- float torque_shadow;
- float speed_shadow;
- bool is_ebrake_shadow;
- }e_Ctrl;
- static void eRamp_init(e_Ramp *r) {
- r->start = 0;
- r->target = 0;
- r->interpolation = 0;
- r->step_val = 0;
- }
- static void eRamp_set_target(e_Ramp *r, float target) {
- r->target = target;
- }
- static void eRamp_set_step(e_Ramp *r, float step) {
- r->step_val = step;
- }
- static void eRamp_running(e_Ramp *r) {
- float target = r->interpolation + r->step_val;
- if (r->step_val < 0) {
- if (target < r->target) {
- target = r->target;
- }
- }else {
- if (target > r->target) {
- target = r->target;
- }
- }
- r->interpolation = target;
- }
- static float eRamp_get_intepolation(e_Ramp *r) {
- return r->interpolation;
- }
- static float eRamp_get_target(e_Ramp *r) {
- return r->target;
- }
- void eCtrl_init(u16 accl_time, u16 dec_time);
- void eCtrl_set_ebrk_time(u16 ebrk_time);
- void eCtrl_brake_signal(bool hw_brake);
- bool eCtrl_is_eBrk_enabled(void);
- void eCtrl_set_TgtCurrent(float c);
- void eCtrl_set_TgtTorque(float t);
- void eCtrl_set_TgtSpeed(float s);
- bool eCtrl_enable_eBrake(bool enable);
- float eCtrl_get_RefSpeed(void);
- float eCtrl_get_RefCurrent(void);
- float eCtrl_get_RefTorque(void);
- float eCtrl_get_FinalSpeed(void);
- float eCtrl_get_FinalCurrent(void);
- float eCtrl_get_FinalTorque(void);
- void eCtrl_Running(void);
- #endif /* EBRAKE_CTRL_H__ */
|