Yet another step towards DIY signal generator’s design finish line. This time it is a battery charging circuit based on a Texas Instruments BQ24295 chip. In previous parts I have mentioned that the generator needs to be powered from a battery. So, this circuit is going to be the one responsible for making it possible.
Links to project’s all posts
- VCA822 Gain Amplifier Circuit
- LM7171 Offset Circuit
- Gain and Offset Control Filter Circuit
- Dual 5V Power Supply
- Dual 12V TPS65131 Power Supply
- Battery Charging Circuit with BQ24295 (this post)
- Basic WEB Interface
- IPS Capacitive LCD on an ESP32
- IPS LCD, ESP32 with eSPI library and Touch screen
- Final PCB Design for the DIY Waveform Generator
- Custom Design PCBs and How To Get Them Manufactured
- Soldering the PCB
- AD9833 Library and Further Output Noise Reduction
- Arduino BQ24295 Battery Charger Library
- LCD GUI with LVGL on ESP-32
- 3D Printed Enclosure
- Finished DIY generator
The chip is not a simple Li-Ion battery charger. It has two functions which makes it more advanced solution. First of all, the BQ24295 has D+ and D- pins which need to be connected to a USB connector’s data pins. This allows it to set maximum allowed current to be drawn from a connected host. If the host is an USB hub on a laptop – the current is limited to 500mA, if the host is a power adapter – the IC can charge battery with up to 3A of current. Secondly, the parameters of this IC can be set trough I2C connection from an external MCU. Which is great thing when you want to dynamically change some parameters or just to read status register values.
Two things to note, before going further. Firstly, this IC does not have any internal register which could show you current battery voltage. So, if I want to know at what percentage of its capacity the battery is charged, I will need to measure it externally (e.g. from an MCU ADC). Eternal circuit might draw additional current from the battery which might not be very convenient solution. Second thing – I haven’t tested the IC thoroughly, but it seems that it always sets maximum drawing current to 500mA when it is connected to a PC’s USB port. Although some PC ports are marked as charging ports which should allow to draw higher currents (it is a fact, as for e.g. smartphone charges with higher currents than the BQ24295).
Whole circuit is more or less taken from the chip’s datasheet. Main additions are USB Type-C connector and a 3.3 V regulator. The Type-C connector was used because we all are living in 21st century and because “why not”? Well, and final reason is because Type-C connector is small enough and it is also sturdier than for example micro USB connector. The 3.3V regulator was added to simplify powering up an external MCU. Also, it should be noted that on J15 connection, which is labeled as “system” outputs 3.5 – 4.2V, so it is not suitable for the MCU which requires 3 – 3.3V.
The BQ24295 can also supply 5V (up to 1.5A) to external USB powered devices trough PMID pin. In this case it will work like a power bank, but for a generator it won’t be used.
Some parts were used with different values than they are shown in the schematic. R3, R4 and R6 were chosen 9.2kΩ as the values doesn’t really matter because the resistors are used as pull-ups for I2C and Interrupt pins. CE connection was directly soldered to ground – when pulled low, it enables the battery charging. R5 was chosen 240Ω which should set maximum allowed current to more than 1.5A. also, it should be noted, that the IC sets maximum current either from the R5 resistor or from a registry value – whichever is lower. Finally, C1 was used with a 10uF value instead of a 20uF, but as it will not be used – the value really doesn’t matter.
Actually, there is not much to write about the PCB. The IC is in VQFN package which is hard to hand solder, but it is manageable with hot air soldering gun. On the other hand, the whole circuit takes not much PCB space – which is good thing for a battery-operated device. From the photos you might wonder that the PCB is still quite large, but in reality, a lot of space is taken by soldering pads for external wires.
The PCB has a green LED which turns on when battery is being charged. If you disconnect the battery from the PCB – the green LED starts to blink. When the battery finishes charging the LED turns off. This indication is good for testing purposes, but in final device I will remove it, because external MCU could read the state from an internal register.
As I have mentioned earlier, the charging IC can distinguish different hosts. Although it kinda works, but whenever it is connected to a PC USB port it maximally draws 500mA. Somehow it doesn’t matter if the PC port could supply higher current or not – the BQ24259 will still draw up to 0.5A. Maybe it is because I haven’t played around with the internal registers enough, or it might be because the IC is designed to behave in this way. In either way it will take additional testing after which I will conclude my findings.
So, this post concludes yet another hardware circuit which is going to be used in a final DIY generator’s design. Although it potentially has a problem with not drawing more than 500mA from PC’s USB port (even if the port allows it), it is still a great solution which will never damage PC’s USB port while still allowing to charge a battery rapidly from a wall adapter.
What is left now, is to decide which MCU will be used (it will probably be an ESP32), what kind of display to use and how the user should interact with the device (either through physical buttons or a touch interface), and of course to write all firmware/GUI and additional libraries 😀 … and design final PCB… and manufacture the PCB… solder it… test it… Well OK, there are still a lot of things to take care of, which I will definitely write about in future posts.