Added setpoint offset 004002, pending of bench tests
This commit is contained in:
@@ -134,8 +134,6 @@ void FBKW_init(void) {
|
|||||||
fbkw_getters.ctx = NULL;
|
fbkw_getters.ctx = NULL;
|
||||||
|
|
||||||
pwm_init(&fbkw_rt, &pwm_cal_rom, &pwm_flash_rom, &fbkw_getters);
|
pwm_init(&fbkw_rt, &pwm_cal_rom, &pwm_flash_rom, &fbkw_getters);
|
||||||
fbkw_rt.setpoint_offset = (int16_t)0xFD66;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FBKW_service(void) {
|
void FBKW_service(void) {
|
||||||
|
|||||||
@@ -3,13 +3,13 @@
|
|||||||
* @brief ROM-extracted calibration data for the VP44 PWM controller (compact).
|
* @brief ROM-extracted calibration data for the VP44 PWM controller (compact).
|
||||||
*
|
*
|
||||||
* AUTO-GENERATED by tools/extract_calibration.py
|
* AUTO-GENERATED by tools/extract_calibration.py
|
||||||
* Source ROM: rom_eeprom_dump_004002_0x0000-40960.bin
|
* Source ROM: rom_eeprom_dump_0000-9FFF_004002.bin
|
||||||
* Calibration base (RWA4): 0x9C28
|
* Calibration base (RWA4): 0x9C28
|
||||||
* Flash anchor: 0x9618
|
* Flash anchor: 0x9618
|
||||||
* Generated: 2026-04-17 22:03:12
|
* Generated: 2026-04-18 13:52:55
|
||||||
*
|
*
|
||||||
* DO NOT EDIT — regenerate with:
|
* DO NOT EDIT — regenerate with:
|
||||||
* python tools/extract_calibration.py rom_eeprom_dump_004002_0x0000-40960.bin --target compact
|
* python tools/extract_calibration.py rom_eeprom_dump_0000-9FFF_004002.bin --target compact
|
||||||
*/
|
*/
|
||||||
#include "cal_tables_rom.h"
|
#include "cal_tables_rom.h"
|
||||||
|
|
||||||
@@ -119,6 +119,11 @@ const pwm_calibration_t pwm_cal_rom = {
|
|||||||
.closed_loop_gain_const = 4, /* CAL+0x0156 */
|
.closed_loop_gain_const = 4, /* CAL+0x0156 */
|
||||||
.error_persist_init_count = 100, /* CAL+0x0108 */
|
.error_persist_init_count = 100, /* CAL+0x0108 */
|
||||||
.recovery_rpm_threshold = 4194, /* CAL+0x011A */
|
.recovery_rpm_threshold = 4194, /* CAL+0x011A */
|
||||||
|
|
||||||
|
/* Setpoint offset latched at init by FUN_8643 (0x867d):
|
||||||
|
* CAL[0x52]=2167 - CAL[0x54]=2833 = -666
|
||||||
|
* (RAM[0x0430] always 0, so omitted). */
|
||||||
|
.setpoint_offset = (int16_t)0xFD66, /* CAL+0x0052 - CAL+0x0054 */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ── ROM-extracted flash tables (rebased from FLASH:xxxx) ───────────── */
|
/* ── ROM-extracted flash tables (rebased from FLASH:xxxx) ───────────── */
|
||||||
|
|||||||
@@ -3,11 +3,11 @@
|
|||||||
* @brief Extern declarations for ROM-extracted calibration data (compact).
|
* @brief Extern declarations for ROM-extracted calibration data (compact).
|
||||||
*
|
*
|
||||||
* AUTO-GENERATED by tools/extract_calibration.py
|
* AUTO-GENERATED by tools/extract_calibration.py
|
||||||
* Source ROM: rom_dump_0000-9FFF.bin
|
* Source ROM: rom_eeprom_dump_0000-9FFF_004002.bin
|
||||||
* Calibration base (RWA4): 0x9C28
|
* Calibration base (RWA4): 0x9C28
|
||||||
*
|
*
|
||||||
* DO NOT EDIT — regenerate with:
|
* DO NOT EDIT — regenerate with:
|
||||||
* python tools/extract_calibration.py rom_dump_0000-9FFF.bin --target compact
|
* python tools/extract_calibration.py rom_eeprom_dump_0000-9FFF_004002.bin --target compact
|
||||||
*/
|
*/
|
||||||
#ifndef CAL_TABLES_ROM_H
|
#ifndef CAL_TABLES_ROM_H
|
||||||
#define CAL_TABLES_ROM_H
|
#define CAL_TABLES_ROM_H
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ static void apply_calibration(pwm_runtime_t *rt, const pwm_calibration_t *c)
|
|||||||
rt->upper_integrator_gain = c->pi_upper_integrator_gain;
|
rt->upper_integrator_gain = c->pi_upper_integrator_gain;
|
||||||
rt->center_integrator_gain = c->pi_center_integrator_gain;
|
rt->center_integrator_gain = c->pi_center_integrator_gain;
|
||||||
rt->lower_integrator_gain = c->pi_lower_integrator_gain;
|
rt->lower_integrator_gain = c->pi_lower_integrator_gain;
|
||||||
|
rt->setpoint_offset = c->setpoint_offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pwm_init(pwm_runtime_t *rt,
|
void pwm_init(pwm_runtime_t *rt,
|
||||||
@@ -139,14 +140,11 @@ static void setpoint_compute(pwm_runtime_t *rt, const pwm_calibration_t *cal)
|
|||||||
rt->compensation_angle = (int16_t)(rt->compensation_angle +
|
rt->compensation_angle = (int16_t)(rt->compensation_angle +
|
||||||
s_combine(cal->y_pair[2], &rt->setpoint_slot_x, &rt->setpoint_slot_y));
|
s_combine(cal->y_pair[2], &rt->setpoint_slot_x, &rt->setpoint_slot_y));
|
||||||
|
|
||||||
//comp angle is 02b6
|
|
||||||
|
|
||||||
|
|
||||||
int16_t sum = (int16_t)(rt->inputs.b_fb_kw + rt->compensation_angle);
|
int16_t sum = (int16_t)(rt->inputs.b_fb_kw + rt->compensation_angle);
|
||||||
int16_t half = shra16(sum, 1); /* SHRA — signed halve */
|
int16_t half = shra16(sum, 1); /* SHRA — signed halve */
|
||||||
rt->pre_offset_target = half; //this is 012a
|
rt->pre_offset_target = half;
|
||||||
|
|
||||||
int16_t t = (int16_t)(half + rt->setpoint_offset); // offset is 0150
|
int16_t t = (int16_t)(half + rt->setpoint_offset);
|
||||||
if (t < cal->target_minimum) t = cal->target_minimum;
|
if (t < cal->target_minimum) t = cal->target_minimum;
|
||||||
rt->target = t;
|
rt->target = t;
|
||||||
}
|
}
|
||||||
@@ -518,6 +516,7 @@ const pwm_calibration_t pwm_cal_default = {
|
|||||||
.pi_upper_integrator_gain = 1024,
|
.pi_upper_integrator_gain = 1024,
|
||||||
.pi_center_integrator_gain = 1024,
|
.pi_center_integrator_gain = 1024,
|
||||||
.pi_lower_integrator_gain = 2048,
|
.pi_lower_integrator_gain = 2048,
|
||||||
|
.setpoint_offset = 0, /* CAL+0x52 - CAL+0x54 — populated from ROM */
|
||||||
};
|
};
|
||||||
|
|
||||||
const pwm_flash_t pwm_flash_default = {
|
const pwm_flash_t pwm_flash_default = {
|
||||||
|
|||||||
@@ -202,6 +202,12 @@ struct pwm_calibration {
|
|||||||
/* fast_recovery tuning */
|
/* fast_recovery tuning */
|
||||||
int16_t error_persist_init_count; /* CAL+0x0108 */
|
int16_t error_persist_init_count; /* CAL+0x0108 */
|
||||||
int16_t recovery_rpm_threshold; /* CAL+0x011A */
|
int16_t recovery_rpm_threshold; /* CAL+0x011A */
|
||||||
|
|
||||||
|
/* Setpoint offset latched once at init by FUN_8643 (0x867d):
|
||||||
|
* RAM[0x0150] = CAL[0x52] - (CAL[0x54] + RAM[0x0430])
|
||||||
|
* RAM[0x0430] is observed as always 0 at runtime, so the effective
|
||||||
|
* constant is CAL[0x52] - CAL[0x54]. */
|
||||||
|
int16_t setpoint_offset; /* CAL+0x0052 - CAL+0x0054 (RAM 0x0150) */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ── Flash-resident tables ──────────────────────────────────────────── */
|
/* ── Flash-resident tables ──────────────────────────────────────────── */
|
||||||
|
|||||||
Reference in New Issue
Block a user