intrologo-lithium-battery-charger

In this project, we are building a programmable single/multi cell lithium battery charger shield for Arduino. The shield provides LCD and button interface which let the user set the battery cut-off voltage from 2V to 10V and charge current from 50mA to 1.1A. The charger also provides the ability to monitor the battery status before and during charge.

The charger is based on LT1510 Constant Current/Constant Voltage Battery charger IC and controlled by Arduino UNO. The display on the shield is Nokia 5110 LCD which is very simple to use and still available on the market. There are two different battery connectors available on the shield, a two contact screw terminal block and a right angle 2mm JST-PH connector.

Circuit Design

The schematic of the project is drawn in SoloCapture, the schematic editor of SoloPCB tools. SoloCapture makes the schematic drawing process very easy and fast. You can download SoloPCB tools at Fabstream.com for FREE.

You can download the SoloPCB design files of the project by using the link below.

Please check out this video to see how to import the project libraries, open and synchronize the schematic and PCB files.

schematic-620-lithium-battery-charger

The lithium battery charger circuit is designed as an Arduino Shield. But the battery charger IC on the board can also work without MCU control. R3 and R4 sets the charge cut-off voltage, R2 ,R24 and C5 adjusts the charge current limit. With those passive component configurations, LT1510 can charge the battery and know when to stop. But we want to build a user programmable charger. So we had to take control of these functions. Anyway, when no code is present on Arduino, the charger has default cut-off voltage of 4.2V and maximum charge current of 1.1A.

component-side-lithium-battery-charger

Pulling VC pin of LT1510 to ground stops charging immediately. The pin 5 of Arduino assigned to drive Q2 Mosfet to stop charging when required. The battery voltage is divided by ten over R7 and R8 resistors and read by the A1 analog input. By using these two features, we can read the battery voltage and stop charging when the battery reaches a pre-determined voltage level.

In LT1510 datasheet, in addition to fixed resistor configuration, controlling the charge current by PWM method is also explained. Pin 6 of Arduino has PWM function and it is used for this purpose. Adjusting the PWM duty cycle easily adjusts the charge current. The current flowing to the battery is sensed by ACS712-5A Hall Effect current sensor IC and the sensor output is read by A0 analog input of Arduino. ACS712-5A outputs 0.185mV per 1A in addition to 2.5V. For example when the battery draws 1A, the sensor outputs 2.685V. To read the current more accurately, the internal voltage reference 1.1V is used so 10 bit ADC reading will fit between 0V and 1.1V at 1024 step resolution.

The maximum sensor output difference will be 1.1A x 0.185V = 0.204V resulting an output of 2.704V. By using the LM258 op-amp, we subtracted 2.5V from the sensor output and multiply the result by 5. This maps the sensor output from 0V (@0A) to 1.02 (@1.1A) which fits nicely between the ADC limits of 0V and 1.1V. There is still 0.1V margin left which is meaningful when considering the op-amp offset voltage and current sensor noise and offset.

5110 LCD display uses SPI interface and requires 3.3V power supply. Since the Arduino I/O pins works at 5V, to protect the LCD module, it is recommendedto connect 10K or 1K resistors in series to the signal lines. The LCD module includes backlight LEDs. Those LEDs are driven by Pin 8 over 330R current limiting resistor.

There are four buttons (up, down, left, right) connected to Pin A2-A5 of Arduino. Those pins are set as inputs and the internal pull up resistors are activated. So simply pulling the pins to ground by using the buttons is enough to detect the button activity.

There are two SMD LEDs on the board reserved for any kind of indication. They are connected to Pin 3 and Pin 4. Those pins are set as outputs. Depending on the LED characteristics, current limiting resistors should be connected in series with the LEDs.

PCB Design

The PCB of the project is designed in SoloPCB. SoloPCB is a pack of powerful tools consisting of schematic capture, PCB layout, and integrated autorouting. You can download SoloPCB tools at Fabstream.com for FREE and start using immediately.

You can download the SoloPCB design files of the project by using the link below.

Please check out this video to see how to import the project libraries, open and synchronize the schematic and PCB files.

PCB-lithium-battery-charger

Since this is an Arduino shield, it should have similar dimensions with Arduino UNO. The expansion headers must be properly positioned. The LCD, buttons, LEDs and the battery connectors are placed on the top layer to make the interface usable. All the other components are placed on the bottom layer.

buttons-and-connectors-lithium-battery-charger

LT1510 requires PCB area which is connected to the GND pins to cool down the IC during operation. And there is a recommended PCB layout in its datasheet which maximizes the noise reduction performance.

Part List

parts-lithium-battery-charger

The Bill of Materials of the Lithium Battery Charger shield is given below.

Quantity Part Description Designator
1 LT1510 Constant Current/Constant Voltage Battery Charger SO-16 U1
1 REF03 2.5V Voltage Reference SO8 U2
1 ACS712-5A Hall Effect Based Current Sensor 8-SOIC U3
1 LM258 Low Noise Operational Amplifier SO-8 U4
1 5110 LCD Module LCD1
2 SS14 1A 40V Schottky Rectifier SMA D1 D2
1 1N4148 General Purpose Diode SOD80C D5
3 BSS138 Mosfet SOT-23 Q1 Q2 Q3
1 Red LED 0805 D3
1 Green LED 0805 D4
1 220nF 50V 0805 X7R SMD Ceramic Capacitor C1
5 100nF 50V 0805 X7R SMD Ceramic Capacitor C4 C8 C9 C10 C11
2 1nF 50V 0805 X7R SMD Ceramic Capacitor C6 C7
1 10uF 25V 1206 X7R SMD Ceramic Capacitor C3
1 1uF 25V 1206 X7R SMD Ceramic Capacitor C5
1 22uF 16V Tantalum Capacitor B-Case C2
1 MSS1260-333 330uH Coilcraft Power Inductor L1
3 100R 1% 0805 Resistor R5 R6 R23
3 20K 1% 0805 Resistor R7 R19 R22
2 1K 1% 0805 Resistor R1 R10
1 70.6K 1% 0805 Resistor R4
6 10K 1% 0805 Resistor R11 R12 R13 R14 R20 R21
2 0805 Resistor Value Depends on the LEDs R15 R16
1 3K8 1% 0805 Resistor R24
3 100K 1% 0805 Resistor R3 R17 R18
1 330R 1% 0805 Resistor R9
1 300R 1% 0805 Resistor R2
1 180K 1% 0805 Resistor R8
4 Tact Push Button SMD SW1 SW2 SW3 SW4
1 1×6 2.54mm pitch 15mm height Male Header J2
2 1×8 2.54mm pitch 15mm height Male Header J3 J4
1 1×10 2.54mm pitch 15mm height Male Header J1
1 JST-PH Connector 2 Pin Right Angle J5
1 1×2 5.2mm Pitch Screw Terminal Block J6

Software

Page based design is applied in the project. There are four pages that lets the user enter the charge parameters and monitor the battery status. Adafruit PCD8544 and GFX libraries are used to drive Nokia 5110 LCD.

The first page is the Set Parameters page. On this page the user can enter the battery cut-off voltage and the maximum charge current, go to battery status page, and start charging. Up and down buttons are used to travel between the options and right and left buttons are used to change values or select any option.

set-parameters-page-lithium-battery-charger

The second page is the Battery Status Page. While not charging, the user can enter this page from the Set Parameters page and see the current battery voltage. Pressing the left or the light button make the charger return to the Set Parameters page.

battery-status-page-lithium-battery-charger

The third page shows the charging state of the battery. It shows the voltage and current status of the battery during charge. When right or left button is pressed, the charger stops charging and returns to the Set Parameters page.

charging-page-lithium-battery-charger

When the battery voltage reaches to the set voltage, the charger stops charging and displays the Charge Complete page.To exit, pressing the left or the right button is required.

charge-complete-page-lithium-battery-charger

The charger keeps the last used parameters in the internal EEPROM. When charging process starts, the parameters are saved. At startup the charger reads the values from the EEPROM so the user don’t have to enter the values each time.

To read the battery voltage and the charge current, A0 and A1 pins are used as analog inputs. The details of the ADC steps are explained in the code. To change the charge current, PWM function is used via pin 6. Adjusting the duty cycle changes the charge current. A lookup table including the current vs. duty cycle is constructed manually and used. Since we can read the current, it is also possible to change the duty cycle dynamically.

At startup, the charger displays a bitmap logo. It was a bit challenging to display this bitmap so we wanted to explain the process for 5110 LCD users who want to use this feature.

How to Create and Use Bitmap Images on 5110 LCD

This example is prepared to be used with Adafruit PCD8544 and GFX Arduino libraries.

First of all, we need to create the image that will be displayed on the 5110 LCD. There are lots of graphics editors that can be used for this purpose but we will use the most basic one, MS Paint.

  1. Start paint and create a new file.
  2. Select “Resize” on the tool ribbon.
  3. Choose “Pixels” and uncheck “Maintain aspect ratio”
  4.  We will create a full screen logo so enter the dimensions horizontal: 88 and vertical: 48. Actually the width of the screen is 84px but we experienced that the width should be a multiple of 8. The excess four bits in each line won’t be displayed.
  5. Save the image in “Monochrome Bitmap” type.

Now the blank image is ready for the design. The last four vertical columns on the image will be lost so don’t include them. You can see the image created for the charger project below.

logo-page-lithium-battery-charger

To display this image on the LCD, we need to convert it to a bit matrix. LCD Assistant is a useful tool which will help us at this point.

  1. Open LCD Assistant and select “Load Image” from the ”File” menu.
  2. Choose the image you created.
  3. On the settings tab, choose “Horizontal” as byte orientation. The size of the picture will be automatically detected.
  4. Leave the other fields as they are.
  5. From the “File” menu, choose “Save Output” and type the file name such as Logo.txt.
  6. Open the .txt file and replace “const unsigned char” with “static const unsigned char PROGMEM”

The image bit matrix is ready to use in the Arduino sketch. Paste it before the “void Setup()” section. To display image on the screen, you can use the following code;

display.clearDisplay();

display.drawBitmap(0, 0,  logo, 84, 48, 1);

display.display();

Arduino Code