Skip to content

Commit

Permalink
Update drv_bl_shared.c
Browse files Browse the repository at this point in the history
  • Loading branch information
2Fblob authored Sep 9, 2024
1 parent 35c9d39 commit 8c46d1a
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions src/driver/drv_bl_shared.c
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,8 @@ void BL_ProcessUpdate(float voltage, float current, float power,
// Reset
last_minute = current_minute;
// **Check Time Condition**
// New logic to estimate energy
// New logic to estimate energy. We multiply the available power after t = 30minutes
// to accomodate for the shorter timespam available to cunsume the energy
if (current_minute < 30)
{
net_energy_equivalent = ((float)(net_energy*(60/current_minute)));
Expand All @@ -851,28 +852,36 @@ void BL_ProcessUpdate(float voltage, float current, float power,
{
net_energy_equivalent = net_energy*2;
}
if (check_time >= 15 && check_time <= 55 && (check_time % 5 == 0))
if (check_time > 14)
{

// **Dishwasher**
dump_load_relay[2] = (net_energy_equivalent <= -1000 && check_hour >= 10 && check_hour <= 17) ? 1 :
((check_hour < 10 || check_hour > 17 || net_energy > 0) ? 0 : dump_load_relay[2]);


// The chargers wait for the first 15 minutes for power to accumulate. During this time the previous state is maintained.
// **Primary Charger**
dump_load_relay[1] = (net_energy_equivalent <= -400 && check_hour >= 9 && check_hour <= 17) ? 1 :
((check_hour < 9 || check_hour > 17 || net_energy_equivalent >= -100) ? 0 : dump_load_relay[1]);
dump_load_relay[1] = (net_energy_equivalent <= -300 && check_hour >= 9 && check_hour <= 17) ? 1 :
((net_energy >= -100) ? 0 : dump_load_relay[1]);

// **Secondary Charger**
dump_load_relay[3] = (net_energy_equivalent <= -800 && check_hour >= 10 && check_hour <= 15) ? 1 :
((check_hour < 10 || check_hour > 15 || net_energy_equivalent >= -200) ? 0 : dump_load_relay[3]);
dump_load_relay[3] = (net_energy_equivalent <= -500 && check_hour >= 10 && check_hour <= 15) ? 1 :
(( net_energy >= -150) ? 0 : dump_load_relay[3]);

}
/** Basement dehumidifier control **/
if ((check_time >= 20 && check_time <= 58 && net_energy_equivalent <= -1000) && (check_hour >= 9 && check_hour <= 16)) {
// The dehumidifier turns on last at t = 20 minutes, to ensure the power stabilizes as the chargers and dishwasher operate.
// It's ideal power source is unused energy as we approach the end of the hour.
if ((check_time >= 20 && check_time <= 58 && net_energy_equivalent <= -800) && (check_hour >= 9 && check_hour <= 16)) {
dump_load_relay[4] = 1; // Turn on dehumidifier
} else if (check_time == 59 || net_energy_equivalent >= -300) {
} else if (check_time == 59 || net_energ >= -300) {
dump_load_relay[4] = 0; // Turn off dehumidifier
}

/** Dishwasher control **/
// We wait for an estimated 700W to be available and allow up to 300W from grid / battery to facilitate in poor weather
// This ensures it wont go off during hour changes and takes priority over other devices.
if (net_energy_equivalent <= -700) && (check_hour >= 9 && check_hour <= 18)) {
dump_load_relay[4] = 1; // Turn on dishwasher
} else if (net_energy >= 300) {
dump_load_relay[4] = 0; // Turn off dishwasher. We allow up to 300W from grid / battery to facilitate in poor weather
}


for (int output_index = 0; output_index < dump_load_relay_number; output_index++)
Expand Down

0 comments on commit 8c46d1a

Please sign in to comment.