Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions vehicle/OVMS.V3/components/vehicle_smarteq/docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ xsq.v.reset.speed Average trip speed (reset) [km/h]
xsq.v.start.time Time since start [hh:mm]
xsq.v.start.distance Trip distance since start [km]
xsq.adc.factor Current ADC factor for 12V calculation [float]
xsq.adc.factor.history Last calculated ADC factors (ring buffer) - persistent
xsq.adc.factor.history Last calculated ADC factors (ring buffer)
xsq.poll.state Current poll state (OFF/ON/RUNNING/CHARGING)
xsq.ed4.values ED4scan: number of cells to show
xsq.ddt4all.canbyte DDT4all CAN response bytes [hex string]
Expand Down Expand Up @@ -210,7 +210,7 @@ xsq.obl.misc OBL miscellaneous data vector: [0]=freq(H
xsq.obl.leakdiag OBL leakage diagnostic status
xsq.bms.prod.data BMS production data formatted (serial, MM/YYYY)
xsq.bms.temps BMS temperature sensors vector [°C]
xsq.bms.voltages BMS voltage values vector: [0]=cell_min(V), [1]=cell_max(V), [2]=cell_mean(V), [3]=link_volt(V), [4]=pack_volt(V), [5]=ocv_volt(V), [6]=12v_system(V)
xsq.bms.voltages BMS voltage values vector: [0]=cell_min(V), [1]=cell_max(V), [2]=cell_mean(V), [3]=cell_sum(V), [4]=pack_volt(V), [5]=traction_link_volt(V), [6]=12v_bms_clamp30(V), [7]=Open Circuit 12V(V)
xsq.bms.contactor.cycles HV contactor cycles vector: [0]=max, [1]=now, [2]=consumed, [3]=diff, [4]=1h_count - persistent
xsq.bms.soc.values SOC values vector [0]=kernel, [1]=real, [2]=min, [3]=max, [4]=display [%]
xsq.bms.soc.recal.state SOC recalibration state
Expand All @@ -234,8 +234,7 @@ xsq.bms.id.sw.version BMS Software Version (SoftwareNumber hex)
xsq.bms.id.basic.parts BMS BasicPartList (PN/HW/Approval hex)
xsq.bms.id.mfr BMS Manufacturer Identification Code
xsq.12v.trickle.count 12V trickle charge counted in 24h, reset to 0 after 24h. Alert if count == 3 in 24h [count] - persistent
xsq.12v.undervolt.history 12V undervoltage history [<timestamp>=<12V>]
xsq.12v.undervolt.history.vec 12V undervoltage history vector (<12V>) - persistent
xsq.12v.undervolt.history 12V undervoltage history vector (<12V>)
=========================== ==============

-------------------------
Expand Down
15 changes: 8 additions & 7 deletions vehicle/OVMS.V3/components/vehicle_smarteq/src/eq_can_poll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ void OvmsVehicleSmartEQ::PollReply_BMS_SOC(const char* data, uint16_t reply_len)
ocv = 0.0f;
if(cap_loss < 0.0f || cap_loss > 100.0f)
cap_loss = 0.0f;
mt_bms_voltages->SetElemValue(5, ocv); // ocv_voltage
mt_bms_voltages->SetElemValue(7, ocv); // ocv_voltage
mt_bms_soc_values->SetElemValue(0, soc); // kernel SOC
mt_bms_soc_values->SetElemValue(1, (real_soc_min + real_soc_max) / 2.0f); // real SOC
mt_bms_soc_values->SetElemValue(2, real_soc_min); // SOC min
Expand Down Expand Up @@ -692,11 +692,10 @@ void OvmsVehicleSmartEQ::PollReply_BMS_BattState(const char* data, uint16_t repl

mt_bms_voltages->SetElemValue(0, v_cell_min); // cv_min
mt_bms_voltages->SetElemValue(1, v_cell_max); // cv_max
mt_bms_voltages->SetElemValue(2, (v_cell_min + v_cell_max) / 2.0f); // cv_mean

mt_bms_voltages->SetElemValue(3, v_link); // link
mt_bms_voltages->SetElemValue(2, (v_cell_min + v_cell_max) / 2.0f); // cv_mean
mt_bms_voltages->SetElemValue(3, cv_sum_raw); // cv_sum (HV)
mt_bms_voltages->SetElemValue(4, v_pack_term); // contactor
mt_bms_voltages->SetElemValue(5, cv_sum_raw); // cv_sum (HV)
mt_bms_voltages->SetElemValue(5, v_link); // traction link 12V

// P = V × I (in kW)
float pack_power_kw = (v_pack_term * i_pack) / 1000.0f;
Expand Down Expand Up @@ -813,10 +812,12 @@ void OvmsVehicleSmartEQ::PollReply_BCM_TPMS_InputCapt(const char* data, uint16_t
{
// Pressure: big-endian 16 bit *0.75 kPa
uint16_t praw = CAN_UINT(8 + (i*2));
m_tpms_pressure[i] = (float)praw != 0xffff ? (float)praw * 0.75f : 0.0f;
if (praw != 0xffff)
m_tpms_pressure[i] = (float)praw * 0.75f; // only valid values, 0xffff = invalid
// Temperature: raw byte + offset -30.0
uint16_t traw = (uint16_t)(uint8_t)CAN_BYTE(16 + i);
m_tpms_temperature[i] = traw != 0xffff ? (float)traw - 30.0f : 0.0f;
if (traw != 0xffff)
m_tpms_temperature[i] = (float)traw - 30.0f; // only valid values, 0xffff = invalid
m_tpms_lowbatt[i] = static_cast<bool>((raw >> i) & 0x01);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,9 @@ OvmsVehicle::vehicle_command_t OvmsVehicleSmartEQ::CommandPreset(int verbosity,
"obdii_7e4",
"obdii_7e4_modify",
"basic_tpms",
"calc.adcfactor.samples"
"calc.adcfactor.samples",
"cell_interval_drv",
"cell_interval_chg",
};

int removed_count = 0;
Expand Down
56 changes: 16 additions & 40 deletions vehicle/OVMS.V3/components/vehicle_smarteq/src/eq_features.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,9 @@ void OvmsVehicleSmartEQ::ReCalcADCfactor(float can12V, OvmsWriter* writer) {
MyConfig.SetParamValueBool("xsq", "calc.adcfactor", false);
}
if (writer) writer->printf("New ADC factor stored: %.3f (prev %.3f, history size %u)\n", adc_factor_new, adc_factor_prev, (unsigned)n);
// Send data log XSQ-ADC-FactorLog
// V1: <new factor>,<prev factor>
MyNotify.NotifyStringf("data", "xsq.adc.log.factor", "XSQ-ADC-FactorLog,1,%d,%.3f,%.3f", 86400 * 30, adc_factor_new, adc_factor_prev);
#else
ESP_LOGD(TAG, "ADC support not enabled");
if (writer) writer->puts("ADC support not enabled");
Expand Down Expand Up @@ -318,48 +321,21 @@ void OvmsVehicleSmartEQ::DoorOpenState() {

void OvmsVehicleSmartEQ::smart12VHistory()
{
// On first call after reboot: restore previous entries from persistent vec metric
if (m_12v_undervolt_history.empty())
{
size_t vn = mt_12v_undervolt_history_vec->GetSize();
for (size_t i = 0; i < vn && i < 10; ++i)
{
float v = mt_12v_undervolt_history_vec->GetElemValue(i);
if (v > 0.0f)
{
char entry[16];
snprintf(entry, sizeof(entry), "reboot=%.2fV", v);
m_12v_undervolt_history.push_back(entry);
}
}
}
float volt = StdMetrics.ms_v_bat_12v_voltage->AsFloat(0.0f);
time_t ts = (time_t)StdMetrics.ms_m_timeutc->AsInt();
if (ts < 86400) // UTC not yet synced (still at/near 1970-01-01)
{
ESP_LOGD(TAG, "smart12VHistory: UTC time not synced, skipping entry");
m_12v_alerted = false;
return;
}
struct tm t;
localtime_r(&ts, &t);
char buf[32];
strftime(buf, sizeof(buf)-8, "%Y-%m-%dT%H:%M:%S", &t);
snprintf(buf + 19, sizeof(buf) - 19, "=%.2fV", volt);
m_12v_undervolt_history.push_back(buf);
float volt = StdMetrics.ms_v_bat_12v_voltage->AsFloat(0.0f);
float bms12v = mt_bms_voltages->GetElemValue(6); // 12V BMS clamp 30
float usm12v = mt_evc_dcdc->GetElemValue(3); // 12V USM voltage
m_12v_undervolt_history.push_back(volt);
if (m_12v_undervolt_history.size() > 10)
m_12v_undervolt_history.pop_front();
std::string hist_str;
float hist_vec[10];
float hist[10];
size_t n = m_12v_undervolt_history.size();
for (size_t i=0; i<n; ++i)
{
if (i > 0) hist_str += '|';
hist_str += m_12v_undervolt_history[i];
hist_vec[i] = atof(strchr(m_12v_undervolt_history[i].c_str(), '=') + 1);
}
mt_12v_undervolt_history->SetValue(hist_str);
mt_12v_undervolt_history_vec->SetElemValues(0, n, hist_vec);
for (size_t i = 0; i < n; ++i)
hist[i] = m_12v_undervolt_history[i];
if (n > 0)
mt_12v_undervolt_history->SetElemValues(0, n, hist);
// Send data log XSQ-12V-undervoltagelog
// V1: <12Vvoltage>,<USM12V>,<BMS12V>
MyNotify.NotifyStringf("data", "xsq.12v.log.undervoltage", "XSQ-12V-undervoltagelog,1,%d,%.2f,%.2f,%.2f", 86400 * 30, volt, usm12v, bms12v);
}

void OvmsVehicleSmartEQ::smartOn()
Expand Down Expand Up @@ -416,7 +392,7 @@ void OvmsVehicleSmartEQ::smartSleep()

void OvmsVehicleSmartEQ::smartChargeStart()
{
smartCoolDownPolling(20);
smartCoolDownPolling(15);
if (m_charge_finished)
{
ResetChargingValues();
Expand Down
12 changes: 2 additions & 10 deletions vehicle/OVMS.V3/components/vehicle_smarteq/src/eq_handle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,8 @@ void OvmsVehicleSmartEQ::HandleOBDpolling() {
if (m_obdii_745_tpms && IsOnEQ()) // full TPMS mode with individual pressure/temp/alert status for each wheel
m_poll_vector.insert(m_poll_vector.end(), obdii_745_tpms_polls, endof_array(obdii_745_tpms_polls));

if (m_obdii_79b_cell) // 79b PIDs cell V/R/T values with configurable intervals
{
for (const auto& p79bcell : obdii_79b_cell_vrt_polls)
{
OvmsPoller::poll_pid_t p79bcell_mod = p79bcell;
p79bcell_mod.polltime[2] = m_cfg_cell_interval_drv;
p79bcell_mod.polltime[3] = m_cfg_cell_interval_chg;
m_poll_vector.push_back(p79bcell_mod);
}
}
if (m_obdii_79b_cell) // 79b PIDs cell V/R/T values
m_poll_vector.insert(m_poll_vector.end(), obdii_79b_cell_vrt_polls, endof_array(obdii_79b_cell_vrt_polls));

if (m_obdii_7e4_dcdc) // 7e4 PIDs DCDC
m_poll_vector.insert(m_poll_vector.end(), obdii_7e4_dcdc_polls, endof_array(obdii_7e4_dcdc_polls));
Expand Down
7 changes: 4 additions & 3 deletions vehicle/OVMS.V3/components/vehicle_smarteq/src/eq_notify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,14 +253,14 @@ OvmsVehicle::vehicle_command_t OvmsVehicleSmartEQ::CommandED4scan(int verbosity,
writer->printf(" Manufacturer ID: %s\n", mt_bms_mfr_id->AsString().c_str());

writer->puts("\n--- SOC Kernel Data (PID 0x08) ---");
writer->printf(" Open Circuit Voltage: %.2f V\n", mt_bms_voltages->GetElemValue(5));
writer->printf(" Real SOC (Min): %.2f%%\n", mt_bms_soc_values->GetElemValue(2));
writer->printf(" Real SOC (Max): %.2f%%\n", mt_bms_soc_values->GetElemValue(3));
writer->printf(" Kernel SOC: %.2f%%\n", mt_bms_soc_values->GetElemValue(0));
writer->printf(" Capacity Loss: %.2f%%\n", mt_bms_cap->GetElemValue(3));
writer->printf(" Initial Capacity: %.2f Ah\n", mt_bms_cap->GetElemValue(1));
writer->printf(" Estimated Capacity: %.2f Ah\n", mt_bms_cap->GetElemValue(2));
writer->printf(" Voltage State: %s\n", mt_bms_voltage_state->AsString().c_str());
writer->printf(" Open Circuit 12V: %.2f V\n", mt_bms_voltages->GetElemValue(7));

writer->puts("\n--- SOC Recalibration (PID 0x25) ---");
writer->printf(" Recalibration State: %s\n", mt_bms_soc_recal_state->AsString().c_str());
Expand All @@ -270,13 +270,14 @@ OvmsVehicle::vehicle_command_t OvmsVehicleSmartEQ::CommandED4scan(int verbosity,
writer->puts("\n--- Battery State (PID 0x07) ---");
writer->printf(" Cell Voltage Min: %.3f V\n", mt_bms_voltages->GetElemValue(0));
writer->printf(" Cell Voltage Max: %.3f V\n", mt_bms_voltages->GetElemValue(1));
writer->printf(" Cell Voltage Mean: %.3f V\n", mt_bms_voltages->GetElemValue(2));
writer->printf(" Link Voltage: %.2f V\n", mt_bms_voltages->GetElemValue(3));
writer->printf(" Cell Voltage Mean: %.3f V\n", mt_bms_voltages->GetElemValue(2));
writer->printf(" Cell Voltage sum: %.2f V\n", mt_bms_voltages->GetElemValue(3));
writer->printf(" Pack Voltage: %.2f V\n", mt_bms_voltages->GetElemValue(4));
writer->printf(" Pack Current: %.2f A\n", StdMetrics.ms_v_bat_current->AsFloat());
writer->printf(" Pack Power: %.2f kW\n", StdMetrics.ms_v_bat_power->AsFloat());
writer->printf(" Contactor State: %s\n", mt_bms_HVcontactStateTXT->AsString().c_str());
writer->printf(" Vehicle Mode: %s\n", mt_bms_EVmode_txt->AsString().c_str());
writer->printf(" Traction Link Voltage: %.2f V\n", mt_bms_voltages->GetElemValue(5));
writer->printf(" BMS 12V Voltage: %.2f V\n", mt_bms_voltages->GetElemValue(6));

writer->puts("\n--- EVC Data (0x7EC) ---");
Expand Down
Loading