### LTSpice - Rechargeable Battery Simulation #### Reference Circuit Based on the following schematic from [Sam Ben-Yaakov's video](https://youtu.be/KL6Uim7spcE): ![[LiPo Battery SPICE Model.png]] Starting with the VCCS that charges a capacitor to 100V: ![[Pasted image 20250129073503.png]] Next, the VCVS that takes reads the capacitor voltage (0-100) and puts out a cell voltage (2.7-4.4) #### Mapping SoC to Cell Voltage | SoC % | Cell Voltage | | ----- | ------------ | | 3.90 | 2.73 | | 9.26 | 2.98 | | 12.68 | 3.11 | | 31.70 | 3.22 | | 67.80 | 3.41 | | 81.95 | 3.45 | | 88.78 | 3.70 | | 93.17 | 4.08 | | 95.60 | 4.40 | Using Wolfram Alpha to map them to a quintic: ``` 8.00709×10^-9 x^5 - 1.84185×10^-6 x^4 + 0.000156186 x^3 - 0.00604528 x^2 + 0.112123 x + 2.37013 ``` Pulling a quintic function from another LTSpice model I found to clone the syntax: ``` Vbatt=(-8.0128*pwr(V(vsoc),5) + 22.509*pwr(V(vsoc),4) - 19.929*pwr(V(vsoc),3) + 4.332*pwr(V(vsoc),2) + 2.0965*V(vsoc) + 0.0026) ``` **LTSpice Quintic Function** This can be pasted into a BV component. It references node `vsoc`. ``` Vbatt=(8.00709e-9*pwr(V(vsoc),5) - 1.84185e-6*pwr(V(vsoc),4) + 0.000156186*pwr(V(vsoc),3) - 0.00604528*pwr(V(vsoc),2) + 0.112123*V(vsoc) + 2.37013) ``` Added a point at (100, 4.5) since it was going to 5.5-6.0 around 100, which is simply too high. Final LTSpice Quintic: ``` V=(2.44544e-9*pwr(V(vsoc),5) - 6.00106e-7*pwr(V(vsoc),4) + 0.000060708*pwr(V(vsoc),3) - 0.00307689*pwr(V(vsoc),2) + 0.0774173*V(vsoc) + 2.48387) ``` This is looking more like a battery now. ![[Pasted image 20250129080236.png]] Annoyingly, there seems to be no way to break up long Spice commands. Line breaks break it into separate statements. #### Final Circuit ![[Pasted image 20250129084303.png]] This is an simple and effective model for a rechargeable battery. X-Axis on the plot is V(vsoc), Y-Axis is V(batt) ![[Pasted image 20250129084135.png]] Mission success! --- ### YouTube Notes #### Model Lithium Ion Battery with LTspice https://youtu.be/2HRr48GR0YE This guy references some whitepapers on Modeling of Li-ion batteries using equivalent circuit diagrams. They're approximate models of the battery as a voltage source that basically decays over ~15k seconds ![[Pasted image 20250129062055.png]] #### A simple simulation model of a rechargeable battery https://youtu.be/KL6Uim7spcE Similar approach, modeling the battery as a capacitor that gets charged by a current source. Where the current source is determined by the sense current measured from a separate circuit. The second circuit is a behavioral voltage source defined by a high order polynomial that matches the general characteristics of a battery charge/discharge curve, along with some series parasitic impedances. In this case, he added clamping diodes to set limits, and showed a way to display State of Charge SoC in PSPICE. He also added an oscillating pulse to show charge/discharge. Battery voltage decreases when loaded and increases when being charged. You can essentially model this as a different series resistance in different directions. ![[LiPo Battery SPICE Model.png]] Current through shunt V2 determines the current going into the capacitor. The capacitor charges to 100V to represent 100% SoC. The behavioral voltage references the table of points, fits a polynomial, and then takes the capacitor voltage (0-100) as an input, and then outputs a battery voltage accordingly (2.7-4.3) The points are (Charge%, Voltage), and represent the curve in the bottom right. The axes of that chart are Battery Voltage vs. State of Charge%, hence (Charge%, Voltage) The battery curves can be reproduced by mapping the battery voltage vs. the capacitor voltage - which is again, (Charge%, Voltage) ![[Pasted image 20250129070408.png]] ##### What is State of Charge? (SoC) - **Characteristic Curves**: For each type of battery, there exists a characteristic OCV versus SoC curve. By measuring the OCV, one can estimate the SoC by comparing it to these characteristic curves. Different battery chemistries will have distinct OCV-SOC profiles. - **Rest Requirement**: Accurate OCV measurements typically require the battery to be in a rested or equilibrium state. Obtaining precise SoC using OCV is challenging during active charge/discharge periods. - **Influence of Temperature**: Temperature changes can affect the relationship between OCV and SoC, requiring compensations in calculations. - **Battery Degradation**: As batteries age, their OCV-SOC characteristics can shift, leading to potential inaccuracies if not calibrated for degradation. Multiple approaches, such as coulomb counting and model-based estimations, integrate these voltage measurements with additional data to provide a more comprehensive and dynamic SoC assessment.