Skip to content

Commit 870a055

Browse files
committed
set inverter currernt to 0 when rebooting batteries
1 parent 8af6f3e commit 870a055

3 files changed

Lines changed: 19 additions & 5 deletions

File tree

packs/Nissan/LeafMultiPack.cpp

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ LeafMultiPack::LeafMultiPack(
4545
m_shutdown_callback_count(0),
4646
m_fully_charged(true),
4747
m_fully_discharged(true),
48-
m_display_shutdown_status(true)
48+
m_display_shutdown_status(true),
49+
m_zero_current_count(0)
4950
{
5051
m_timer.registerPeriodicCallback(&m_periodic_callback, CALLBACK_PERIOD_ms, "LeafMultiPackPeriodic");
5152
if (m_log) m_log->info("LeafMultiPack: status set to STARTUP");
@@ -159,6 +160,15 @@ void LeafMultiPack::periodicCallback()
159160
}
160161
}
161162

163+
if (m_zero_current_count > 0)
164+
{
165+
m_zero_current_count--;
166+
std::ostringstream ss;
167+
ss << "LeafMultiPack: current set to 0 for " << m_zero_current_count << " more callbacks";
168+
if (m_log) m_log->info(ss);
169+
}
170+
171+
162172
m_start_button_state = m_start_button.get();
163173
if (m_start_button_state != m_prev_sb_state)
164174
{
@@ -343,14 +353,16 @@ float LeafMultiPack::getMinDischargeVoltage() const
343353

344354
float LeafMultiPack::getChargeCurrentLimit() const
345355
{
346-
// if shutting down return 0
347-
if (getPackStatus() == Monitor::SHUTTING_DOWN) return 0.0;
356+
// if shutting down or in zero state return 0
357+
if (getPackStatus() == Monitor::SHUTTING_DOWN || (m_zero_current_count > 0)) return 0.0;
348358

349359
// if full, no charging allowed
350360
if (m_fully_charged) return 0.0;
351361

352362
// THIS IS A STOP GAP. NEED TO FIGURE OUT WHY THIS WAS REPORTING HIGH CCL (>40A) TO INVERTER
353363
// DISPITE LEAF BATTERIES REPORTING <2A EACH FOR CCL
364+
// I believe this was being caused by faulty current smoothing code in LeafMonitor.cpp
365+
// Code has been changed (in previous version) but leaving this here for now
354366
const float CRITICALLY_HIGH_VOLTAGE(4.15);
355367
const float WARN_HIGH_VOLTAGE(4.1);
356368
if (getMaxCellVolts() >= WARN_HIGH_VOLTAGE + 0.01)
@@ -389,7 +401,7 @@ float LeafMultiPack::getChargeCurrentLimit() const
389401
float LeafMultiPack::getDischargeCurrentLimit() const
390402
{
391403
// if shutting down return 0
392-
if (getPackStatus() == Monitor::SHUTTING_DOWN) return 0.0;
404+
if (getPackStatus() == Monitor::SHUTTING_DOWN || (m_zero_current_count > 0)) return 0.0;
393405

394406
// if empty, no discharging allowed
395407
if (m_fully_discharged) return 0.0;
@@ -570,6 +582,7 @@ void LeafMultiPack::setTriggerBatReboot()
570582
// 1,2,3 are on the same power relay, 4,5 are on the same power relay
571583
m_vmonitor[0]->setTriggerBatReboot();
572584
m_vmonitor[3]->setTriggerBatReboot();
585+
m_zero_current_count = 15;
573586
}
574587

575588
bool LeafMultiPack::getTriggerBatReboot()

packs/Nissan/LeafMultiPack.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ class LeafMultiPack: public monitor::Monitor
111111
const uint CALLBACK_PERIOD_ms = 1000;
112112
const uint MAX_STARTUP_COUNT = 5 * 60; // number of callback periods
113113
const uint SHUTTING_DOWN_COUNT = 10; // number of callback periods
114+
uint m_zero_current_count;
114115

115116
};
116117

testcan.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include <fstream>
88
#include <vector>
99

10-
#define VERSION_NUMBER "0003"
10+
#define VERSION_NUMBER "0005"
1111
#include "packs/Nissan/LeafPack.hpp"
1212
#include "packs/Nissan/LeafMultiPack.hpp"
1313
// #include "can/services/SMA/MessageFactory.hpp"

0 commit comments

Comments
 (0)