Prototyping Coulomb Counting With STM32
This document is in progress as of 11th March, 2023. This tag will be removed when it is completed.
The idea behind this project is to use a microcontroller (STM32 in this case) get us the voltage and current data of a 4.2 V lithium battery in real-time to try our Coulomb Counting algorithm.
Equipment
The equipment you will need to set up this project.
A STM32 Microcontroller (the one used in this prototype is STM32F2027 discovery kit)
A 4.2V Lithium battery (must not be wielded)
A Battery Holder
Some bread boards
Resistances of 20, 100K ohms and such.
An external load (the one used is DL 3031 Rigol)
Some jumper cables, wires and alligator plugs
Instructions
Step-by-step guide of how to build this:
Our first step is designing an STM32 board with a battery charger, a battery connector, and an ADC connection to read the battery’s voltage. Most lithium batteries today have a charge voltage of 4.2V, but most STM32s have a maximum voltage of 3.6V. We need to build a voltage divider such that voltage measured by the ADC is of the verified range, but we cannot use the ADC to read an analog voltage which is higher than the supply voltage.
The voltage divider diagram will be added in some time (I am not a 100% sure of the connections so I will make it next time we go) but we connected the resistors in series and connected the STM32 ADC port (PA1) between the resistors with one end of the resistors having the battery and the other end connected to the load.
The laptop has to be connected to the STM32 and then some code can be used to get access to the voltage reading of the ADC (the code hasn’t been finalized and will be implemented we go next time in the bay).
Related articles
Here are some related links and articles that could help what our plan is and what we are doing.
For the Coulomb Counting procedure check out this article (we will be implementing this in the original prototype):
For the procedure on getting the voltage from lithium battery using ADC check out this article: https://vivonomicon.com/2019/10/15/reading-battery-voltage-with-the-stm32s-adc/