You are on page 1of 26

EE401-Microcontrollers

Battery Management System with Hall Effect Current Meter

2004502020 zgr M. DUMAN 2006502020 A. Esat GEN 2006502028Mehmet KARABUDAK

10.03.2011

Abstract:
Nowadays, cars, work with electrical energy, are very popular due to the reducing carbon emission. Because of the adverse affect of the fossil fuels, interest of the solar and electrical energy increase. In such systems, in order to use the solar energy, there must be a battery system, which store electrical energy converted from electrical energy, to provide power supply to device. However, some problems can occur while storing and providing energy. In order to avoid such problems battery management systems (BMS) are developed to provide stable and safe energy to the devices. Battery management systems measure each voltage values of batteries and discard distorted battery if any. Unless the distorted battery doesnt provide energy to the system, other batteries materials can be damaged and unwanted conditions such as great current increment and unbalanced voltage levels can be occurred. BMS provide to prevent these unwanted conditions. Hence, life of batteries is saved by battery management systems and maintenance cost of these systems reduces greatly. Another advantage of the BMS is balancing the voltage levels to avoid charging batteries each other. If systems dont do that, providing energy by batteries will reduce and losses will increase. Our system couldnt provide such advantages yet, but this system is the basic structure of the general BMS. It measures the calculated voltage and current values and shows on LCD and PC through serial port. Although the low resolution of ADC we have, system can measure the values with approximately %93.75 accuracy. If some developments are applied to the system, it can be used in a car work with solar energy. Such development includes ADC with high resolution, Hall Effect sensor with linear input current output voltage curve and linear amplifier that amplify the low voltage values. Also if available, high voltage input capable ADC can be used to get voltage values of batteries without using any voltage divider circuit. If the system is wanted to be independent from any other device such as signal generator, a clock generator such as LM7555 IC can be used. Hence, the system needs only AC 220V.

Theory:
Our battery management system includes four main parts; four battery supplies approximately DC 60V, Hall Effect sensor to measure the current on the 32.5, voltage divider to restrict the voltage values for each battery to 0-5V level and a microcontroller (MCU) board which show measured and calculated values on LCD and PC through serial port. The MCU board includes an analog-digital converter (ADC), a microcontroller called AT89C52, an LCD display and RS232 circuit in order to display measured values on PC. The ADC, called ADC0808, includes eight different analog inputs which can be selected by using address bits. This is an 8-bit converter which means it has eight output pins. Input voltage values of the ADC should be in range of Vref(+) and Vref(-).Because of that, resolution of the ADC will be 0,019 if the range is 5V. Hence, due to the fact that 60V DC voltage must be reduced by proportional of a constant, voltage divider circuits are set up. This constant calculated under supplying maximum voltage level circumstances of the battery system. If maximum voltage is considered as 60V, it can be reduced to 5V by dividing 12. Reducing each voltage levels by dividing 12 is important, because if otherwise, unwanted conditions occur such as reading high or negative voltage levels. After converting the each battery level which comes to the ADC in range of 0-5V voltage levels, microcontroller multiplies the same constant to find the exact values of the system. Actually, coming voltage levels to ADC dont belong the each battery; on the contrary they are the summation of all batteries voltages. For instances, first coming voltage level which is maximum 60V is the summation of all batteries. While multiplying the constant to coming voltage levels to MCU, we first subtract the each value. In microcontroller, measured voltages through ADC are calculated with determined methods before and monitored on LCD and PC through serial ports of MCU. Another part of the system measures the current value on the 32.5 resistor with Hall Effect sensor. Here is the working principle of the Hall Effect. When a current-carrying conductor is placed into a magnetic field, a voltage will be generated perpendicular to both the current and the field. Figure 1 illustrates the basic principle of the Hall Effect. It shows a thin sheet of semiconducting material (Hall element) through which a current is passed. The output connections are perpendicular to the direction of current. When no magnetic field is present (Figure 1), current distribution is uniform and no potential difference is seen across the output. When a perpendicular magnetic field is present, as shown in Figure 2, a Lorentz

force i exerted on t e current Thi force di turbs the current distribution, resulting in a potential difference (voltage) across the output This voltage is the Hall voltage (VH). The interaction of the magnetic field and the current is shown in equation form as :
VH wI vB

Figure 1: Hall Effect principle, no magnetic field

Figure 2: Hall Effect principle, magnetic field present

Our Hall Effect sensors characteristic is depicted below;


Output voltage of Hall effect (mV) 0 1,7 3,8 5,8 9,6 13,9 14,8 16,2 18,4 20,1 22 24,3 27,2 29,2 30,9 32,9 34,8 36,6 38,6 40,5 42,5 44,6 46,5 48,5 50,3 52,7 Current Value (mA) 60 83,5 107 130 174 200 210 220 240 260 280 300 330 350 370 390 410 420 450 465 485 505 525 550 569 590 Ratio of sensor output voltage and current value Inf 49,1176470588235 28,1578947368421 22,4137931034483 18,1250000000000 14,3884892086331 14,1891891891892 13,5802469135802 13,0434782608696 12,9353233830846 12,7272727272727 12,3456790123457 12,1323529411765 11,9863013698630 11,9741100323625 11,8541033434650 11,7816091954023 11,4754098360656 11,6580310880829 11,4814814814815 11,4117647058824 11,3228699551570 11,2903225806452 11,3402061855670 11,3121272365805 11,1954459203036

Table 1: output voltage of sensor with respect to input current value

Figure 3: Characteristic curve of Hall Effect sensor

Application:
We started to set the circuit up step by step. First week, to warm up the C program language and MCU, we toggled a LED. Later, ADC control codes are written. After implementing the circuit on board, system didnt work. Some research indicates that, ADC needs extra clock cycle for processing independent from MCU. Connection of 500 KHz signal satisfied to work our circuit. While doing that we, simultaneously, search how communicate with MCU and PC. RS232 which we know also before provide to communicate the PC and MCU. Coding process so easy but in the circuit system was in failure. Lengthy attempt about failure show that baud rate value must be F3H in circuit but F4H in simulation. Heretofore, our system included RS232 and ADC. Now, it is time to integrate the LCD to the circuit. In first attempt, we didnt connect the LCD properly. But after investigating the connection carefully, LCD worked with 2 lines. Reading and monitoring namely MCU part of the system was ready. Now, measuring part of the system was to build. During the implementation process, we first decided to use analog multiplexer (MUX) in order to measure each battery voltage referenced to the ground. But when we connect the voltages which multiplexer IC couldnt support to MUX, an explosion occurred. Hence, we decided to use another method which must be safe in compare to hardware connection. In order to achieve that, summation of all voltage levels are connected to voltage divider circuit. Thus, coming voltage levels are reduced to 5V which is suitable for ADC IC. Consequently, codes in the MCU were changed in order to calculate exact voltage levels. Current flew through the 32.5 metal-cooled low-value resistor was measured by Hall Effect sensor. This sensor gave us only mV voltage levels so that it should be scaled up to suitable values for ADC. In order to that, LM324 was used which amplified the input value to 36 times bigger than before. Amplifying constant was selected 36 because of ICs capabilities. Because of the characteristic of Hall Effect sensor, maximum coming voltage to MCU can be 150mV so that amplifying constant is suitable for whole system. After amplifying the current value, MCU read this level in range of 0-5V. In code, coming value first divided by 36 after that multiplied a constant which can be obtain from Voltage-Current curve of the Hall Effect sensor. Sensor output respect to the input obtained by experimental because the datasheet belong it is absent. Due to the fact that exact result of current value

couldnt be read. On the other hand, in low levels of voltage and current, because of the ADCs resolution value, losses can occur while data distribution. Here is the schematic representation of the whole system;

Figure 4: Schematic representation of the whole system Shortly, inputs of the analog-digital converter are voltage levels which is out of the voltage divider circuit and current level which is measured by Hall Effect sensor MC . controls the ADC and get the digital data converted by ADC and calculate them. MC to another value. Hence MC through RS232. not only read the data but also calculate them because the coming values are converted or reduced also recalculate them and show them on the LCD and PC

Result:
Here is the some photographs of the system wh it is set up on the board. We first en tried to get any data which means it doesnt have to cover a meaningful data on LCD and PC. In first photograph we have also an ADC IC which is controlled by microcontroller.

Photograph 1 After implementing the system individually, we combine parts and tried to get meaningful data. In photograph 2, we set the voltage divider circuit up and connected to ADC. Voltage levels of the voltage divider circuit can be shown on LCD. However, Hall Effect sensor wasnt connected to circuit so that the current value couldnt be shown.

Photograph 2 Here is the battery system of the whole system (Photograph 3). Switches are used to control of the current which flow through 32 metal-cooled low-value resistors. In front of the batteries, voltage divider circuits are located.

Photograph 3

Photograph 4 Final part of the system which is combined to the system at last is Hall Effect sensor. As it is shown in photograph 4, Hall Effect sensors characteristic curve is obtained by experiment. By using this curve, coefficients are determined to show correct values of the measured data.

10

Photograph 5

Photograph 6

11

Photograph 5 and 6 are the whole systems photos. While supplying the whole system, we used AC/DC converter which converts the AC 220V to the DC 0,5V and +12, 12V. Hall Effect sensor needs +12 and -12V and the other boards need 0, +5V. System only used a clock cycle from signal generator. If we can achieve to produce 500 KHz clock cycle, system will work only connecting the AC/DC converter to the grid.

Photograph 7 High current value flows through the metal-cooled low-value resistor so that a cooling needs to reduce the heat on the resistor. In order to avoid overheating, a fan which also includes metal-cooling is combined to the system. Because the fan needs DC 12V voltage, we use different two batteries which support 6V each. Cooling system can be seen in photograph 7.

12

Photograph 8

Photograph 9

13

Conclusion:
As a result, theory can be implemented in real world, but some unexpected situation may occur. This is because of non-ideal structure of electronic devices used in the system. Also limited capacities of such devices reduce to accu racy of whole system. This project shows us in spite of some difficulties, implementation of such system suitable for applications. In theory, we predicted to use analog multiplexer to connect each batteries to ground respectively. But capability of the multiplexer IC is too low to satisfy this condition, so that voltage divider circuit was used to get voltage values. This circuit has disadvantages such as voltage losses on the resistors and addition multiplier needs to get correct values after measured. Also in simulation, all conditions are assumed ideal. Hence, while implementing the circuit, awareness must be in top. Otherwise unfused system can cause fire. For instances, all ground must be common to provide wanted voltage levels. After overall system is implemented, we reach some results. Our Hall Effect sensor doesnt produce linear output voltage values according to different current values. This sensor is not suitable for lower current values. Because ratio of output voltage and measured current is increased while current value is decreased. Another problem is about ADC0808. ADC0808 has 8-bit output, so resolution of ADC is nearly 0.019. This value is lower to measure small change of current and voltage values. Battery management system should include more than one Hall Effect sensor, because system is measured current values of all batteries. But our system has only one Hall Effect sensor and we measured current of overall system. Finally, for design better system we choose more linear Hall Effect sensor and suitable ADC which it has more than 8-bit output for high resolution.

14

References:
1. 2. M.A.Mazidi, J.G.Mazidi, R.D.Mck nlay, The 8051 Microcontroller and Embedded Systems, Second Eddition, 2006 H. Gm kaya Mikroi lemciler ve 8051 Ailesi 5.Bas m, 2002 3. I.Scott MacKenzie, The 8051 Microcontroller, Third Edition, 1995

15

Appendix-A:
Microcontroller codes; #include<regx52.h> #include <stdio.h> #include "lcd.h" void MSDelay(unsigned int); unsigned int ADC(void); char olcum[15]; sbit ALE=P3^5; sbit OE=P3^4; sbit Start=P3^7; sbit EOC=P3^3; sbit led_pin=P2^7; sbit ADD_A=P2^6; sbit ADD_B=P2^5; sbit ADD_C=P2^4; void main() { signed int c_deger,c_deger1,c_deger2,c_deger3,c_deger4; // LCD ktphanesi eklenmistir.

16

float goster,goster1,goster2,goster3,akim,akim_1,akim_2,goster_1,goster_2,goster_3,goster_4; TMOD |= 0x20; TH1 = 0xF3; SCON = 0x40; TR1 = 1; TI = 1; lcdac(); // 401 MICROCONTROLLER Komut(birincisatir); Veridizi(" EE401 //birinci satir aktif ",500); //ikinci satir aktif /* TMOD: timer 1, mode 2, 8 -bit reload */

/* TH1: reload value for 2400 baud @ 11.0592MHz */ /* SCON: mode 1, 8 -bit UART, enable rcvr /* TR1: timer 1 run */ */ */

/* TI: set TI to send first char of UART

Komut(ikincisatir);

Veridizi(" MICROCONTROLLER ",500); MSDelay(100); Komut(sil); // GROUP ismi Komut(birincisatir); Veridizi(" Group 1A //birinci satir aktif ",500);

MSDelay(50); Komut(sil); //ISIM 1 Komut(birincisatir); //birinci satir aktif

Veridizi(" Ahmet Esat GENC",500);

17

Komut(ikincisatir);

//ikinci satir aktif

Veridizi(" 2006502020",500); MSDelay(50); Komut(sil); //ISIM 2 Komut(birincisatir); //birinci satir aktif

Veridizi("Mehmet KARABUDAK",500); Komut(ikincisatir); //ikinci satir aktif

Veridizi(" 2006502028",500); MSDelay(50); Komut(sil); //ISIM3 Komut(birincisatir); //birinci satir aktif

Veridizi(" Ozgur M. DUMAN",500); Komut(ikincisatir); //ikinci satir aktif

Veridizi(" 2005502020",500); MSDelay(50); Komut(sil);

while(1) {

//Akim

18

ADD_A=0; ADD_B=0; ADD_C=1; c_deger4=ADC(); akim=c_deger4*0.01960784313725490196078431372549; akim_1=akim/36; akim_2=akim_1*13; MSDelay(1);

// ADD_A=0; ADD_B=0; ADD_C=0; //Komut(birincisatir); c_deger=ADC(); //birinci satir aktif //ADCde okunan degeri c_degere ata

goster=(float)c_deger*0.01960784313725490196078431372549; // goster=5V MSDelay(1); Komut(sil);

// toggle led_pin=1; MSDelay(50); led_pin=0;

19

//Akim ADD_A=0; ADD_B=0; ADD_C=1; c_deger4=ADC(); akim=c_deger4*0.01960784313725490196078431372549; akim_1=akim/36; akim_2=akim_1*13; MSDelay(1);

// CELL-4 ADD_A=1; ADD_B=0; ADD_C=0; Komut(birincisatir); c_deger1=ADC(); // birinci satir aktif //ADCde okunan degeri c_degere ata //

goster1=(float)c_deger1*0.01960784313725490196078431372549; goster1=3,75V goster_1=goster-goster1; goster_1=goster_1*11.5; MSDelay(1); printf ("CELL-4 Voltage=%.3f V yazma ",goster_1); //

Seri

porttan

20

printf ("CURRENT=%.3f A\n\n",akim_2); sprintf(olcum,"CELL-4 V=%.3f V",goster_1); Veridizi(olcum,0); Komut(ikincisatir); sprintf(olcum,"CURRENT=%.3f A",akim_2); Veridizi(olcum,0); MSDelay(100); Komut(sil); //LCD ye yazma

// toggle led_pin=1; MSDelay(50); led_pin=0;

//Akim ADD_A=0; ADD_B=0; ADD_C=1; c_deger4=ADC(); akim=c_deger4*0.01960784313725490196078431372549; akim_1=akim/36; akim_2=akim_1*13; MSDelay(1);

21

// 45V ADD_A=0; ADD_B=1; ADD_C=0; Komut(birincisatir); c_deger2=ADC(); //ADCde okunan degeri c_deger2e ata

goster2=(float)c_deger2*0.01960784313725490196078431372549; //goster2=2,5V goster_2=goster1-goster2; goster_2=goster_2*11.5; MSDelay(1); printf ("CELL-3 Voltage=%.3f V ",goster_2); // Seri porttan yazma

printf ("CURRENT=%.3f A\n\n",akim_2); sprintf(olcum,"CELL-3 V=%.3f V",goster_2); Veridizi(olcum,0); Komut(ikincisatir); sprintf(olcum,"CURRENT=%.3f A",akim_2); Veridizi(olcum,0); MSDelay(100); Komut(sil); //LCD ye yazma

// toggle

22

led_pin=1; MSDelay(50); led_pin=0;

//Akim ADD_A=0; ADD_B=0; ADD_C=1; c_deger4=ADC(); akim=c_deger4*0.01960784313725490196078431372549; akim_1=akim/36; akim_2=akim_1*13; MSDelay(1);

// 30V ADD_A=1; ADD_B=1; ADD_C=0; Komut(birincisatir); c_deger3=ADC(); //ADCde okunan degeri c_deger3e ata //voltaj

goster3=(float)c_deger3*0.01960784313725490196078431372549; degeri hesaplama goster_3=goster2-goster3;

23

goster_3=goster_3*11.5; MSDelay(1); printf ("CELL-2 Voltage=%.3f V yazma printf ("CURRENT=%.3f A\n\n",akim_2); sprintf(olcum,"CELL-2 V=%.3f V",goster_3); Veridizi(olcum,0); Komut(ikincisatir); sprintf(olcum,"CURRENT=%.3f A",akim_2); Veridizi(olcum,0); MSDelay(150); Komut(sil); //LCD ye yazma ",goster_3); // Seri porttan

//Akim ADD_A=0; ADD_B=0; ADD_C=1; c_deger4=ADC(); akim=c_deger4*0.01960784313725490196078431372549; akim_1=akim/36; akim_2=akim_1*13; MSDelay(1);

24

//15V goster_4=goster3; goster_4=goster_4*11.5; printf ("CELL-1 Voltage=%.3f V yazma printf ("CURRENT=%.3f A\n\n",akim_2); sprintf(olcum,"CELL-1 V=%.3f V",goster_4); Veridizi(olcum,0); Komut(ikincisatir); sprintf(olcum,"CURRENT=%.3f A",akim_2); Veridizi(olcum,0); MSDelay(100); Komut(sil); } } unsigned int ADC(void) { unsigned int cevrilen_deger; //P1=0xFF; EOC=1; ALE=0; OE=0; Start=0; // P1 input //P3.6 input //clear ale //clear oe //clear sc //LCD ye yazma ",goster_4); // Seri porttan

25

MSDelay(1); ALE=1; MSDelay(1); Start=1; MSDelay(1); ALE=0; Start=0; while (EOC==1); while (EOC==0); OE=1; MSDelay(1); cevrilen_deger=P1; OE=0; return(cevrilen_deger); } //enable read //start conversion //wait for data conversion

void MSDelay(unsigned int itime) { unsigned int i,j=0; for(i=0;i<itime;i++) for(j=0;j<1275;j++); }

26

You might also like