DC/DC test function and dead time config added

- The DC/DC test function slowly ramps up the duty cycle to 50% to allow defined measurements of gate driver, switch node etc. with an oscilloscope (without disturbance by the MPPT algorithm)

- The dead-time between HS and LS gate on/off is now configurable for each PCB and not fixed to 300 ns for all PCBs anymore.
This commit is contained in:
Martin Jaeger
2019-07-05 11:01:35 +02:00
parent 7ee248cf81
commit 7300406b94
9 changed files with 49 additions and 5 deletions
+36
View File
@@ -181,6 +181,42 @@ void dcdc_control(dcdc_t *dcdc, dc_bus_t *hs, dc_bus_t *ls)
}
}
void dcdc_test(dcdc_t *dcdc, dc_bus_t *hs, dc_bus_t *ls)
{
if (half_bridge_enabled()) {
if (half_bridge_get_duty_cycle() > 0.5) {
half_bridge_duty_cycle_step(-1);
}
}
else {
static int startup_delay_counter = 0;
static const int num_wait_calls = (CONTROL_FREQUENCY / 10 >= 1) ? (CONTROL_FREQUENCY / 10) : 1; // wait at least 100 ms for voltages to settle
if (_dcdc_check_start_conditions(dcdc, ls, hs) && ls->voltage < dcdc->ls_voltage_max) {
if (startup_delay_counter >= num_wait_calls) {
// Don't start directly at Vmpp (approx. 0.8 * Voc) to prevent high inrush currents and stress on MOSFETs
half_bridge_start(ls->voltage / (hs->voltage - 1));
printf("DC/DC buck mode start (HS: %.2fV, LS: %.2fV, PWM: %.1f).\n", hs->voltage, ls->voltage, half_bridge_get_duty_cycle() * 100);
}
else {
startup_delay_counter++;
}
}
else if (_dcdc_check_start_conditions(dcdc, hs, ls) && hs->voltage < dcdc->hs_voltage_max) {
if (startup_delay_counter >= num_wait_calls) {
// will automatically start with max. duty (0.97) if connected to a nanogrid not yet started up (zero voltage)
half_bridge_start(ls->voltage / (hs->voltage + 1));
printf("DC/DC boost mode start (HS: %.2fV, LS: %.2fV, PWM: %.1f).\n", hs->voltage, ls->voltage, half_bridge_get_duty_cycle() * 100);
}
else {
startup_delay_counter++;
}
}
else {
startup_delay_counter = 0; // reset counter
}
}
}
void dcdc_self_destruction()
{
printf("Charge controller self-destruction called!\n");
+8
View File
@@ -101,6 +101,14 @@ void dcdc_init(dcdc_t *dcdc);
*/
void dcdc_control(dcdc_t *dcdc, dc_bus_t *high_side, dc_bus_t *low_side);
/** Test mode for DC/DC, ramping up to 50% duty cycle
*
* @param dcdc DC/DC type description
* @param high_side High-side power port (e.g. solar input for typical MPPT charge controller application)
* @param low_side Low-side power port (e.g. battery output for typical MPPT charge controller application)
*/
void dcdc_test(dcdc_t *dcdc, dc_bus_t *high_side, dc_bus_t *low_side);
/** Prevent overcharging of battery in case of shorted HS MOSFET
*
* This function switches the LS MOSFET continuously on to blow the battery input fuse. The reason for self destruction should
-2
View File
@@ -147,11 +147,9 @@ void half_bridge_start(float pwm_duty)
{
half_bridge_set_duty_cycle(pwm_duty);
#ifndef PIL_TESTING
// Break and Dead-Time Register
// MOE = 1: Main output enable
TIM1->BDTR |= TIM_BDTR_MOE;
#endif
_enabled = true;
}
-2
View File
@@ -146,7 +146,6 @@ void half_bridge_start(float pwm_duty)
{
half_bridge_set_duty_cycle(pwm_duty);
#ifndef PIL_TESTING
// Capture/Compare Enable Register
// CCxE = 1: Enable the output on OCx
// CCxP = 0: Active high polarity on OCx (default)
@@ -154,7 +153,6 @@ void half_bridge_start(float pwm_duty)
// CCxNP = 0: Active high polarity on OC1N (default)
TIM3->CCER |= TIM_CCER_CC3E;
TIM3->CCER |= TIM_CCER_CC4E;
#endif
_enabled = true;
}
+1 -1
View File
@@ -116,7 +116,7 @@ int main()
pwm_switch_init(&pwm_switch);
#else // MPPT
dcdc_init(&dcdc);
half_bridge_init(PWM_FREQUENCY, 300, 12 / dcdc.hs_voltage_max, 0.97); // lower duty limit might have to be adjusted dynamically depending on LS voltage
half_bridge_init(PWM_FREQUENCY, PWM_DEADTIME, 12 / dcdc.hs_voltage_max, 0.97); // lower duty limit might have to be adjusted dynamically depending on LS voltage
#endif
// Configuration from EEPROM
+1
View File
@@ -24,6 +24,7 @@
// DC/DC converter settings
#define PWM_FREQUENCY 50 // kHz 50 = better for cloud solar to increase efficiency
#define PWM_DEADTIME 300 // ns
#define PWM_TIM 1 // use TIM1 timer
#define DCDC_CURRENT_MAX 8 // PCB maximum DCDC output current
+1
View File
@@ -24,6 +24,7 @@
// DC/DC converter settings
#define PWM_FREQUENCY 50 // kHz 50 = better for cloud solar to increase efficiency
#define PWM_DEADTIME 230 // ns
#define PWM_TIM 3 // use TIM3 timer
#define DCDC_CURRENT_MAX 10 // PCB maximum DCDC output current
+1
View File
@@ -24,6 +24,7 @@
// DC/DC converter settings
#define PWM_FREQUENCY 50 // kHz 50 = better for cloud solar to increase efficiency
#define PWM_DEADTIME 230 // ns
#define PWM_TIM 3 // use TIM3 timer
#define DCDC_CURRENT_MAX 10 // PCB maximum DCDC output current
+1
View File
@@ -24,6 +24,7 @@
// DC/DC converter settings
#define PWM_FREQUENCY 70 // kHz 70 = good compromise between output ripple and efficiency
#define PWM_DEADTIME 300 // ns
#define PWM_TIM 1 // use TIM1 timer
#define DCDC_CURRENT_MAX 20 // PCB maximum DCDC output current