Fixing load overvoltage protection (closes #27)
This commit is contained in:
+4
-2
@@ -296,7 +296,7 @@ extern log_data_t log_data;
|
||||
extern float mcu_temp;
|
||||
|
||||
// this function is called more often than the state machine
|
||||
void load_control(load_output_t *load)
|
||||
void load_control(load_output_t *load, float load_max_voltage)
|
||||
{
|
||||
if (short_circuit) {
|
||||
load->switch_state = LOAD_STATE_OFF_SHORT_CIRCUIT;
|
||||
@@ -317,7 +317,9 @@ void load_control(load_output_t *load)
|
||||
}
|
||||
|
||||
static int debounce_counter = 0;
|
||||
if (load->bus->voltage > LOW_SIDE_VOLTAGE_MAX) {
|
||||
if (load->bus->voltage > load_max_voltage ||
|
||||
load->bus->voltage > LOW_SIDE_VOLTAGE_MAX)
|
||||
{
|
||||
debounce_counter++;
|
||||
if (debounce_counter > CONTROL_FREQUENCY) { // waited 1s before setting the flag
|
||||
load_switch_set(false);
|
||||
|
||||
+1
-1
@@ -79,6 +79,6 @@ void load_state_machine(load_output_t *load, bool source_enabled);
|
||||
*
|
||||
* Performs time-critical checks like overcurrent and overvoltage
|
||||
*/
|
||||
void load_control(load_output_t *load);
|
||||
void load_control(load_output_t *load, float load_max_voltage);
|
||||
|
||||
#endif /* LOAD_H */
|
||||
|
||||
+2
-2
@@ -80,7 +80,7 @@ void system_control()
|
||||
leds_set_charging(half_bridge_enabled());
|
||||
#endif
|
||||
|
||||
load_control(&load);
|
||||
load_control(&load, bat_conf.voltage_absolute_max * charger.num_batteries);
|
||||
|
||||
if (counter % CONTROL_FREQUENCY == 0) {
|
||||
// called once per second (this timer is much more accurate than time(NULL) based on LSI)
|
||||
@@ -137,7 +137,7 @@ int main()
|
||||
#ifdef UART_SERIAL_ENABLED
|
||||
thingset_serial_init(&serial);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef CAN_ENABLED
|
||||
ts_can.enable();
|
||||
#endif
|
||||
|
||||
@@ -26,14 +26,6 @@
|
||||
// generic settings (for all charge controller boards)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/** Maximum voltage at battery port (V)
|
||||
*/
|
||||
#define LOW_SIDE_VOLTAGE_MAX 32
|
||||
|
||||
/** Maximum voltage at PV input port (V)
|
||||
*/
|
||||
#define HIGH_SIDE_VOLTAGE_MAX 55
|
||||
|
||||
/** Main control function frequency (Hz)
|
||||
*
|
||||
* Frequencies higher than 10 Hz caused issues with MPPT control during lab test with
|
||||
|
||||
@@ -29,6 +29,9 @@
|
||||
#define DCDC_CURRENT_MAX 8 // PCB maximum DCDC output current
|
||||
#define LOAD_CURRENT_MAX 10 // PCB maximum load switch current
|
||||
|
||||
#define LOW_SIDE_VOLTAGE_MAX 16 // Maximum voltage at battery port (V)
|
||||
#define HIGH_SIDE_VOLTAGE_MAX 55 // Maximum voltage at PV input port (V)
|
||||
|
||||
#define PIN_UEXT_TX PA_2
|
||||
#define PIN_UEXT_RX PA_3
|
||||
#define PIN_UEXT_SCL PB_6
|
||||
|
||||
@@ -29,6 +29,9 @@
|
||||
#define DCDC_CURRENT_MAX 10 // PCB maximum DCDC output current
|
||||
#define LOAD_CURRENT_MAX 10 // PCB maximum load switch current
|
||||
|
||||
#define LOW_SIDE_VOLTAGE_MAX 16 // Maximum voltage at battery port (V)
|
||||
#define HIGH_SIDE_VOLTAGE_MAX 55 // Maximum voltage at PV input port (V)
|
||||
|
||||
#define PIN_UEXT_TX PA_2
|
||||
#define PIN_UEXT_RX PA_3
|
||||
#define PIN_UEXT_SCL PB_6
|
||||
|
||||
@@ -29,6 +29,9 @@
|
||||
#define DCDC_CURRENT_MAX 10 // PCB maximum DCDC output current
|
||||
#define LOAD_CURRENT_MAX 10 // PCB maximum load switch current
|
||||
|
||||
#define LOW_SIDE_VOLTAGE_MAX 16 // Maximum voltage at battery port (V)
|
||||
#define HIGH_SIDE_VOLTAGE_MAX 55 // Maximum voltage at PV input port (V)
|
||||
|
||||
#define PIN_UEXT_TX PA_2
|
||||
#define PIN_UEXT_RX PA_3
|
||||
#define PIN_UEXT_SCL PB_6
|
||||
|
||||
@@ -29,6 +29,9 @@
|
||||
#define DCDC_CURRENT_MAX 20 // PCB maximum DCDC output current
|
||||
#define LOAD_CURRENT_MAX 20 // PCB maximum load switch current
|
||||
|
||||
#define LOW_SIDE_VOLTAGE_MAX 32 // Maximum voltage at battery port (V)
|
||||
#define HIGH_SIDE_VOLTAGE_MAX 55 // Maximum voltage at PV input port (V)
|
||||
|
||||
#define PIN_UEXT_DIS PC_14 // starting from rev. 0.10
|
||||
#define PIN_UEXT_TX PA_2
|
||||
#define PIN_UEXT_RX PA_3
|
||||
@@ -60,6 +63,7 @@
|
||||
#define PIN_EEPROM_SDA PB_11
|
||||
|
||||
#define EEPROM_24AA32
|
||||
#define HAS_CAN 1
|
||||
|
||||
enum pin_state_t { PIN_HIGH, PIN_LOW, PIN_FLOAT };
|
||||
|
||||
@@ -120,10 +124,4 @@ enum {
|
||||
ADC_CHSELR_CHSEL17 \
|
||||
)
|
||||
|
||||
// defines for CAN BUS SUPPORT
|
||||
#define HAS_CAN 1
|
||||
#define PIN_CAN_RX PB_8
|
||||
#define PIN_CAN_TX PB_9
|
||||
#define PIN_CAN_STB PA_15
|
||||
|
||||
#endif
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
#define DCDC_CURRENT_MAX 20 // PCB maximum DCDC output current
|
||||
#define LOAD_CURRENT_MAX 20 // PCB maximum load switch current
|
||||
|
||||
#define LOW_SIDE_VOLTAGE_MAX 32 // Maximum voltage at battery port (V)
|
||||
#define HIGH_SIDE_VOLTAGE_MAX 55 // Maximum voltage at PV input port (V)
|
||||
|
||||
#define PIN_UEXT_TX 0
|
||||
#define PIN_UEXT_RX 0
|
||||
#define PIN_UEXT_SCL 0
|
||||
|
||||
@@ -29,6 +29,9 @@
|
||||
#define DCDC_CURRENT_MAX 20 // PCB maximum DCDC output current
|
||||
#define LOAD_CURRENT_MAX 20 // PCB maximum load switch current
|
||||
|
||||
#define LOW_SIDE_VOLTAGE_MAX 30 // Maximum voltage at battery port (V)
|
||||
#define HIGH_SIDE_VOLTAGE_MAX 55 // Maximum voltage at PV input port (V)
|
||||
|
||||
#define PIN_UEXT_TX PA_2
|
||||
#define PIN_UEXT_RX PA_3
|
||||
#define PIN_UEXT_SCL PB_6
|
||||
|
||||
@@ -29,6 +29,9 @@
|
||||
#define DCDC_CURRENT_MAX 20 // PCB maximum DCDC output current
|
||||
#define LOAD_CURRENT_MAX 20 // PCB maximum load switch current
|
||||
|
||||
#define LOW_SIDE_VOLTAGE_MAX 30 // Maximum voltage at battery port (V)
|
||||
#define HIGH_SIDE_VOLTAGE_MAX 55 // Maximum voltage at PV input port (V)
|
||||
|
||||
#define PIN_UEXT_TX PA_2
|
||||
#define PIN_UEXT_RX PA_3
|
||||
#define PIN_UEXT_SCL PB_6
|
||||
|
||||
Reference in New Issue
Block a user