ƒ

Battery SOC EKF

Advanced
Ejecutar el ejemplo en vivo Gratis · sin registro · funciona en tu navegador

El bloque BatterySocEkf implementa un filtro de Kalman extendido (EKF) para estimar el estado de carga (State of Charge, SOC) de una celda de batería a partir de las mediciones de tensión en bornes y corriente de carga. Empleando un circuito equivalente con una o dos ramas RC de polarización, corrige la deriva por integración del conteo de culombios y el retardo por polarización electroquímica, al tiempo que estima el desvío (bias) del sensor de corriente y los límites de incertidumbre estadística (±2σ\pm 2\sigma).

La curva de tensión en circuito abierto (Open-Circuit Voltage, OCV) se define en un editor interactivo tipo hoja de cálculo de 2 columnas (SOC (0–1) y OCV (V)) con una vista previa gráfica en vivo (OCV = f(SOC)), calculada mediante interpolación lineal o splines cúbicos monótonos de Hermite (smooth). Las curvas de hojas de datos pueden importarse y exportarse directamente vía CSV (battery_ocv.csv) o pegarse desde Excel (Ctrl+V). Sus 21 parámetros se organizan en cuatro secciones lógicas: _Estado inicial y muestreo_, _Covarianzas de ruido (Q y R)_, _Modelo de circuito equivalente_ y _Tabla OCV y solucionador_.

Modelo Matemático

x=[SOC, V1, V2, b]T,I=Im−b\mathbf{x} = [\text{SOC},\ V_1,\ V_2,\ b]^T, \quad I = I_m - b

La dinámica de estados en tiempo continuo y la ecuación de tensión en bornes son:

SOC˙=−η I3600 Q,V˙j=−VjRjCj+ICj,b˙=0\dot{\text{SOC}} = -\frac{\eta\, I}{3600\,Q}, \quad \dot{V}_j = -\frac{V_j}{R_j C_j} + \frac{I}{C_j}, \quad \dot{b} = 0
Vterm=OCV(SOC)−V1−V2−R0I,H=[∂ OCV∂ SOC, −1, −1, R0]V_{\text{term}} = \text{OCV}(\text{SOC}) - V_1 - V_2 - R_0 I, \quad \mathbf{H} = \left[\frac{\partial\,\text{OCV}}{\partial\,\text{SOC}},\ -1,\ -1,\ R_0\right]

La extrapolación de covarianza de estados y la corrección de medida iterada siguen la recursión discreta de Kalman:

x^k∣k=x^k∣k−1+Kk(Vmeas−h(x^k∣k−1)),Kk=Pk∣k−1HkT(HkPk∣k−1HkT+R)−1\hat{\mathbf{x}}_{k|k} = \hat{\mathbf{x}}_{k|k-1} + \mathbf{K}_k \left(V_{\text{meas}} - h(\hat{\mathbf{x}}_{k|k-1})\right), \quad \mathbf{K}_k = \mathbf{P}_{k|k-1} \mathbf{H}_k^T (\mathbf{H}_k \mathbf{P}_{k|k-1} \mathbf{H}_k^T + R)^{-1}

Entradas y Salidas

Direction ID Label Tipo Status
→ In in1 I number Required
→ In in2 V number Required
→ In in3 Reset number Optional
→ In in4 Dropout number Optional
← Out soc_hat SOC number Output
← Out soc_sigma σ SOC number Output
← Out v1_hat V₁ number Output
← Out v2_hat V₂ number Output
← Out bias_hat I bias number Output
← Out voc_hat OCV number Output
← Out jacobian dOCV/dSOC number Output
← Out k_gain_0 K_SOC number Output
← Out innovation Innov. number Output
← Out innovation_cov S number Output
← Out nis NIS number Output

Parámetros

Parámetros Label Tipo Por defecto Descripción
sampleTime Sample Time number 1 Filter period in seconds
socInit Initial SOC Estimate number 0.5 Fraction 0…1
v1Init Initial V1 Estimate number 0
pSoc Initial SOC Variance number 0.01 How unsure the initial SOC is; 0.01 is σ = 10 % SOC
pV1 Initial RC Voltage Variance number 0.000001 Per RC branch; small, since a rested cell has V1 ≈ V2 ≈ 0
pBias Initial Bias Variance number 0 How unsure the current sensor's offset is; 0 leaves the offset out of the model, 0.01 is σ = 0.1 A
qSoc Process Noise SOC number 1e-8 Noise density per second, so the filter does not change with the sample time
qV1 Process Noise RC Voltage number 0.000001 Noise density per second, per RC branch
qBias Process Noise Bias number 0 How fast the sensor offset may drift, as a density per second; 0 for a constant offset
rMeas Measurement Noise number 0.0001 Variance of the voltage measurement in V²
r0 R0 (Ω) number 0.05 Ohmic resistance
r1 R1 (Ω) number 0.02 Polarisation resistance of the fast branch
c1 C1 (F) number 1000 Polarisation capacitance of the fast branch
r2 R2 (Ω) number 0 Resistance of a second, slow RC branch; 0 leaves the branch out
c2 C2 (F) number 30000 Capacitance of the second RC branch
capacity Capacity (Ah) number 3.2
chargeEfficiency Charge Efficiency number 1 Coulombic efficiency while charging (current < 0); Li-ion cells are typically 0.99–0.999
ocvSoc OCV Table SOC table 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 SOC breakpoints, ascending
ocvVoltage OCV Table Voltage text 3.00 3.50 3.65 3.72 3.78 3.84 3.90 3.97 4.05 4.14 4.20 Open-circuit voltage at each breakpoint in V
ocvInterpolation OCV Interpolation select linear Linear matches a LookupTable exactly; Smooth (monotone cubic) has no slope jumps at the breakpoints, which steadies the filter's gain
iterations Update Iterations number 1 1 is the classic EKF; 3 relinearises at the corrected estimate (iterated EKF), which helps where the OCV curve bends sharply

Ejemplos de Uso

Ejemplo 1: Inicialización del SOC en celda en reposo

Una celda de litio en reposo a 3.72 V se inicializa con una estimación incierta (socInit=0.6\text{socInit} = 0.6). Al ingresar mediciones de tensión, el EKF converge al valor real de 30% de SOC en menos de 1.5 s, reduciendo σsoc\sigma_{\text{soc}} del 10% a menos del 1%.

Ejemplo 2: Ciclo de conducción dinámico con deriva de sensor de corriente

Durante descargas pulsadas de un vehículo eléctrico, el filtro estima el estado de carga y un desvío constante de 150 mA en el sensor de corriente, impidiendo la divergencia del conteo de culombios.

Observaciones y Buenas Prácticas

  • Hoja de cálculo OCV interactiva e importación/exportación CSV: Emplee 📂 Importar CSV, 💾 Exportar CSV (battery_ocv.csv) o pegado directo (Ctrl+V desde Excel) para cargar mediciones y revisar la curva dinámica OCV = f(SOC).
  • Intervalos de incertidumbre: La salida soc_sigma calcula en tiempo real la desviación estándar del error, permitiendo al sistema BMS determinar intervalos de confianza al 95% (±2σ\pm 2\sigma).
  • Supervisión de consistencia: La innovación cuadrática normalizada (NIS) audita el ajuste del filtro, con una media teórica de 1.0 si las matrices de ruido QQ y RR reflejan el entorno real.
  • Tolerancia a pérdida de sensores: La activación de la entrada opcional Dropout detiene las correcciones por tensión, recurriendo de forma segura al conteo de culombios con aumento proporcional de la covarianza.
  • Robustez no lineal: La interpolación mediante splines cúbicos suaves y las iteraciones locales evitan saltos de covarianza en pendientes acusadas de la curva OCV.

Preguntas Frecuentes (FAQ)

Q: Why is an Extended Kalman Filter (EKF) superior to Coulomb counting for battery SOC?

Pure Coulomb counting (SOC(t)=SOC0−1Qn∫IdtSOC(t) = SOC_0 - \frac{1}{Q_n} \int I dt) irreversibly drifts due to current sensor offsets and unmodeled parasitic reactions. An EKF pairs the Coulomb counting integrator with an Equivalent Circuit Model (ECM, R0+R1∥C1R_0 + R_1 \parallel C_1) and corrects the state estimate at each step using the nonlinear open-circuit voltage relationship Vt=OCV(SOC)−IR0−VRCV_t = OCV(SOC) - I R_0 - V_{RC}. This bounds SOC estimation error within ±2%\pm 2\% across temperature shifts and aging.

Bloques Relacionados

  • KalmanFilter: Filtro de Kalman lineal para estimación de estados en sistemas dinámicos lineales.
  • LookupTable: Tabla de búsqueda unidimensional para modelar no linealidades estáticas.
  • RandomNumber: Generador de ruido gaussiano para simular perturbaciones de sensores y proceso.