Calibrate parameters for v1.1

This commit is contained in:
Thomas Kolb 2016-10-03 14:59:31 +02:00
parent f698413f8d
commit 958d82b414
1 changed files with 22 additions and 10 deletions

View File

@ -526,9 +526,9 @@ int main(void)
uint32_t sleep_time = 10;
uint64_t force_display_update_time = 1000;
fxp_t PGAIN_CV = fxp_from_float( 1000.000f);
fxp_t IGAIN_CV = fxp_from_float( 0.500f);
fxp_t IERR_LIMIT = fxp_from_int(5000);
fxp_t PGAIN_CV = fxp_from_float( 2000.000f);
fxp_t IGAIN_CV = fxp_from_float( 1.000f);
fxp_t IERR_LIMIT = fxp_from_int(1000);
fxp_t PGAIN_CC = fxp_from_float( 50.000f);
fxp_t IGAIN_CC = fxp_from_float( 0.300f);
@ -558,16 +558,16 @@ int main(void)
fxp_t LOAD_LOW_VOLTAGE_THRESHOLD = fxp_from_float(11.600f);
// Calculated values
//fxp_t VIN_SCALE = fxp_from_float(3.3f * (100 + 12.4f) / 12.4f / 4095.0f);
//fxp_t VIN_SCALE = fxp_from_float(3.3f * (100 + 10.0f) / 10.0f / 4095.0f);
//fxp_t VOUT_SCALE = fxp_from_float(3.3f * (100 + 12.0f) / 12.0f / 4095.0f);
//fxp_t CURRENT_SCALE = fxp_from_float(9.7f / 4095.0f);
// Calibrated from measurements
fxp_t VIN_SCALE = fxp_from_float(12.23f / 1600.0f);
fxp_t VOUT_SCALE = fxp_from_float(12.76f / 1620.0f);
fxp_t CURRENT_SCALE = fxp_from_float(8.95f / 4095.0f);
fxp_t VIN_SCALE = fxp_from_float(36.41f / 4096.0f);
fxp_t VOUT_SCALE = fxp_from_float(30.87f / 4096.0f);
fxp_t CURRENT_SCALE = fxp_from_float(9.10f / 4096.0f);
fxp_t CURRENT_OFFSET = fxp_from_float(0.045);
fxp_t CURRENT_OFFSET = fxp_from_float(0.196);
/* if power changes by more than this factor, MPP is tested again */
MPP_MAX_POWER_CHANGE_FACTOR = fxp_from_float(0.2f);
@ -651,6 +651,16 @@ int main(void)
while(!dma_get_interrupt_flag(DMA1, DMA_CHANNEL1, DMA_TCIF) && wait_frame);
dma_clear_interrupt_flags(DMA1, DMA_CHANNEL1, DMA_TCIF);
if(timebase_ms % 250 == 0) {
debug_send_string("ADC: ");
for(int i = 0; i < 3; i++) {
fxp_format_int(adc_values[i], msg);
debug_send_string(msg);
debug_send_string(" ");
}
debug_send_string("\r\n");
}
// convert read values
power_state.vin = fxp_mult(fxp_from_int(adc_values[0]), VIN_SCALE);
power_state.vout = fxp_mult(fxp_from_int(adc_values[1]), VOUT_SCALE);
@ -688,7 +698,7 @@ int main(void)
timer_set_oc_value(TIM1, TIM_CH_CONV, 0);
timer_set_oc_value(TIM1, TIM_CH_BOOTSTRAP, 24);
if(time_in_state >= 5) { // bootstrap duration in ms
if(time_in_state >= 10) { // bootstrap duration in ms
//iErr = 0;
operState = nextState;
}
@ -879,12 +889,14 @@ int main(void)
#ifndef DEBUG
deepsleep(sleep_time);
#endif
// Woke up again.
lcd_set_cursor_pos(0, 0);
lcd_send_string(" ");
time_in_state = 9900; // run the voltage test again
#else
time_in_state = 0;
#endif
sleep_time *= 2;
if(power_state.vout_avg > LOAD_LOW_VOLTAGE_THRESHOLD) {