Texas Instruments MSP430 Launchpad Microcontroller Based Battery Charger

Share it!


I wrote about Texas Instruments’(TI) Launchpad line of micro controllers (uC) about a year ago in this post. . Finally it is time to use it in a project.

In the MSP430 Launchpad family of uCs there are seemingly infinite number of choices. The part number I am using is M430G2513, I ordered them from http://www.mouser.com for less than $2 each. To be able to use them in bread board circuits, I chose 20 pin DIP package (IN20 extension).

Project Description

If you remember the home made solar power project, 65 Watt experimental solar panel charged up a car battery, and this power was used for things like lighting, etc.

In a situation like this, the load is pretty much constant from day to day. However, the source of the power varies depending upon the seasons or the weather conditions. If a cloud passes by or if it rains or snows the power source is diminished.

So, what we need is a circuit that will measure the battery voltage periodically (say every 5 minutes) and check if it is below a threshold (say 12 Volts). If it is higher, this means there is enough power and it will do nothing. If the voltage is lower, it will turn on the relay to connect the battery charger to the grid (a plug on the wall) for a period of time (say one hour).

It is important to note that the battery will be charged independently by either the solar panel, the charger, or maybe both at the same time.

We will use the AD converter and the Timer A features of the uC for measuring the voltage and the timing, and we will use several output pins to turn on the LEDs and the relay.

Relay Control

M430G2513IN20 works with 3.3 DC Volts. The circuit below uses this low level signal and controls the relay, which in turn controls the power to a standard AC plug.

Relay Circuit

The schematic shows 5 Volts, but you need to use the voltage that the relay requires. Generic diode suppresses the spikes when the coil is turned off. R1 and R2 are both 1K, but again the resistor here depends on the gain of the transistor. The relay contacts controls the power to the plug. The signal from pin 15 of the uC is connected to the free end of the R1.

Note that this part of the project is generic enough that it could be used for other purposes.



R3 = 10K, R2 = 1K pot, VCC = 3 VDC, LED1 blinks, LED2 is on when charging, R1 = 4.7K.
Battery terminals are connected to sensor wires, Ground and one end of R3. Pin 15 goes out to relay control.

You need to adjust the R2 resistor to set the battery limit voltage such that when the mid leg of the R2 is below 1 Volts, the relay will be activated.

Here is the bread board view.

Bread board view


TI provides Code Composer Studio (CCS) to develop software for MSP430 uC. I will not go through the steps of installing this software because it is already documented in the TI’s website. Likewise, creating a new project in the workspace.

Once you create the project, you can copy the C program provided below over the sample main program that is created automatically.

Most of this code is self explanatory, but here are several points.

#include <msp430g2553.h>
#ifndef TIMER0_A1_VECTOR
void FaultRoutine(void);

The first line is where you specify your device type. The device type is printed on top of the chip.

    meas_time = 1;  // minutes
    chrg_time = 2;  // minutes
    p15secs = 0;
    ledon = 0;

We turn off the CPU in the main loop (line 49), because we are not using polling. This saves battery life. When the timer interrupts, the CPU will be activated and the interrupt service routine will run.

It is important to set meas_time and chrg_time to meaningful values (line 45 and 46). For testing purposes they are set to 1 and 2 here, but in real life you would want to set them to more meaningful values like 5 minutes and 60 minutes.

That’s about it as far as the code goes. You can compile and download it onto the uC with the LaunchPad development kit.

Finished Project

Here is a picture of the finished project. Granted, needs to be packaged better, but see it works great! :)

Finished project

1. Relay, 2. Relay contacts cable, 3. Relay coil power, 4. Transistor switching relay coil, 5. Switched Plug, 6. Unswitched Plug, 7. Power Supply to power relay coil, 8. Signal cables from uC to the transistor, 9. Sense wires to the Battery, 10. Voltage divider resistor and the pot. The yellow and the blue LEDs are unmarked.

A Different Approach

Another approach to this project is that instead of charging the battery for a fixed amount of time, we measure the voltage as the battery is charging, and stop the charging when the voltage goes above the higher limit (maybe 14 Volts). It is very easy to make this change to the program listed above.

Share it!
This entry was posted in Projects and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">