battery management system(bms)ee401 final report

26
 EE401-Microcontrollers Battery Management System with Hall Effect Current Meter 2004502020 Özgür M. DUMAN 2006502020 A. Esat GENÇ 2006502028Mehmet KARABUDAK  10.03.2011

Upload: ozgur-m-duman

Post on 07-Apr-2018

226 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Battery Management System(BMS)EE401 Final Report

8/6/2019 Battery Management System(BMS)EE401 Final Report

http://slidepdf.com/reader/full/battery-management-systembmsee401-final-report 1/26

 

EE401-Microcontrollers

Battery Management System with Hall

Effect Current Meter 

2004502020 Özgür M. DUMAN2006502020 A. Esat GENÇ

2006502028Mehmet KARABUDAK  

10.03.2011

Page 2: Battery Management System(BMS)EE401 Final Report

8/6/2019 Battery Management System(BMS)EE401 Final Report

http://slidepdf.com/reader/full/battery-management-systembmsee401-final-report 2/26

 

2

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 doesn¶t 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 don¶t do that,

 providing energy by batteries will reduce and losses will increase.

Our system couldn¶t 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 measurethe 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.

Page 3: Battery Management System(BMS)EE401 Final Report

8/6/2019 Battery Management System(BMS)EE401 Final Report

http://slidepdf.com/reader/full/battery-management-systembmsee401-final-report 3/26

 

3

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 don¶t 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 boththe 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

Page 4: Battery Management System(BMS)EE401 Final Report

8/6/2019 Battery Management System(BMS)EE401 Final Report

http://slidepdf.com/reader/full/battery-management-systembmsee401-final-report 4/26

 

4

force i exer ted on t e current Thi force di turbs the current distr i bution, resulting in a

 potential difference (voltage) across the out put This voltage is the Hall voltage (VH). The

interaction of the magnetic f ield and the current is shown in equation form as:

VH wI vB 

Figure 1: Hall Effect pr inci ple, no magnetic f ield

Figure 2: Hall Effect pr inci ple, magnetic f ield present 

Page 5: Battery Management System(BMS)EE401 Final Report

8/6/2019 Battery Management System(BMS)EE401 Final Report

http://slidepdf.com/reader/full/battery-management-systembmsee401-final-report 5/26

 

5

Our Hall Effect sensor¶s character istic is depicted below; 

Output voltage of 

Hall eff ect (mV)

Current Value 

(mA)

R atio of sensor output 

voltage and current value 

0 60 Inf 

1,7 83,5 49,1176470588235

3,8 107 28,15789473684215,8 130  22,4137931034483 

9,6 174 18,1250000000000 

13,9 200 14,3884892086331

14,8 210 14,1891891891892 

16,2  220 13,5802469135802 

18,4 240 13,0434782608696

20,1 260 12,9353233830846

22  280 12,7272727272727

24,3  300 12,3456790123457

27,2  330 12,1323529411765

29,2  350 11,9863013698630 

30,9 370 11,9741100323625

32,9 390 11,8541033434650 

34,8 410 11,7816091954023 

36,6 420 11,4754098360656

38,6 450 11,6580310880829

40,5 465 11,4814814814815

42,5 485 11,4117647058824

44,6 505 11,3228699551570 

46,5 525 11,2903225806452 

48,5 550 11,3402061855670 

50,3 569 11,3121272365805

52

,7 590

11,195445920303

6Table 1: out put voltage of sensor with respect to input current value

 

Figure 3: Character istic curve of Hall Effect sensor 

Page 6: Battery Management System(BMS)EE401 Final Report

8/6/2019 Battery Management System(BMS)EE401 Final Report

http://slidepdf.com/reader/full/battery-management-systembmsee401-final-report 6/26

 

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 didn¶t 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 didn¶t 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 couldn¶t 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

Page 7: Battery Management System(BMS)EE401 Final Report

8/6/2019 Battery Management System(BMS)EE401 Final Report

http://slidepdf.com/reader/full/battery-management-systembmsee401-final-report 7/26

 

7

couldn¶t be read. On the other hand, in low levels of voltage and current, because of  the

ADC¶s resolution value, losses can occur while data distr i bution.

Here is the schematic representation of the whole system; 

Figure 4: Schematic representation of the whole system

Shor tly, inputs of  the analog-digital conver ter 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 conver ted by ADC and calculate them. MC not 

only read the data but also calculate them because the coming values are conver ted or reduced

to another value. Hence MC also recalculate them and show them on the LCD and PC 

through R S232.

Page 8: Battery Management System(BMS)EE401 Final Report

8/6/2019 Battery Management System(BMS)EE401 Final Report

http://slidepdf.com/reader/full/battery-management-systembmsee401-final-report 8/26

 

8

R esult: 

Here is the some photographs of  the system when it  is set up on the board. We f irst 

tr ied to get any data which means it doesn¶t have to cover a meaningful data on LCD and PC.

In f irst photograph we have also an ADC IC which is controlled by microcontroller.

Photograph 1

Af ter  implementing the system individually, we combine par ts and tr ied 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 wasn¶t connected to circuit so that the current value couldn¶t be shown.

Page 9: Battery Management System(BMS)EE401 Final Report

8/6/2019 Battery Management System(BMS)EE401 Final Report

http://slidepdf.com/reader/full/battery-management-systembmsee401-final-report 9/26

 

9

Photograph 2

Here is the battery system of the whole system (Photograph 3). Switches are used to

control of the current which f low through 32� metal-cooled low-value resistors. In front of 

the batter ies, voltage divider circuits are located.

Photograph 3

Page 10: Battery Management System(BMS)EE401 Final Report

8/6/2019 Battery Management System(BMS)EE401 Final Report

http://slidepdf.com/reader/full/battery-management-systembmsee401-final-report 10/26

 

10 

Photograph 4

Final par t of the system which is combined to the system at last is Hall Effect sensor.

As it  is shown in photograph 4, Hall Effect sensor¶s character istic curve is obtained byexper iment. By using this curve, coeff icients are determined to show correct values of  the

measured data.

Page 11: Battery Management System(BMS)EE401 Final Report

8/6/2019 Battery Management System(BMS)EE401 Final Report

http://slidepdf.com/reader/full/battery-management-systembmsee401-final-report 11/26

 

11

Photograph 5

Photograph 6

Page 12: Battery Management System(BMS)EE401 Final Report

8/6/2019 Battery Management System(BMS)EE401 Final Report

http://slidepdf.com/reader/full/battery-management-systembmsee401-final-report 12/26

 

12 

Photograph 5 and 6 are the whole system¶s photos. While supplying the whole system,

we used AC/DC conver ter which conver ts 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 conver ter to the gr id.

Photograph 7

High current value f lows 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 batter ies which suppor t 6V each. Cooling system can be seen in photograph

7.

Page 13: Battery Management System(BMS)EE401 Final Report

8/6/2019 Battery Management System(BMS)EE401 Final Report

http://slidepdf.com/reader/full/battery-management-systembmsee401-final-report 13/26

 

13 

Photograph 8

Photograph 9

Page 14: Battery Management System(BMS)EE401 Final Report

8/6/2019 Battery Management System(BMS)EE401 Final Report

http://slidepdf.com/reader/full/battery-management-systembmsee401-final-report 14/26

 

14 

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 accuracy 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 

doesn¶t 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.

Page 15: Battery Management System(BMS)EE401 Final Report

8/6/2019 Battery Management System(BMS)EE401 Final Report

http://slidepdf.com/reader/full/battery-management-systembmsee401-final-report 15/26

 

15 

R eferences: 

1.  M.A.Mazidi, J.G.Mazidi, R.D.Mcknlay, µThe 8051 Microcontroller and Embedded

Systems¶, Second Eddition, 2006

2.  H. Gümükaya µMikroilemciler ve 8051 Ailesi¶ 5.Basm, 2002

3.  I.Scott MacKenzie, µThe 8051 Microcontroller¶, Third Edition, 1995

Page 16: Battery Management System(BMS)EE401 Final Report

8/6/2019 Battery Management System(BMS)EE401 Final Report

http://slidepdf.com/reader/full/battery-management-systembmsee401-final-report 16/26

 

16 

Appendix-A:

Microcontroller codes;

#include<regx52.h>

#include <stdio.h>

#include "lcd.h" // LCD kütüphanesi eklenmistir.

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;

Page 17: Battery Management System(BMS)EE401 Final Report

8/6/2019 Battery Management System(BMS)EE401 Final Report

http://slidepdf.com/reader/full/battery-management-systembmsee401-final-report 17/26

 

17 

float

goster,goster1,goster2,goster3,akim,akim_1,akim_2,goster_1,goster_2,goster_3,goster_4;

TMOD |= 0x20; /* TMOD: timer 1, mode 2, 8 -bit reload */

TH1 = 0xF3; /* TH1 : reload value for 2400 baud @ 11.0592MHz */

SCON = 0x40; /* SCON: mode 1, 8 -bit UART, enable rcvr */

TR1 = 1; /* TR1: timer 1 run */

TI = 1; /* TI: set TI to send first char of UART */

lcdac();

// 401 MICROCONTROLLER 

Komut(birincisatir); //birinci satir aktif 

Veridizi(" EE401 ",500);

Komut(ikincisatir); //ikinci satir aktif 

Veridizi(" MICROCONTROLLER ",500);

MSDelay(100);

Komut(sil);

// GROUP ismi

Komut(birincisatir); //birinci satir aktif 

Veridizi(" Group 1A ",500);

MSDelay(50);

Komut(sil);

//ISIM 1

Komut(birincisatir); //birinci satir aktif 

Veridizi(" Ahmet Esat GENC",500);

Page 18: Battery Management System(BMS)EE401 Final Report

8/6/2019 Battery Management System(BMS)EE401 Final Report

http://slidepdf.com/reader/full/battery-management-systembmsee401-final-report 18/26

 

18 

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

Page 19: Battery Management System(BMS)EE401 Final Report

8/6/2019 Battery Management System(BMS)EE401 Final Report

http://slidepdf.com/reader/full/battery-management-systembmsee401-final-report 19/26

 

19 

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); //birinci satir aktif 

c_deger=ADC(); //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;

Page 20: Battery Management System(BMS)EE401 Final Report

8/6/2019 Battery Management System(BMS)EE401 Final Report

http://slidepdf.com/reader/full/battery-management-systembmsee401-final-report 20/26

 

20 

//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); // birinci satir aktif 

c_deger1=ADC(); //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 ",goster_1); // Seri porttan

yazma

Page 21: Battery Management System(BMS)EE401 Final Report

8/6/2019 Battery Management System(BMS)EE401 Final Report

http://slidepdf.com/reader/full/battery-management-systembmsee401-final-report 21/26

 

21 

 printf ("CURRENT=%.3f A\n\n",akim_2);

sprintf(olcum,"CELL-4 V=%.3f V",goster_1); //LCD ye yazma

Veridizi(olcum,0);

Komut(ikincisatir);

sprintf(olcum,"CURRENT=%.3f A",akim_2);

Veridizi(olcum,0);

MSDelay(100);

Komut(sil);

// 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);

Page 22: Battery Management System(BMS)EE401 Final Report

8/6/2019 Battery Management System(BMS)EE401 Final Report

http://slidepdf.com/reader/full/battery-management-systembmsee401-final-report 22/26

 

22

// 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); //LCD ye yazma

Veridizi(olcum,0);

Komut(ikincisatir);

sprintf(olcum,"CURRENT=%.3f A",akim_2);

Veridizi(olcum,0);

MSDelay(100);

Komut(sil);

// toggle

Page 23: Battery Management System(BMS)EE401 Final Report

8/6/2019 Battery Management System(BMS)EE401 Final Report

http://slidepdf.com/reader/full/battery-management-systembmsee401-final-report 23/26

 

23

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

goster3=(float)c_deger3*0.01960784313725490196078431372549; //voltaj

degeri hesaplama

goster_3=goster2-goster3;

Page 24: Battery Management System(BMS)EE401 Final Report

8/6/2019 Battery Management System(BMS)EE401 Final Report

http://slidepdf.com/reader/full/battery-management-systembmsee401-final-report 24/26

 

24 

goster_3=goster_3*11.5;

MSDelay(1);

  printf ("CELL-2 Voltage=%.3f V ",goster_3); // Seri porttan

yazma

 printf ("CURRENT=%.3f A\n\n",akim_2);

sprintf(olcum,"CELL-2 V=%.3f V",goster_3); //LCD ye yazma

Veridizi(olcum,0);

Komut(ikincisatir);

sprintf(olcum,"CURRENT=%.3f A",akim_2);

Veridizi(olcum,0);

MSDelay(150);

Komut(sil);

//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);

Page 25: Battery Management System(BMS)EE401 Final Report

8/6/2019 Battery Management System(BMS)EE401 Final Report

http://slidepdf.com/reader/full/battery-management-systembmsee401-final-report 25/26

 

25 

//15V

goster_4=goster3;

goster_4=goster_4*11.5;

  printf ("CELL-1 Voltage=%.3f V ",goster_4); // Seri porttan

yazma

 printf ("CURRENT=%.3f A\n\n",akim_2);

sprintf(olcum,"CELL-1 V=%.3f V",goster_4); //LCD ye yazma

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; // P1 input

EOC=1; //P3.6 input

ALE=0; //clear ale

OE=0; //clear oe

Start=0; //clear sc

Page 26: Battery Management System(BMS)EE401 Final Report

8/6/2019 Battery Management System(BMS)EE401 Final Report

http://slidepdf.com/reader/full/battery-management-systembmsee401-final-report 26/26

MSDelay(1);

ALE=1;

MSDelay(1);

Start=1;

MSDelay(1);

ALE=0;

Start=0; //start conversion

while (EOC==1); //wait for data conversion

while (EOC==0);

OE=1; //enable read

MSDelay(1);

cevrilen_deger=P1;

OE=0;

return(cevrilen_deger);

}

void MSDelay(unsigned int itime)

{

unsigned int i,j=0;

for(i=0;i<itime;i++)

for(j=0;j<1275;j++);

}