mirror of https://github.com/rusefi/bldc.git
Some updates to MTPA PR
This commit is contained in:
parent
dea04a5e22
commit
960cd3b992
|
@ -5,6 +5,7 @@
|
|||
* Fixed motor temperature reading on hw with ADC mux.
|
||||
* Added speed PID input ramping option.
|
||||
* Added LSM6DS3 IMU support.
|
||||
* Added MTPA support. See See: https://github.com/vedderb/bldc/pull/179
|
||||
|
||||
=== FW 5.01 ===
|
||||
* Fixed PPM bug in previous release.
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#define FW_VERSION_MAJOR 5
|
||||
#define FW_VERSION_MINOR 02
|
||||
// Set to 0 for building a release and iterate during beta test builds
|
||||
#define FW_TEST_VERSION_NUMBER 3
|
||||
#define FW_TEST_VERSION_NUMBER 4
|
||||
|
||||
#include "datatypes.h"
|
||||
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
#include <stdbool.h>
|
||||
|
||||
// Constants
|
||||
#define MCCONF_SIGNATURE 2013508732
|
||||
#define APPCONF_SIGNATURE 2460147246
|
||||
#define MCCONF_SIGNATURE 1358025204
|
||||
#define APPCONF_SIGNATURE 2662993821
|
||||
|
||||
// Functions
|
||||
int32_t confgenerator_serialize_mcconf(uint8_t *buffer, const mc_configuration *conf);
|
||||
|
|
21
mcpwm_foc.c
21
mcpwm_foc.c
|
@ -195,7 +195,6 @@ static void terminal_plot_hfi(int argc, const char **argv);
|
|||
static void timer_update(volatile motor_all_state_t *motor, float dt);
|
||||
static void input_current_offset_measurement( void );
|
||||
static void hfi_update(volatile motor_all_state_t *motor);
|
||||
static void apply_mtpa(float *id, float *iq, volatile motor_all_state_t *motor);
|
||||
|
||||
// Threads
|
||||
static THD_WORKING_AREA(timer_thread_wa, 1024);
|
||||
|
@ -2547,7 +2546,14 @@ void mcpwm_foc_adc_int_handler(void *p, uint32_t flags) {
|
|||
motor_now->m_motor_state.phase = motor_now->m_phase_now_override;
|
||||
}
|
||||
|
||||
apply_mtpa(&id_set_tmp, &iq_set_tmp, motor_now);
|
||||
// Apply MTPA. See: https://github.com/vedderb/bldc/pull/179
|
||||
float ld_lq_diff = conf_now->foc_motor_ld_lq_diff;
|
||||
if (ld_lq_diff != 0.0) {
|
||||
float lambda = conf_now->foc_motor_flux_linkage;
|
||||
|
||||
id_set_tmp = (lambda - sqrtf(SQ(lambda) + 8.0 * SQ(ld_lq_diff) * SQ(iq_set_tmp))) / (4.0 * ld_lq_diff);
|
||||
iq_set_tmp = SIGN(iq_set_tmp) * sqrtf(SQ(iq_set_tmp) - SQ(id_set_tmp));
|
||||
}
|
||||
|
||||
// Apply current limits
|
||||
// TODO: Consider D axis current for the input current as well.
|
||||
|
@ -3989,14 +3995,3 @@ static void terminal_plot_hfi(int argc, const char **argv) {
|
|||
commands_printf("This command requires one argument.\n");
|
||||
}
|
||||
}
|
||||
|
||||
static void apply_mtpa(float *id, float *iq, volatile motor_all_state_t *motor) {
|
||||
float ld_lq_diff = motor->m_conf->foc_motor_ld_lq_diff;
|
||||
|
||||
if(ld_lq_diff != 0.0){
|
||||
float lambda = motor->m_conf->foc_motor_flux_linkage;
|
||||
|
||||
*id = (lambda - sqrtf(SQ(lambda) + 8.0 * SQ(ld_lq_diff) * SQ(*iq))) / (4.0 * ld_lq_diff);
|
||||
*iq = SIGN(*iq) * sqrtf(SQ(*iq) - SQ(*id));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue