From 667e89d8f4ce51f5f1867fe2f3a4db4d41fd56ee Mon Sep 17 00:00:00 2001 From: 2Fblob <164585100+2Fblob@users.noreply.github.com> Date: Tue, 16 Jul 2024 20:47:14 +0100 Subject: [PATCH] Update drv_bl_shared.c Added output to AC coupled battery charging / discharging Inverter: 192.168.5.23 Charger 1: 192.168.5.22 Charger 2: 192.168.5.24 --- src/driver/drv_bl_shared.c | 58 +++++++++++++++++++++++++++----------- 1 file changed, 41 insertions(+), 17 deletions(-) diff --git a/src/driver/drv_bl_shared.c b/src/driver/drv_bl_shared.c index e6b91005c..7df69d5f2 100644 --- a/src/driver/drv_bl_shared.c +++ b/src/driver/drv_bl_shared.c @@ -53,7 +53,7 @@ static byte old_time = 0; #define bypass_off_time 18 #define min_daily_time_on 120 // Runs the diversion load up to this specified ammount of time, if there wasn't enough sun over the day. int time_on = 0; // Variable to count how long the Bypass load ran during the day -int dump_load_relay = 3; // Variable to Indicate on the Webpage if the Bypass load is on +int dump_load_relay = 0; // Variable to Indicate on the Webpage if the Bypass load is on int lastsync = 0; // Variable to run the bypass relay loop. It's used to take note of the last time it run byte check_time = 0; // Variable for Minutes byte check_hour = 0; // Variable for Hour @@ -304,9 +304,11 @@ void BL09XX_AppendInformationToHTTPIndexPage(http_request_t *request) hprintf255(request, "Diversion relay total on-time today was %d min.
Next sync in %d min. ", time_on, (dump_load_hysteresis-lastsync)); // Print Status of relay) - if (dump_load_relay == 1){poststr(request," ON - Solar Power
");} - else if (dump_load_relay == 2) {poststr(request," ON - Timer
");} - else if (dump_load_relay == 3) {poststr(request," OFF
");} + if (dump_load_relay == 0){poststr(request,"Data not available yet
");} + else if (dump_load_relay == 1){poststr(request," Solar Power
");} + else if (dump_load_relay == 2){poststr(request," Solar Power - Charging
");} + else if (dump_load_relay == 3){poststr(request," Solar Power - Fast Charging
");} + else if (dump_load_relay == 4){poststr(request," AC Grid & Battery Storage
");} else {poststr(request," OFF - Temporary bypass (High AC load or other Fault)
");} //---------------------- hprintf255(request," Last NetMetering reset occured at: %d:%d
", time_hour_reset, time_min_reset); // Save the value at which the counter was synchronized @@ -762,22 +764,44 @@ void BL_ProcessUpdate(float voltage, float current, float power, // Are we exporting enough? If so, turn the relay on //if (((int)net_energy>(int)dump_load_on)) - if (estimated_production_hour>max_export) - { + + //------------------------------------------------------------------------------ + + + // Are we Exporting? + if ((int)net_energy<-50) + { + // Turn Off Battery Inverter + CMD_ExecuteCommand("SendGet http://192.168.5.23/cm?cmnd=Power%20off", 0); dump_load_relay = 1; - time_on += dump_load_hysteresis; // Increase the timer. - //CMD_ExecuteCommand("SendGet http://192.168.5.20/cm?cmnd=Power%20on", 0); - } - /*else if ((check_hour >= bypass_on_time) && (check_hour < bypass_off_time) && (time_on < min_daily_time_on)) - { + } + // Are we exporting above 200W? + else if ((int)net_energy<-200) + { + // Turn on Battery Charger + CMD_ExecuteCommand("SendGet http://192.168.5.22/cm?cmnd=Power%20on", 0); dump_load_relay = 2; - }*/ - else /*if (estimated_production_hour>max_export)*/ - //else if (((int)net_energy<(int)dump_load_off)) - { - // If none of the exemptions applies, we turn the diversion load off. + + } + // Are we exporting above 600W? + else if ((int)net_energy<-600) + { + // Turn on second Battery Charger + CMD_ExecuteCommand("SendGet http://192.168.5.24/cm?cmnd=Power%20on", 0); dump_load_relay = 3; - } + } + + // Are we consuming more than 200W? + else if ((int)net_energy>50) + { + // Turn off Charger(s) - We are consuming + CMD_ExecuteCommand("SendGet http://192.168.5.22/cm?cmnd=Power%20off", 0); + CMD_ExecuteCommand("SendGet http://192.168.5.24/cm?cmnd=Power%20off", 0); + // Turn on Battery Inverter to supply load + CMD_ExecuteCommand("SendGet http://192.168.5.23/cm?cmnd=Power%20on", 0); + dump_load_relay = 4; + + } } //-------------------------------------------------------------------------------------------------------------------------------------------------