SLAA287B December   2005  – April 2022 MSP430BT5190 , MSP430BT5190 , MSP430F1101 , MSP430F1101 , MSP430F1101A , MSP430F1101A , MSP430F1111A , MSP430F1111A , MSP430F112 , MSP430F112 , MSP430F1121 , MSP430F1121 , MSP430F1121A , MSP430F1121A , MSP430F1122 , MSP430F1122 , MSP430F1132 , MSP430F1132 , MSP430F122 , MSP430F122 , MSP430F1222 , MSP430F1222 , MSP430F123 , MSP430F123 , MSP430F1232 , MSP430F1232 , MSP430F133 , MSP430F133 , MSP430F135 , MSP430F135 , MSP430F147 , MSP430F147 , MSP430F1471 , MSP430F1471 , MSP430F148 , MSP430F148 , MSP430F1481 , MSP430F1481 , MSP430F149 , MSP430F149 , MSP430F1491 , MSP430F1491 , MSP430F155 , MSP430F155 , MSP430F156 , MSP430F156 , MSP430F157 , MSP430F157 , MSP430F1610 , MSP430F1610 , MSP430F1611 , MSP430F1611 , MSP430F1612 , MSP430F1612 , MSP430F167 , MSP430F167 , MSP430F168 , MSP430F168 , MSP430F169 , MSP430F169 , MSP430F2001 , MSP430F2001 , MSP430F2002 , MSP430F2002 , MSP430F2003 , MSP430F2003 , MSP430F2011 , MSP430F2011 , MSP430F2012 , MSP430F2012 , MSP430F2013 , MSP430F2013 , MSP430F2013-EP , MSP430F2013-EP , MSP430F2101 , MSP430F2101 , MSP430F2111 , MSP430F2111 , MSP430F2112 , MSP430F2112 , MSP430F2121 , MSP430F2121 , MSP430F2122 , MSP430F2122 , MSP430F2131 , MSP430F2131 , MSP430F2132 , MSP430F2132 , MSP430F2232 , MSP430F2232 , MSP430F2234 , MSP430F2234 , MSP430F2252 , MSP430F2252 , MSP430F2252-Q1 , MSP430F2252-Q1 , MSP430F2254 , MSP430F2254 , MSP430F2272 , MSP430F2272 , MSP430F2272-Q1 , MSP430F2272-Q1 , MSP430F233 , MSP430F233 , MSP430F2330 , MSP430F2330 , MSP430F235 , MSP430F235 , MSP430F2350 , MSP430F2350 , MSP430F2370 , MSP430F2370 , MSP430F2410 , MSP430F2410 , MSP430F2416 , MSP430F2416 , MSP430F2417 , MSP430F2417 , MSP430F2418 , MSP430F2418 , MSP430F2419 , MSP430F2419 , MSP430F247 , MSP430F247 , MSP430F2471 , MSP430F2471 , MSP430F248 , MSP430F248 , MSP430F2481 , MSP430F2481 , MSP430F249 , MSP430F249 , MSP430F2491 , MSP430F2491 , MSP430F2616 , MSP430F2616 , MSP430F2617 , MSP430F2617 , MSP430F2618 , MSP430F2618 , MSP430F2619 , MSP430F2619 , MSP430F412 , MSP430F412 , MSP430F413 , MSP430F413 , MSP430F4132 , MSP430F4132 , MSP430F415 , MSP430F415 , MSP430F4152 , MSP430F4152 , MSP430F417 , MSP430F417 , MSP430F423 , MSP430F423 , MSP430F423A , MSP430F423A , MSP430F425 , MSP430F425 , MSP430F4250 , MSP430F4250 , MSP430F425A , MSP430F425A , MSP430F4260 , MSP430F4260 , MSP430F427 , MSP430F427 , MSP430F4270 , MSP430F4270 , MSP430F427A , MSP430F427A , MSP430F435 , MSP430F435 , MSP430F4351 , MSP430F4351 , MSP430F436 , MSP430F436 , MSP430F4361 , MSP430F4361 , MSP430F437 , MSP430F437 , MSP430F4371 , MSP430F4371 , MSP430F438 , MSP430F438 , MSP430F439 , MSP430F439 , MSP430F447 , MSP430F447 , MSP430F448 , MSP430F448 , MSP430F4481 , MSP430F4481 , MSP430F449 , MSP430F449 , MSP430F4491 , MSP430F4491 , MSP430F4616 , MSP430F4616 , MSP430F46161 , MSP430F46161 , MSP430F4617 , MSP430F4617 , MSP430F46171 , MSP430F46171 , MSP430F4618 , MSP430F4618 , MSP430F46181 , MSP430F46181 , MSP430F4619 , MSP430F4619 , MSP430F46191 , MSP430F46191 , MSP430F47126 , MSP430F47126 , MSP430F47127 , MSP430F47127 , MSP430F47163 , MSP430F47163 , MSP430F47166 , MSP430F47166 , MSP430F47167 , MSP430F47167 , MSP430F47173 , MSP430F47173 , MSP430F47176 , MSP430F47176 , MSP430F47177 , MSP430F47177 , MSP430F47183 , MSP430F47183 , MSP430F47186 , MSP430F47186 , MSP430F47187 , MSP430F47187 , MSP430F47193 , MSP430F47193 , MSP430F47196 , MSP430F47196 , MSP430F47197 , MSP430F47197 , MSP430F477 , MSP430F477 , MSP430F478 , MSP430F478 , MSP430F4783 , MSP430F4783 , MSP430F4784 , MSP430F4784 , MSP430F479 , MSP430F479 , MSP430F4793 , MSP430F4793 , MSP430F4794 , MSP430F4794 , MSP430F5232 , MSP430F5232 , MSP430F5234 , MSP430F5234 , MSP430F5237 , MSP430F5237 , MSP430F5239 , MSP430F5239 , MSP430F5242 , MSP430F5242 , MSP430F5244 , MSP430F5244 , MSP430F5247 , MSP430F5247 , MSP430F5249 , MSP430F5249 , MSP430F5252 , MSP430F5252 , MSP430F5253 , MSP430F5253 , MSP430F5254 , MSP430F5254 , MSP430F5255 , MSP430F5255 , MSP430F5256 , MSP430F5256 , MSP430F5257 , MSP430F5257 , MSP430F5258 , MSP430F5258 , MSP430F5259 , MSP430F5259 , MSP430F5304 , MSP430F5304 , MSP430F5308 , MSP430F5308 , MSP430F5309 , MSP430F5309 , MSP430F5310 , MSP430F5310 , MSP430F5324 , MSP430F5324 , MSP430F5325 , MSP430F5325 , MSP430F5326 , MSP430F5326 , MSP430F5327 , MSP430F5327 , MSP430F5328 , MSP430F5328 , MSP430F5329 , MSP430F5329 , MSP430F5333 , MSP430F5333 , MSP430F5336 , MSP430F5336 , MSP430F5338 , MSP430F5338 , MSP430F5340 , MSP430F5340 , MSP430F5341 , MSP430F5341 , MSP430F5342 , MSP430F5342 , MSP430F5418 , MSP430F5418 , MSP430F5418A , MSP430F5418A , MSP430F5419 , MSP430F5419 , MSP430F5419A , MSP430F5419A , MSP430F5435 , MSP430F5435 , MSP430F5435A , MSP430F5435A , MSP430F5436 , MSP430F5436 , MSP430F5436A , MSP430F5436A , MSP430F5437 , MSP430F5437 , MSP430F5437A , MSP430F5437A , MSP430F5438 , MSP430F5438 , MSP430F5500 , MSP430F5500 , MSP430F5501 , MSP430F5501 , MSP430F5502 , MSP430F5502 , MSP430F5503 , MSP430F5503 , MSP430F5504 , MSP430F5504 , MSP430F5505 , MSP430F5505 , MSP430F5506 , MSP430F5506 , MSP430F5507 , MSP430F5507 , MSP430F5508 , MSP430F5508 , MSP430F5509 , MSP430F5509 , MSP430F5510 , MSP430F5510 , MSP430F5630 , MSP430F5630 , MSP430F5631 , MSP430F5631 , MSP430F5632 , MSP430F5632 , MSP430F5633 , MSP430F5633 , MSP430F5634 , MSP430F5634 , MSP430F5635 , MSP430F5635 , MSP430F5636 , MSP430F5636 , MSP430F5637 , MSP430F5637 , MSP430F5638 , MSP430F5638 , MSP430F6433 , MSP430F6433 , MSP430F6435 , MSP430F6435 , MSP430F6436 , MSP430F6436 , MSP430F6438 , MSP430F6438 , MSP430F6630 , MSP430F6630 , MSP430F6631 , MSP430F6631 , MSP430F6632 , MSP430F6632 , MSP430F6633 , MSP430F6633 , MSP430F6634 , MSP430F6634 , MSP430F6635 , MSP430F6635 , MSP430F6636 , MSP430F6636 , MSP430F6637 , MSP430F6637 , MSP430F6638 , MSP430F6638 , MSP430FE423 , MSP430FE423 , MSP430FE4232 , MSP430FE4232 , MSP430FE423A , MSP430FE423A , MSP430FE4242 , MSP430FE4242 , MSP430FE425 , MSP430FE425 , MSP430FE4252 , MSP430FE4252 , MSP430FE425A , MSP430FE425A , MSP430FE427 , MSP430FE427 , MSP430FE4272 , MSP430FE4272 , MSP430FE427A , MSP430FE427A , MSP430FG4250 , MSP430FG4250 , MSP430FG4260 , MSP430FG4260 , MSP430FG4270 , MSP430FG4270 , MSP430FG4616 , MSP430FG4616 , MSP430FG4617 , MSP430FG4617 , MSP430FG4618 , MSP430FG4618 , MSP430FG4619 , MSP430FG4619 , MSP430FG477 , MSP430FG477 , MSP430FG478 , MSP430FG478 , MSP430FG479 , MSP430FG479 , MSP430FW423 , MSP430FW423 , MSP430FW425 , MSP430FW425 , MSP430FW427 , MSP430FW427 , MSP430FW428 , MSP430FW428 , MSP430FW429 , MSP430FW429 , MSP430G2001 , MSP430G2001 , MSP430G2101 , MSP430G2101 , MSP430G2102 , MSP430G2102 , MSP430G2111 , MSP430G2111 , MSP430G2112 , MSP430G2112 , MSP430G2121 , MSP430G2121 , MSP430G2131 , MSP430G2131 , MSP430G2132 , MSP430G2132 , MSP430G2152 , MSP430G2152 , MSP430G2201 , MSP430G2201 , MSP430G2201-Q1 , MSP430G2201-Q1 , MSP430G2211 , MSP430G2211 , MSP430G2212 , MSP430G2212 , MSP430G2221 , MSP430G2221 , MSP430G2231-Q1 , MSP430G2231-Q1 , MSP430G2232 , MSP430G2232 , MSP430G2252 , MSP430G2252 , MSP430G2302 , MSP430G2302 , MSP430G2312 , MSP430G2312 , MSP430G2332 , MSP430G2332 , MSP430G2352 , MSP430G2352 , MSP430G2402 , MSP430G2402 , MSP430G2432 , MSP430G2432 , MSP430G2452 , MSP430G2452 , MSP430L092 , MSP430L092

 

  1.   Trademarks
  2. 1Introduction
  3. 2Measurement Circuit
  4. 3Software
    1. 3.1 Main
    2. 3.2 ADC ISR
    3. 3.3 Watchdog Timer ISR
    4. 3.4 Software Flowchart
  5. 4Conclusion
  6. 5References
  7. 6Revision History

Measurement Circuit

Figure 2-1 shows block-level schematic of a charger.

GUID-AB9C2056-BB9F-41EB-A9CC-3677FFE90644-low.gif Figure 2-1 Block Level Schematic

A buck converter is used during the constant current and voltage charge stages. A buck converter is a step-down voltage converter that uses the inductor as a current source to the output load impedance, which is the battery. The PNP and NPN transistors form a switch that is controlled by a PWM signal. The Timer_A3 on the MSP430 MCU can control the current for charging the battery using the PWM feature. When this switch is closed (on), current flows through the inductor and the capacitor is charged (see Figure 2-2). When the switch is open (off), the inductor tries to maintain its current flow by inducing a voltage, because an inductor cannot have an instantaneous change in current. The current now flows through the diode and the inductor charges the capacitor (see Figure 2-3). The LC network acts as a low-pass filter, and if the PWM frequency is much higher than the cut-off frequency of the LC network, the capacitor voltage is constant and equal to the mean value of the input voltage to the buck converter.

GUID-A73E81F8-7DD7-4D32-812B-A27C70FFAA17-low.gifFigure 2-2 Buck Converter Switch On
GUID-86105F36-3CBB-41D2-98F1-42A79EFA252B-low.gifFigure 2-3 Buck Converter Switch Off

The value of the inductor can be calculated by Equation 1.

Equation 1. L = Duty cycle × T × (VI – Vsat – VO) / 2IO

where

  • Duty Cycle = the duty cycle of the PWM
  • T = Period of the PWM
  • VO = Voltage output
  • Vsat = Voltage loss on the switch
  • VI = Voltage input to the switch
  • IO = Current for constant current stage

Assuming VI is 6 V, Vsat is 0.5 V, IO is 500 mA, VO is 4.575 V, 1/T is 15 kHz, duty cycle is 50%:

Equation 2. VO = Vbat + Ibat × Rsense = 4.2 + 500 mA × 0.75 = 4.575 V

The inductor should be at least 31 µH. For this implementation, a value of 75 µH is used. When the timer is clocked from the DCO with a frequency of 3.84 MHz, the TACCR0 value must be 255 to achieve a PWM frequency of 15 kHz (3.84 MHz / 256). The timer runs in up mode, and the timer output switches in toggle/set mode. The duty cycle of the timer output (TA1) can be controlled by adjusting the value of TACCR1. A PWM resolution of 8 bits is enough to control the constant current flow in the battery during the constant current charging stage and maintain a constant voltage on the battery during the constant voltage charging stage. If the capacitor is 220 µF and the inductor is 75 µH, the cutoff frequency of the LC network is 1.2 kHz ( 1 / 2 × π × L × C ), which is much lower than the PWM frequency. This helps the capacitor to effectively reduce the output voltage ripple and maintain a DC voltage level.

Three channels (A0, A1, A2) on the 10-bit ADC on the MSP430 MCU can be used to monitor the battery voltage, battery temperature, and battery current. 1 LSB is equal to Vref / (N – 1), where Vref is the reference voltage and N is the resolution in bits of the ADC. With a 1.5-V on chip reference, 1 LSB is 1.5 / 1023 = 1.47 mV.

The range of voltages that the ADC needs to detect can be calculated as follows:

The highest voltage, VO, during the constant current charging stage is 4.575 V. The voltage to the ADC input due to the voltage divider (R1 = 2.1 × R2) is 4.575 / 3.1 = 1.5 V. This is within Vref and can be resolved by the ADC.

The lowest voltage that the ADC needs to detect is during the constant voltage stage to monitor the battery current and stop the charging process. The ADC needs to detect the voltage drop created by a 0.1C current through the battery. In this case it is 50 mA × 0.75 = 37.5 mV. This is approximately 25 LSB of resolution and can be resolved by the ADC.

For this application, a thermistor (RT1) is connected to the negative pole of the battery. The thermistor resistance decreases with temperature and so does the thermistor voltage. A 10k thermistor was used.

An abnormally low voltage indicates overheating, and the charging process must stop. This voltage can be detected by the ADC input.