Tuning, use idle state, some power saving

This commit is contained in:
Thomas Kolb 2016-08-07 01:04:24 +02:00
parent 33dea2e7a4
commit cfcbbe5269
1 changed files with 23 additions and 4 deletions

View File

@ -6,6 +6,8 @@
#include <libopencm3/cm3/nvic.h> #include <libopencm3/cm3/nvic.h>
#include <libopencm3/cm3/systick.h> #include <libopencm3/cm3/systick.h>
#include <libopencmsis/core_cm3.h>
#include <fxp.h> #include <fxp.h>
#include <fxp_basic.h> #include <fxp_basic.h>
@ -339,7 +341,7 @@ int main(void)
timer_set_oc_value(TIM1, TIM_CH_CONV, 0); timer_set_oc_value(TIM1, TIM_CH_CONV, 0);
if(time_in_state >= 5) { // bootstrap duration in ms if(time_in_state >= 5) { // bootstrap duration in ms
iErr = fxp_from_int(500); iErr = fxp_div(IERR_LIMIT, fxp_from_int(2));
operState = nextState; operState = nextState;
} }
break; break;
@ -383,6 +385,10 @@ int main(void)
if(current_avg > MAX_CURRENT) { if(current_avg > MAX_CURRENT) {
operState = ConvConstCurrent; operState = ConvConstCurrent;
} }
if(vin_avg < vout_avg) {
operState = Idle;
}
break; break;
case ConvConstCurrent: case ConvConstCurrent:
@ -463,8 +469,8 @@ int main(void)
// power test is currently idle, but power has changed // power test is currently idle, but power has changed
// too much. // too much.
// -> start a new one. // -> start a new one.
testPWM[0] = pwm + 7; testPWM[0] = pwm + 5;
testPWM[1] = pwm - 6; testPWM[1] = pwm - 4;
testPWMStep = 0; testPWMStep = 0;
break; break;
@ -489,12 +495,22 @@ int main(void)
operState = ConvConstCurrent; operState = ConvConstCurrent;
} }
if(vin_avg < vout_avg) {
operState = Idle;
}
break; break;
case Idle: case Idle:
// disable all PWMs // disable all PWMs
timer_set_oc_value(TIM1, TIM_CH_CONV, 0); timer_set_oc_value(TIM1, TIM_CH_CONV, 0);
timer_set_oc_value(TIM1, TIM_CH_BOOTSTRAP, 0); timer_set_oc_value(TIM1, TIM_CH_BOOTSTRAP, 0);
if(vin_avg > vout_avg) {
operState = Bootstrap;
nextState = ConvMPP;
}
break; break;
default: default:
@ -589,7 +605,10 @@ int main(void)
timebase_ms++; timebase_ms++;
while(wait_frame); while(wait_frame) {
__WFI();
}
wait_frame = 1; wait_frame = 1;
} }