1 System Overview
Parameters related to battery charging and discharging include: battery terminal voltage, charging current, battery temperature, etc. Therefore, the system needs to accurately collect these three parameters. The system block diagram is shown in Figure 1. The system consists of MCU, analog sampling circuit, temperature acquisition circuit and host computer. The MCU collects terminal voltage, current and temperature information during battery charging and discharging, and then sends the information to the host computer through the serial communication interface, and then receives and processes it by MATLAB, and draws a curve. The current and voltage are collected 10 times per second, and the temperature is collected once per second. The MCU transmits a set of data to the host computer every second, and MATLAB tracks and updates the data to achieve the effect of dynamically displaying voltage, current, and temperature.
2 Hardware Design
2.1 MCU Selection
The MCU of this monitoring system uses STC12C5A60S2. The chip resources include: 60K flash, 1280 bytes high-speed RAM, 8-channel 10-bit A/D, 2-channel UART, 2-channel 16-bit timer, and 1-channel internal watchdog timer. The crystal oscillator is 11.0592MHz.
2.2 Temperature acquisition chip selection
The temperature acquisition circuit chip uses DS18B20 produced by Dallas. It is a linear digital temperature sensor produced by Dallas. It uses a 3-pin T0-92 small package. The temperature measurement range is -55℃~+125℃, and it can be programmed to 9-bit to 12-bit A/D conversion accuracy. The temperature measurement resolution can reach 0.0625℃. The measured temperature is serially output in a 16-bit digital format with sign extension. It has the advantages of directly outputting digital signals, no interference in the signal transmission process, convenient expansion, and no need to design additional signal modulation circuits.
In order to make the temperature collection more accurate, this system uses two DS18B20s, and the A/D conversion accuracy is selected as 12 bits, which are attached to different positions of the battery wall.
2.3 Design of current and voltage detection circuits
The voltage check uses resistor voltage division, and is sent to the A/D conversion interface through the voltage follower circuit. The role of the operational amplifier is to increase the input impedance, reduce the impact of the detection circuit on the charging circuit, and improve the measurement accuracy.
There are two methods for current detection: high-end detection and low-end detection. Low-end detection is easier to implement, but the disadvantage of this solution is that the load will raise a DC voltage higher than the actual ground line, and the measurement is inaccurate; in addition, the power supply and load have different reference grounds, which is not conducive to EMI control. The difficulty of high-end detection is that there is a common-mode voltage at the input end, and the measurement circuit is complicated. This system uses Maxim's MAX4173 to measure the differential mode voltage, which includes a differential amplifier inside. Selecting two MAX4173s can realize bidirectional sampling of current. The current detection circuit is shown in Figure 2.
3 MCU software design
MCU completes functions including reading two-way A/D conversion (voltage, current); reading two-way DS18B20 conversion results; serial communication. Voltage and current change more drastically, the sampling period should be short, but a short period will result in a large amount of data, increasing the burden of transmission and data analysis. After weighing, the sampling period of voltage and current is taken as 0.1s. Temperature is a physical quantity with a long time parameter, so the sampling time can be relaxed. Here, the sampling period is taken as 1s.
3.1 MCU Program
In order to coordinate the implementation of various functions, this paper refers to the multi-task scheduling algorithm and the time slice rotation algorithm. The multi-task scheduling algorithm divides the functions to be implemented by the microcontroller into multiple task modules according to actual requirements, and specifies the priority level, and a task scheduling module uniformly controls the execution order. The control of the CPU is allocated to different task modules according to different priorities. Each module accesses the CPU within its own execution time, forming a multi-task effect of taking turns to execute at the micro level and running concurrently at the macro level, as shown in Figure 3.
Several tasks in this system are sensitive to time requirements, and simply using multi-task scheduling cannot meet the needs. Combined with the time slice rotation algorithm, time constraints are considered when allocating tasks, and tasks are prioritized. Tasks with high priorities are executed first. To ensure the stability of the sampling cycle, A/D conversion and temperature conversion have higher priorities. Sending the serial port several tens of milliseconds later will not cause adverse effects, so the priority is lower. The brief flow of the program is shown in Figure 4.
The task scheduling module contains the time information of each task, such as A/D conversion every 0.1s, temperature detection every 1s, temperature reading every 40ms, and serial port sending every 0.1s. If a task contains multiple sub-functions, the finite state machine (FSM) algorithm is used to execute one sub-function at a time until the task is completed.
The A/D conversion is relatively simple and will not be described in detail. The main point to note is that after starting the A/D conversion, you must wait for the conversion to complete before reading the result, otherwise the result read out will be the last conversion result
.
3.2 DS18B20 Program
The operation of DS18B20 is divided into three steps: initialization, ROM command and DS18B20 function command. The operation timing of DS18B20 is shown in Figure 5. It can be seen from the timing diagram that DS18B20 has strict requirements on the operation timing, otherwise it will cause operation failure.
According to the timing diagram, each read bit of data requires a 60us delay. In order to ensure accurate delay, the method used is to look at the assembly language and calculate the number of null instructions (NOP) that need to be added.
After writing the code according to the timing requirements, the following statistics are obtained: the start-up temperature conversion time is about 2.5ms, and the temperature reading time is about 10.25ms. These time quantities are much smaller than the length of a time slice (20ms), which meets the requirements. In order to achieve 12-bit accuracy, the device manual requires that the interval between two start-up temperature conversion times must not be less than 750ms. Temperature acquisition can be achieved once every 1s. The task flow chart for reading temperature is shown in Figure 6.
In Figure 6, SenseNo refers to the serial number of the DS18B20, and SenseCNT is the total number of devices. The way to read different DS18B20s is to use the device's own ID, which can be read out through the program, but it is more cumbersome. In order to reduce the burden of the program, we read out the ID of each device in advance through other methods and use it directly when reading the temperature, which simplifies the task.
3.3 Communication Protocol
The system transmits the sampled data to the host computer every 1s. In order to ensure reliable transmission, the following communication protocol is formulated:
There are 4 groups of data, voltage (24Byte), current (24Byte), temperature 1 (6Byte), temperature 2 (6Byte). When the baud rate is 19200bps, the longest group of transmission time is about 12ms, which is less than the length of a time slice and meets the requirements. In the task, a group of data is sent each time, and the algorithm is similar to the temperature reading task.
4 MATLAB Program Design
In order to facilitate drawing and data analysis, we use MATLAB as the host computer development tool. The main tasks include serial communication with MCU; data scale conversion; and drawing 4 curves on the same interface.
4.1 Serial communication and data processing
Starting from Matlab 6.0, Mathworks has added the instrument control toolbox to the software, providing formal support for serial communication of RS-232/RS-485 communication standards. Using the Serial class and instrcallback callback function of the toolbox, real-time serial communication can be reliably performed.
The order of serial port operation is (1) create a serial port and set its properties; (2) open the serial port; (3) read and write serial port operations; (4) close and clear the serial port device object.
After reading the data, extract the voltage, current and two-channel temperature data according to the protocol. Since these data are raw A/D conversion data and have no actual physical meaning, they need to be scaled. That is, the physical meaning represented by the data is expressed. For example, for voltage detection, the A/D reference voltage is 5V, so for a 10-bit ADC, the voltage value represented by the conversion result N is: N*5/1024. After the scale conversion is completed, it is stored in the buffer.
4.2 Handle drawing
The system needs to display three physical quantities, voltage, current and temperature. Due to different physical units and sampling periods, three coordinate systems need to be drawn and displayed separately. MATLAB does not provide such a drawing function, so the handle drawing function of MATLAB is used here.
When creating each graphic object, MATLAB assigns a unique value to the object, which is called the graphic object handle (Handie). A handle is a unique identifier of a graphic object. The handles of different objects cannot be repeated or confused. Graphic objects include root screens, windows, coordinate axes, lines, etc. The so-called handle drawing is to use the underlying drawing function to achieve drawing by setting and operating the object properties (Handle Graphics).
5 Running Example Analysis
The system is used to monitor the charging of a lead-acid battery (12V). The computer effect is shown in Figure 7:
In Figure 7, the horizontal axis is the time axis, which is updated once per second; there are three vertical axes, namely the current and voltage on the left, and the temperature on the right; the current curve is red, the voltage is black, the temperature 1 is a blue solid line, and the temperature 2 is a blue dotted line. The four curves correspond to their respective coordinates.
In general, due to the influence of factors such as the internal resistance of the battery and the speed of electrochemical reaction, the terminal voltage during charging is higher than that during static state, and the terminal voltage during discharge is lower than that during static state. The longer the battery is used, the higher the internal resistance, and the more sensitive it is to the charge and discharge current. As shown in the figure, a slight change in the charging current (about 0.1A) causes a sharp fluctuation in the terminal voltage (about 9V). The battery terminal voltage is very sensitive to the charging current, indicating that the battery internal resistance is large. In addition, for a lead-acid battery with good performance, the voltage is between 11V and 13V when it is static, while the static terminal voltage of the battery is less than 6V. It can be inferred that the battery has been seriously damaged.
6 Conclusion
Through this system, we can very intuitively monitor the relationship between the battery terminal voltage and the charge and discharge current, as well as the temperature changes, which is helpful for studying the battery charge and discharge characteristics, managing the battery more scientifically and efficiently, and providing a basis for electric vehicle power management.
Previous article:Design of a Single-stage Long Delay Circuit
Next article:Waveform Conversion and Circuit Implementation of Narrowband Remote Control Signal
- Popular Resources
- Popular amplifiers
- MathWorks and NXP Collaborate to Launch Model-Based Design Toolbox for Battery Management Systems
- STMicroelectronics' advanced galvanically isolated gate driver STGAP3S provides flexible protection for IGBTs and SiC MOSFETs
- New diaphragm-free solid-state lithium battery technology is launched: the distance between the positive and negative electrodes is less than 0.000001 meters
- [“Source” Observe the Autumn Series] Application and testing of the next generation of semiconductor gallium oxide device photodetectors
- 采用自主设计封装,绝缘电阻显著提高!ROHM开发出更高电压xEV系统的SiC肖特基势垒二极管
- Will GaN replace SiC? PI's disruptive 1700V InnoMux2 is here to demonstrate
- From Isolation to the Third and a Half Generation: Understanding Naxinwei's Gate Driver IC in One Article
- The appeal of 48 V technology: importance, benefits and key factors in system-level applications
- Important breakthrough in recycling of used lithium-ion batteries
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Did you have a 4WD car in your childhood? See the "voice-controlled 4WD car" made by a talented person on B station~
- Have you ever designed a 0-10V dimming power supply that is fully compatible with dimmers?
- How to deal with the new national standard for electric vehicles? TI provides BMS solutions!
- TI's IWR6843 smart mmWave sensor antenna-in-package evaluation module
- Structural Design of Virtual I2C Bus Software Package Based on TMS320F206
- eBox question. Has anyone used eBox before? How to set the timer?
- ST NUCLEO-L552ZE-Q Review Summary
- 【Comic】Detailed explanation of power supply circuit
- You are in charge of optimizing the mobile version of EEWorld Forum!
- Why can I see a 2V signal on the oscilloscope, but the ADC cannot collect it?