mirror of https://github.com/rusefi/bldc.git
Added res, ind and lambda estimation lbm commands
This commit is contained in:
parent
c3461966f2
commit
c01de39288
|
@ -606,6 +606,27 @@ Get FOC d-axis voltage.
|
|||
|
||||
Get FOC q-axis voltage.
|
||||
|
||||
#### get-est-lambda
|
||||
```clj
|
||||
(get-est-lambda)
|
||||
```
|
||||
|
||||
Get FOC estimated flux linkage in Weber. Requires that one of the observers with flux linkage tracking is used. Added in FW 6.02.
|
||||
|
||||
#### get-est-res
|
||||
```clj
|
||||
(get-est-res)
|
||||
```
|
||||
|
||||
Get FOC estimated motor resistance in Ohm. This value is only accurate when the RPM is low and current is high. Added in FW 6.02.
|
||||
|
||||
#### get-est-ind
|
||||
```clj
|
||||
(get-est-ind)
|
||||
```
|
||||
|
||||
Get FOC estimated motor inductance Henry. Only works while the first HFI is running (not 45 Deg and not Coupled HFI). Added in FW 6.02.
|
||||
|
||||
#### get-duty
|
||||
```clj
|
||||
(get-duty)
|
||||
|
|
|
@ -267,7 +267,7 @@ void lispif_process_cmd(unsigned char *data, unsigned int len,
|
|||
commands_printf_lisp("Anything else will be evaluated as an expression in LBM.");
|
||||
commands_printf_lisp(" ");
|
||||
} else if (len >= 5 && strncmp(str, ":info", 5) == 0) {
|
||||
commands_printf_lisp("--(LISP HEAP)-----------------------------------------------\n");
|
||||
commands_printf_lisp("--(LISP HEAP)--\n");
|
||||
commands_printf_lisp("Heap size: %u Bytes\n", HEAP_SIZE * 8);
|
||||
commands_printf_lisp("Used cons cells: %d\n", HEAP_SIZE - lbm_heap_num_free());
|
||||
commands_printf_lisp("Free cons cells: %d\n", lbm_heap_num_free());
|
||||
|
@ -275,11 +275,12 @@ void lispif_process_cmd(unsigned char *data, unsigned int len,
|
|||
commands_printf_lisp("Recovered: %d\n", lbm_heap_state.gc_recovered);
|
||||
commands_printf_lisp("Recovered arrays: %u\n", lbm_heap_state.gc_recovered_arrays);
|
||||
commands_printf_lisp("Marked: %d\n", lbm_heap_state.gc_marked);
|
||||
commands_printf_lisp("--(Symbol and Array memory)---------------------------------\n");
|
||||
commands_printf_lisp("--(Symbol and Array memory)--\n");
|
||||
commands_printf_lisp("Memory size: %u Words\n", lbm_memory_num_words());
|
||||
commands_printf_lisp("Memory free: %u Words\n", lbm_memory_num_free());
|
||||
commands_printf_lisp("Allocated arrays: %u\n", lbm_heap_state.num_alloc_arrays);
|
||||
commands_printf_lisp("Symbol table size: %u Bytes\n", lbm_get_symbol_table_size());
|
||||
commands_printf_lisp("Extensions: %u, max %u\n", lbm_get_num_extensions(), lbm_get_max_extensions());
|
||||
} else if (strncmp(str, ":env", 4) == 0) {
|
||||
lbm_value curr = *lbm_get_env_ptr();
|
||||
char output[128];
|
||||
|
|
|
@ -1377,6 +1377,21 @@ static lbm_value ext_get_vq(lbm_value *args, lbm_uint argn) {
|
|||
return lbm_enc_float(mcpwm_foc_get_vq());
|
||||
}
|
||||
|
||||
static lbm_value ext_foc_est_lambda(lbm_value *args, lbm_uint argn) {
|
||||
(void)args; (void)argn;
|
||||
return lbm_enc_float(mcpwm_foc_get_est_lambda());
|
||||
}
|
||||
|
||||
static lbm_value ext_foc_est_res(lbm_value *args, lbm_uint argn) {
|
||||
(void)args; (void)argn;
|
||||
return lbm_enc_float(mcpwm_foc_get_est_res());
|
||||
}
|
||||
|
||||
static lbm_value ext_foc_est_ind(lbm_value *args, lbm_uint argn) {
|
||||
(void)args; (void)argn;
|
||||
return lbm_enc_float(mcpwm_foc_get_est_ind());
|
||||
}
|
||||
|
||||
static lbm_value ext_get_duty(lbm_value *args, lbm_uint argn) {
|
||||
(void)args; (void)argn;
|
||||
return lbm_enc_float(mc_interface_get_duty_cycle_now());
|
||||
|
@ -4471,6 +4486,9 @@ void lispif_load_vesc_extensions(void) {
|
|||
lbm_add_extension("get-iq", ext_get_iq);
|
||||
lbm_add_extension("get-vd", ext_get_vd);
|
||||
lbm_add_extension("get-vq", ext_get_vq);
|
||||
lbm_add_extension("get-est-lambda", ext_foc_est_lambda);
|
||||
lbm_add_extension("get-est-res", ext_foc_est_res);
|
||||
lbm_add_extension("get-est-ind", ext_foc_est_ind);
|
||||
lbm_add_extension("get-duty", ext_get_duty);
|
||||
lbm_add_extension("get-rpm", ext_get_rpm);
|
||||
lbm_add_extension("get-pos", ext_get_pos);
|
||||
|
|
|
@ -190,7 +190,7 @@ typedef struct {
|
|||
bool m_motor_released;
|
||||
|
||||
// Resistance observer
|
||||
float m_r_est;
|
||||
float m_res_est;
|
||||
float m_r_est_state;
|
||||
|
||||
// Temperature-compensated parameters
|
||||
|
|
|
@ -1395,6 +1395,21 @@ float mcpwm_foc_get_mod_beta_measured(void) {
|
|||
return get_motor_now()->m_motor_state.mod_beta_measured;
|
||||
}
|
||||
|
||||
float mcpwm_foc_get_est_lambda(void) {
|
||||
return get_motor_now()->m_observer_state.lambda_est;
|
||||
}
|
||||
|
||||
float mcpwm_foc_get_est_res(void) {
|
||||
return get_motor_now()->m_res_est;
|
||||
}
|
||||
|
||||
// NOTE: Requires the regular HFI sensor mode to run
|
||||
float mcpwm_foc_get_est_ind(void) {
|
||||
float real_bin0, imag_bin0;
|
||||
get_motor_now()->m_hfi.fft_bin0_func((float*)get_motor_now()->m_hfi.buffer, &real_bin0, &imag_bin0);
|
||||
return real_bin0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Measure encoder offset and direction.
|
||||
*
|
||||
|
@ -3524,8 +3539,8 @@ static void timer_update(motor_all_state_t *motor, float dt) {
|
|||
{
|
||||
float res_est_gain = 0.00002;
|
||||
float i_abs_sq = SQ(motor->m_motor_state.i_abs);
|
||||
motor->m_r_est = motor->m_r_est_state - 0.5 * res_est_gain * conf_now->foc_motor_l * i_abs_sq;
|
||||
float res_dot = -res_est_gain * (motor->m_r_est * i_abs_sq + motor->m_speed_est_fast *
|
||||
motor->m_res_est = motor->m_r_est_state - 0.5 * res_est_gain * conf_now->foc_motor_l * i_abs_sq;
|
||||
float res_dot = -res_est_gain * (motor->m_res_est * i_abs_sq + motor->m_speed_est_fast *
|
||||
(motor->m_motor_state.i_beta * motor->m_observer_state.x1 - motor->m_motor_state.i_alpha * motor->m_observer_state.x2) -
|
||||
(motor->m_motor_state.i_alpha * motor->m_motor_state.v_alpha + motor->m_motor_state.i_beta * motor->m_motor_state.v_beta));
|
||||
motor->m_r_est_state += res_dot * dt;
|
||||
|
@ -3556,7 +3571,7 @@ static void terminal_tmp(int argc, const char **argv) {
|
|||
}
|
||||
|
||||
for (int i = 0;i < top;i++) {
|
||||
float res_est = m_motor_1.m_r_est;
|
||||
float res_est = m_motor_1.m_res_est;
|
||||
float t_base = m_motor_1.m_conf->foc_temp_comp_base_temp;
|
||||
float res_base = m_motor_1.m_conf->foc_motor_r;
|
||||
float t_est = (res_est / res_base - 1) / 0.00386 + t_base;
|
||||
|
|
|
@ -81,6 +81,9 @@ float mcpwm_foc_get_mod_alpha_raw(void);
|
|||
float mcpwm_foc_get_mod_beta_raw(void);
|
||||
float mcpwm_foc_get_mod_alpha_measured(void);
|
||||
float mcpwm_foc_get_mod_beta_measured(void);
|
||||
float mcpwm_foc_get_est_lambda(void);
|
||||
float mcpwm_foc_get_est_res(void);
|
||||
float mcpwm_foc_get_est_ind(void);
|
||||
int mcpwm_foc_encoder_detect(float current, bool print, float *offset, float *ratio, bool *inverted);
|
||||
int mcpwm_foc_measure_resistance(float current, int samples, bool stop_after, float *resistance);
|
||||
int mcpwm_foc_measure_inductance(float duty, int samples, float *curr, float *ld_lq_diff, float *inductance);
|
||||
|
|
Loading…
Reference in New Issue