Intelligent battery monitoring system based on DS2438 chip

Publisher:WhisperingLightLatest update time:2012-02-08 Source: 今日电子Keywords:DS2438 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1. Introduction

At present, in order to meet the requirements of mobility and portability, portable devices are usually powered by batteries. When using batteries, the current status of the battery is of concern to users. For example, MP3 players, mobile phones, and laptops all display the current status of the battery in real time. For this reason, when designing the instruments involved in this article, the intelligent battery monitoring system was fully considered. The battery monitoring system implemented in this article consists of the DS2438 intelligent battery monitoring chip, 51 single-chip microcomputer, and LCD display module, among which the core function is completed by the DS2438 intelligent battery monitoring chip. This article introduces the hardware implementation and software design of this system, as well as the characteristics of the DS2438 chip and related control software programs.

2. System Hardware Implementation

The hardware design of this system strives to be simple, with the goal of minimizing the occupancy of the microcontroller instruction cycle so that the microcontroller can complete more other functions. The hardware implementation block diagram of the system is shown in Figure 1.

This system consists of a DS2438 intelligent battery monitoring chip, a 51 microcontroller, and a liquid crystal display module.

The DS2438 chip monitors the current various states of the battery, including the current battery charge/discharge state, voltage, current, temperature, remaining power, elapsed time and other parameters. The DS2438 chip can automatically collect these parameters and store them in the SRAM/EEPROM. The 51 microcontroller issues commands to read these parameters as needed, then processes these parameters and displays the battery status. Since the EEPROM that stores these parameters is non-volatile, this system has a power-off protection function. The 51 microcontroller

reads and processes the corresponding parameters of the battery status according to user needs, and then sends them to the liquid crystal display module for display. As can be seen from Figure 1, the microcontroller is the control and processing center of the entire system. Since a large amount of work is completed by the software of the microcontroller, the complexity of the system hardware is significantly reduced.

The LCD module displays the current battery status information that the user needs to know, and is only controlled and accessed by the microcontroller. It can be seen that the main functions of this system are completed by the DS2438 chip and the software program of the 51 microcontroller

. The usage of the 51 microcontroller and the LCD module is the same as that in other systems, so the following mainly introduces the functional characteristics of the DS2438 chip and the microcontroller software programming.

The DS2438 chip is a new generation of intelligent battery monitoring chip launched by DALLAS. It has the advantages of powerful functions, small size, and simple hardware wiring.

1. Features
(1) There is only one bidirectional data line, so the microcontroller only needs one port to connect to it.
(2) Contains a digital temperature sensor (eliminating the need to install a thermistor in the battery block).
(3) The on-chip analog-to-digital converter can monitor the battery voltage, thereby determining the end of charging and discharging.
(4) The on-chip integral current accumulator can record the total amount of current flowing into and out of the battery in real time, which is convenient for counting power.
(5) Contains a binary format expiration time table.
(6) Contains 40 bytes of user-accessible memory with power-off protection that can be used to store special battery parameters.

2. Chip hardware wiring (see Figure 2)

3. Storage space

The storage space of DS2438 has 8 pages, 8 bytes per page, a total of 64 bytes, and each page has a corresponding high-speed temporary storage page. Therefore, the memory includes two parts: RAM high-speed temporary storage and SRAM/EEPROM (power-off protection), and these two parts are mirror images. The high-speed temporary storage ensures that the data can be consistent when using one-line communication (when writing data to DS2438, it is first written to the high-speed temporary storage. Only when the data is confirmed can the temporary storage page data be written to the corresponding power-off protection space using the temporary storage copy command). When the microcontroller reads/writes data to DS2438, it can only operate on the high-speed temporary storage. The storage space includes some special function registers and user-usable storage units. The following is an explanation of the special registers in the storage space that are related to the actual system we designed.

(1) Status/flag register
The status/flag register determines the working state of DS2438. The microcontroller can realize various functions of DS2438 by reading/writing special function registers. Therefore, before operating it, this register must be initialized, that is, the corresponding control bit must be written.

(2) Current register
DS2438 contains an analog-to-digital converter that can effectively measure the current flowing into and out of the battery block. The current measurement is achieved by measuring the voltage across the external sensing resistor. The measurement result is stored in the current register.

In fact, the current register stores the voltage value. To obtain the current flowing into and out of the battery, the formula (1) can be used to calculate.
I=value of current register/(4096×RSENS) (1)

(3) Current integral accumulator register
DS2438 measures the remaining battery power with the help of its internal current integral accumulator (ICA). ICA stores the net accumulated value of the total current flowing into and out of the battery. Therefore, the value stored in this register can be used to calculate the remaining battery power.

(4) Voltage register
Stores the collected voltage value.

(5) Temperature register
Stores the collected battery temperature value.

(6) Elapsed time record register The
elapsed time record register records the exact time when the battery is fully charged and disconnected from the system relative to the internal reference time, which helps users understand the battery usage and use and maintain the battery correctly.

4. DS2438 operation commands

There are two types of DS2438 operation commands. One type is storage function commands, including read/write temporary page, copy temporary page, read SRAM/EEPROM page, temperature conversion, voltage conversion and other commands. The main function of this type of command is to collect and store data. The other type is ROM function commands, including four operations such as read, compare, skip and search for the RAM serial number of DS2438. Users can use this type of command to arbitrarily access multiple DS2438 chips connected on a bus. [page]


4. System Function Software Implementation and Flowchart

In order to meet the real-time monitoring requirements, the system microcontroller uses a timed interrupt to access the DS2438 to collect battery parameters. First, set the microcontroller's counter to the timed mode, turn on the counter, and the timing length can be flexibly set as needed. Then the microcontroller runs other programs and waits for the arrival of the timed interrupt. After the timed interrupt occurs, the interrupt service program is entered, the control operation program of the DS2438 is called, data is collected, and the collected data is processed and displayed. Finally, the timed interrupt is reinitialized and returned. Figure 3 is the overall flow chart of the system, and Figure 4 is the interrupt service program flow chart.

DS2438 uses only one data line for data communication with the microcontroller, so the program must be written in strict accordance with the chip's read and write timing requirements to ensure the correct reading and writing of data. Although this process is cumbersome, it is not complicated. Due to limited space, this article will not explain it. The following describes how to use an intelligent battery monitoring system based on the DS2438 chip to monitor the power supply mode (DC or AC) of the instrument and the voltage, current, temperature, and remaining power of the battery.

1. Monitoring of power supply mode

To determine what power supply mode the instrument is in during use, the value of the current register introduced earlier can be used to make a judgment.

First, the microcontroller controls the DS2438 to enable its current A/D converter. The DS2438 will automatically measure the current flowing into and out of the battery block at a rate of 36.41 times per second, and the measurement results are stored in the current register. The upper six bits of the high byte of the current register are the sign bits of the current flowing into the battery. When it is 1, it means that the battery is charging, that is, the instrument is powered by an AC power supply; when it is 0, it means that the battery is discharging, that is, the instrument is powered by a DC battery. Therefore, the microcontroller reads the value of the current register and judges its upper six bits to find out the power supply mode, and also obtains the current value. See Figure 5 for the software flow chart.

2. Measurement of battery voltage and temperature

Since the DS2438 has an A/D converter and a digital temperature sensor inside, to obtain the voltage and temperature of the battery, the microcontroller only needs to send a control command to the DS2438 to collect the voltage and temperature, and then wait for it to complete the collection and automatically store the voltage and temperature measurement values ​​in the corresponding registers, and then the microcontroller can read the contents of the registers. When reading the register value, if the data line between the microcontroller and the DS2438 is at a low level, it means that the DS2438 is performing voltage and temperature conversion, and the data cannot be read at this time. Only when the data line is at a high level can the data be read correctly.

3. Monitoring of remaining power

The remaining battery power is important information that users need when using the instrument. It can be obtained by using the value of the current integral accumulation (ICA) register. The value of the ICA register is changed by the DS2438 after automatically measuring the battery current at a fixed time. There is no need to control it. The microcontroller only needs to read the value of the ICA register and then substitute the read value into formula (2) to get the remaining battery power. The flowchart of the remaining power monitoring is shown in Figure 6.

Remaining power = ICA/(2048×RSENS) (2) The unit of RSENS is Ω.

Note: (1) When the microcontroller performs any storage command operation on the DS2438, before issuing each command, it must follow the reset timing requirements of the DS2438, first send a reset signal and wait for the DS2438's response (to indicate that the DS2438 is ready to receive or send data), and then send a ROM command to select the DS2438 to be accessed on the bus. In the program flow chart of this article, this process is replaced by "DS2438 initialization";
(2) Before controlling the DS2438, the status/flag register must be written first;
(3) When reading the register value, in order to prevent reading errors, first check whether the DS2438 is modifying the register contents. This can be achieved by judging the NVB bit in the status/flag register.


V. Conclusion

The intelligent battery monitoring system based on the DS2438 chip introduced in this article is a part of a portable instrument. Practical use has proved that this system is reliable, powerful, easy to operate, and can work with other functions. With the widespread application of various portable electronic products, real-time battery monitoring has become an indispensable function. Therefore, the battery monitoring system introduced in this article has strong practicality.

Keywords:DS2438 Reference address:Intelligent battery monitoring system based on DS2438 chip

Previous article:Application of Hard Disk Storage on Single Chip Microcomputer
Next article:Debugging Power Factor Correction Circuits Using Digital Phosphor Oscilloscopes

Recommended ReadingLatest update time:2024-11-16 21:00

High-power battery status detection based on DS2438
Abstract: This paper introduces a high-power battery status detection method. The charging and discharging current value of the battery is measured by the power quality management chip DS2438, and the charging and discharging capacity of the battery is estimated by integrating the time. With the microcontroller STC8
[Power Management]
High-power battery status detection based on DS2438
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号