|
|
@@ -92,15 +92,6 @@ typedef struct {
|
|
|
float dc_vol_max;
|
|
|
}user_limit;
|
|
|
|
|
|
-typedef struct {
|
|
|
- float target;
|
|
|
- float interpolation;
|
|
|
- float step;
|
|
|
- float time;
|
|
|
- float time_dec;
|
|
|
- bool b_force_step;
|
|
|
-}lineramp_t;
|
|
|
-
|
|
|
typedef struct {
|
|
|
lineramp_t vel;
|
|
|
lineramp_t torque;
|
|
|
@@ -203,19 +194,6 @@ void mot_contrl_calc_current(mot_contrl_t *ctrl);
|
|
|
void mot_contrl_get_pid(mot_contrl_t *ctrl, u8 id, float *kp, float *ki, float *kd);
|
|
|
void mot_contrl_set_pid(mot_contrl_t *ctrl, u8 id, float kp, float ki, float kd);
|
|
|
|
|
|
-static __INLINE void line_ramp_set_target(lineramp_t *line, float target) {
|
|
|
- if (line->target != target) {
|
|
|
- line->target = target;
|
|
|
- if (!line->b_force_step) {
|
|
|
- float delta = (line->target - line->interpolation);
|
|
|
- if (delta >= 0) {
|
|
|
- line->step = delta / line->time;
|
|
|
- }else {
|
|
|
- line->step = -delta / line->time_dec;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
|
|
|
static __INLINE bool mot_contrl_start(mot_contrl_t *ctrl, u8 mode) {
|
|
|
mot_contrl_enable(ctrl, true);
|
|
|
@@ -301,64 +279,5 @@ static __INLINE u32 mot_contrl_get_torque_acc_time(mot_contrl_t *ctrl) {
|
|
|
return ctrl->input_torque.time;
|
|
|
}
|
|
|
|
|
|
-static __INLINE void line_ramp_init(lineramp_t *line, float time) {
|
|
|
- line->target = 0;
|
|
|
- line->interpolation = 0;
|
|
|
- line->step = 0;
|
|
|
- line->b_force_step = false;
|
|
|
- line->time_dec = line->time = time;
|
|
|
-}
|
|
|
-
|
|
|
-static __INLINE void line_ramp_reset(lineramp_t *line, float target) {
|
|
|
- line->target = target;
|
|
|
- line->interpolation = target;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-static __INLINE void line_ramp_set_time(lineramp_t *line, float time) {
|
|
|
- line->time_dec = line->time = time;
|
|
|
- line->b_force_step = false;
|
|
|
-}
|
|
|
-
|
|
|
-static __INLINE void line_ramp_set_dectime(lineramp_t *line, float time) {
|
|
|
- line->time_dec = time;
|
|
|
- line->b_force_step = false;
|
|
|
-}
|
|
|
-
|
|
|
-static __INLINE void line_ramp_set_acctime(lineramp_t *line, float time) {
|
|
|
- line->time = time;
|
|
|
- line->b_force_step = false;
|
|
|
-}
|
|
|
-
|
|
|
-static __INLINE void line_ramp_set_step(lineramp_t *line, float step) {
|
|
|
- line->step = step;
|
|
|
- line->b_force_step = true;
|
|
|
-}
|
|
|
-
|
|
|
-static __INLINE float line_ramp_get_target(lineramp_t *line) {
|
|
|
- return line->target;
|
|
|
-}
|
|
|
-
|
|
|
-static __INLINE float line_ramp_get_interp(lineramp_t *line) {
|
|
|
- return line->interpolation;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-static __INLINE void line_ramp_update(lineramp_t *line) {
|
|
|
- if (!line->b_force_step) {
|
|
|
- float delta = (line->target - line->interpolation);
|
|
|
- if (delta >= 0) {
|
|
|
- line->step = delta / line->time;
|
|
|
- }else {
|
|
|
- line->step = -delta / line->time_dec;
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-static __INLINE float line_ramp_step(lineramp_t *line) {
|
|
|
- step_towards(&line->interpolation, line->target, line->step);
|
|
|
- return line->interpolation;
|
|
|
-}
|
|
|
-
|
|
|
#endif /* _CONTROLLER_H__ */
|
|
|
|