Skip to content

Commit 16385f1

Browse files
committed
Renamed compression to lzo, added observer offset parameter
1 parent 37ac4ff commit 16385f1

16 files changed

+30
-11
lines changed

CHANGELOG

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
* Added MTPA mode based on measured current.
4646
* Faster overvoltage protection.
4747
* Added statistics counters.
48+
* Added configurable observer offset.
4849

4950
=== FW 5.02 ===
5051
* IMU calibration improvement.

Makefile

+8-5
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,9 @@ include nrf/nrf.mk
110110
include libcanard/canard.mk
111111
include imu/imu.mk
112112
include lora/lora.mk
113-
include compression/compression.mk
113+
include lzo/lzo.mk
114114
include blackmagic/blackmagic.mk
115+
#include lispBM/lispbm.mk
115116

116117
# Define linker script file here
117118
LDSCRIPT= ld_eeprom_emu.ld
@@ -167,9 +168,10 @@ CSRC = $(STARTUPSRC) \
167168
$(CANARDSRC) \
168169
$(IMUSRC) \
169170
$(LORASRC) \
170-
$(COMPRESSIONSRC) \
171+
$(LZOSRC) \
171172
$(BLACKMAGICSRC) \
172-
qmlui/qmlui.c
173+
qmlui/qmlui.c \
174+
$(LISPBMSRC)
173175

174176
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
175177
# setting.
@@ -210,11 +212,12 @@ INCDIR = $(STARTUPINC) $(KERNINC) $(PORTINC) $(OSALINC) \
210212
$(CANARDINC) \
211213
$(IMUINC) \
212214
$(LORAINC) \
213-
$(COMPRESSIONINC) \
215+
$(LZOINC) \
214216
$(BLACKMAGICINC) \
215217
qmlui \
216218
qmlui/hw \
217-
qmlui/app
219+
qmlui/app \
220+
$(LISPBMINC)
218221

219222
ifdef app_custom_mkfile
220223
include $(app_custom_mkfile)

compression/compression.mk

-3
This file was deleted.

conf_general.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#define FW_VERSION_MAJOR 5
2525
#define FW_VERSION_MINOR 03
2626
// Set to 0 for building a release and iterate during beta test builds
27-
#define FW_TEST_VERSION_NUMBER 77
27+
#define FW_TEST_VERSION_NUMBER 78
2828

2929
#include "datatypes.h"
3030

confgenerator.c

+3
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ int32_t confgenerator_serialize_mcconf(uint8_t *buffer, const mc_configuration *
7777
buffer_append_float32_auto(buffer, conf->foc_motor_flux_linkage, &ind);
7878
buffer_append_float32_auto(buffer, conf->foc_observer_gain, &ind);
7979
buffer_append_float32_auto(buffer, conf->foc_observer_gain_slow, &ind);
80+
buffer_append_float16(buffer, conf->foc_observer_offset, 1000, &ind);
8081
buffer_append_float32_auto(buffer, conf->foc_duty_dowmramp_kp, &ind);
8182
buffer_append_float32_auto(buffer, conf->foc_duty_dowmramp_ki, &ind);
8283
buffer_append_float32_auto(buffer, conf->foc_openloop_rpm, &ind);
@@ -445,6 +446,7 @@ bool confgenerator_deserialize_mcconf(const uint8_t *buffer, mc_configuration *c
445446
conf->foc_motor_flux_linkage = buffer_get_float32_auto(buffer, &ind);
446447
conf->foc_observer_gain = buffer_get_float32_auto(buffer, &ind);
447448
conf->foc_observer_gain_slow = buffer_get_float32_auto(buffer, &ind);
449+
conf->foc_observer_offset = buffer_get_float16(buffer, 1000, &ind);
448450
conf->foc_duty_dowmramp_kp = buffer_get_float32_auto(buffer, &ind);
449451
conf->foc_duty_dowmramp_ki = buffer_get_float32_auto(buffer, &ind);
450452
conf->foc_openloop_rpm = buffer_get_float32_auto(buffer, &ind);
@@ -809,6 +811,7 @@ void confgenerator_set_defaults_mcconf(mc_configuration *conf) {
809811
conf->foc_motor_flux_linkage = MCCONF_FOC_MOTOR_FLUX_LINKAGE;
810812
conf->foc_observer_gain = MCCONF_FOC_OBSERVER_GAIN;
811813
conf->foc_observer_gain_slow = MCCONF_FOC_OBSERVER_GAIN_SLOW;
814+
conf->foc_observer_offset = MCCONF_FOC_OBSERVER_OFFSET;
812815
conf->foc_duty_dowmramp_kp = MCCONF_FOC_DUTY_DOWNRAMP_KP;
813816
conf->foc_duty_dowmramp_ki = MCCONF_FOC_DUTY_DOWNRAMP_KI;
814817
conf->foc_openloop_rpm = MCCONF_FOC_OPENLOOP_RPM;

confgenerator.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include <stdbool.h>
99

1010
// Constants
11-
#define MCCONF_SIGNATURE 919732468
11+
#define MCCONF_SIGNATURE 2525666056
1212
#define APPCONF_SIGNATURE 3733512279
1313

1414
// Functions

datatypes.h

+1
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ typedef struct {
384384
float foc_motor_flux_linkage;
385385
float foc_observer_gain;
386386
float foc_observer_gain_slow;
387+
float foc_observer_offset;
387388
float foc_pll_kp;
388389
float foc_pll_ki;
389390
float foc_duty_dowmramp_kp;
File renamed without changes.

lzo/lzo.mk

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
LZOSRC = lzo/minilzo.c
2+
LZOINC = lzo
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

main.c

+3
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
#include "mempools.h"
5656
#include "events.h"
5757
#include "main.h"
58+
//#include "lispif.h"
5859

5960
/*
6061
* HW resources used:
@@ -303,6 +304,8 @@ int main(void) {
303304
palSetPad(BOOT_OK_GPIO, BOOT_OK_PIN);
304305
#endif
305306

307+
// lispif_init();
308+
306309
m_init_done = true;
307310

308311
for(;;) {

mcconf/mcconf_default.h

+3
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,9 @@
286286
#ifndef MCCONF_FOC_OBSERVER_GAIN_SLOW
287287
#define MCCONF_FOC_OBSERVER_GAIN_SLOW 0.05 // Observer gain scale at minimum duty cycle
288288
#endif
289+
#ifndef MCCONF_FOC_OBSERVER_OFFSET
290+
#define MCCONF_FOC_OBSERVER_OFFSET -1.0 // Observer offset in timer update cycles
291+
#endif
289292
#ifndef MCCONF_FOC_DUTY_DOWNRAMP_KP
290293
#define MCCONF_FOC_DUTY_DOWNRAMP_KP 10.0 // PI controller for duty control when decreasing the duty
291294
#endif

mcpwm_foc.c

+7-1
Original file line numberDiff line numberDiff line change
@@ -2774,7 +2774,7 @@ void mcpwm_foc_adc_int_handler(void *p, uint32_t flags) {
27742774

27752775
// Compensate from the phase lag caused by the switching frequency. This is important for motors
27762776
// that run on high ERPM compared to the switching frequency.
2777-
motor_now->m_phase_now_observer += motor_now->m_pll_speed * dt * 0.5;
2777+
motor_now->m_phase_now_observer += motor_now->m_pll_speed * dt * (0.5 + conf_now->foc_observer_offset);
27782778
utils_norm_angle_rad((float*)&motor_now->m_phase_now_observer);
27792779
}
27802780

@@ -2951,6 +2951,12 @@ void mcpwm_foc_adc_int_handler(void *p, uint32_t flags) {
29512951
motor_now->m_phase_now_observer = utils_fast_atan2(motor_now->m_x2_prev + motor_now->m_observer_x2,
29522952
motor_now->m_x1_prev + motor_now->m_observer_x1);
29532953

2954+
// The observer phase offset has to be added here as well, with 0.5 switching cycles offset
2955+
// compared to when running. Otherwise going from undriven to driven causes a current
2956+
// spike.
2957+
motor_now->m_phase_now_observer += motor_now->m_pll_speed * dt * conf_now->foc_observer_offset;
2958+
utils_norm_angle_rad((float*)&motor_now->m_phase_now_observer);
2959+
29542960
motor_now->m_x1_prev = motor_now->m_observer_x1;
29552961
motor_now->m_x2_prev = motor_now->m_observer_x2;
29562962

0 commit comments

Comments
 (0)