Table of Content: Digital Ohmmeter
Table of Content: Digital Ohmmeter
Table of Content
Page number Abstract 1.0 Introduction 1.1 Program Description 1.2 Hardware Description 1.3 Block Diagram of Digital Ohmmeter 2.0 Algorithm Flow Chart 3.0 4.0 5.0 6.0 7.0 Software Description Project Result Conclusion Reference Software Listing Coding for this project Schematic Diagram 21 24 4 5 7 8 9 13 16 19 20 3
Digital Ohmmeter
Abstract
A digital ohmmeter is an electrical instrument that used to measured resistance in electronics. In this mini project, the task given is to design a digital ohmmeter by using 8051 Microcontroller Board and external circuit contains chip ADC 0831 and LCD 2x16 characters. The result of resistance value is shown in LCD. Theory of voltage divider is used to determine the value of resistor measured. The range of resistor measured is set from 1k to 1M. Program is written using Keil uVision2 in the form of c program. After the program is compiled, the program will executed by using 8051 Microcontroller Board. Schematic diagram and flow chart of this project are included in this report.
Digital Ohmmeter
1.0 Introduction
1.1 Program Description In this mini project, ADC 0831 is used to convert the input voltage into 8-bit binary numbers. After getting data from ADC 0831, the 8-bit binary value is then converted into resistance value by using calculation of voltage divider theory. The resistance value is then show in LCD. The software used for this mini project is Keil uVision2 and Flash Magic. Program is written in the form of c program. Basic Concepts and Theory of Voltage Divider (Potential Divider) In electronics, a voltage divider (also known as a potential divider) is a simple linear circuit that produces an output voltage, Vout that is a fraction of its input voltage, Vin. Voltage division refers to the partitioning of a voltage among the components of the divider. The basic circuit for a voltage divider for resistor in series is shown below. Vin Rreference Vout Rmeasure
In this circuit the two resistor are connected in series across Vin, which is the power supply voltage connected to the resistor, Rreference, where the output voltage Vout is the voltage across the resistor Rmeasure which is given by the formula. If more resistors are connected in series to the circuit, the different voltages will appear across each resistor with regards to their individual resistance providing different voltage points from a single supply. Vout can be calculated by using voltage divider formula:
Digital Ohmmeter
1.2 Hardware Description 2x16 Characters LCD Liquid Crystal Display (LCD) is very helpful in providing user interface as well as for debugging purpose. The most common type of LCD controller is HD44780 which provides a simple interface between the controller & an LCD.
Figure: Character LCD type HD44780 pin diagram Pin no. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 Name VSS VDD VEE RS RW E D1 D2 D3 D4 D5 D5 D6 D7 Description Power supply (GND) Power supply (+5V) Contrast adjust 0 = Instruction input 1 = Data input 0 = write to LCD module 1 = Read from LCD module Enable signal Data bus line (LSB) Data bus line 1 Data bus line 2 Data bus line 3 Data bus line 4 Data bus line 5 Data bus line 6 Data bus line (MSB)
ADC0831 The ADC0831 series are 8-bit successive approximation Analogue/Digital converters with a serial I/O and configurable input multiplexers with up to 8 channels. The data output is 8-bit binary value and is between 0 up to 255 decimal. The gaps between bits by bits are referred to Vref that determine by user.
Digital Ohmmeter
8051 Microcontroller Board A microcontroller is a single chip microprocessor system which contains a processor core, data and program memory, serial and parallel I/O, timers, external and internal interrupt handling mechanism.
Other equipment that needed in this project: 1. Wires 2. Different values of resistors between 100 to 1M 3. Power supply 4. RS232 connector 5. Breadboard
Digital Ohmmeter
Power supply
LCD DISPLAY . . .
16
. . .
Digital Ohmmeter
2.0 Algorithm
The calculation involved in this program is mainly use voltage divider theorem. Vin = 5V Rreference = 33k Rmeasure
Vout
In this project, Vin is set to 5V and Rreference is set to 33k. Rreference is determined by setting the range of measure the resistance. Range to measure the resistance is set between 1k to 1M.
By using the above formula, Rreference is equal to 31.6k by using range 1k to 1M. Rreference is set to 33k because this value is near to 31.6k. Rmeasure can be calculated by using formula below:
The value of Vo in voltage divider circuit is converted to binary value by using ADC0831. The 8051 microcontroller is getting binary value from ADC0831 when the program is running. To convert binary value to Vo, formula below is used. x = binary value from ADC0831 For example, if the value of x is 128, Rmeasure is equal to 33.27k. Steps to getting Rmeasuse are shown below:
Digital Ohmmeter
f=0
f<3
True
False
Delay 1 second
Display
Delay 1 second
f++
While (1)
k=0
k<8 False A
True
k++
B
9
Digital Ohmmeter
CS = 1
Delay 1 second
10
Digital Ohmmeter
Delay 1 second
11
Digital Ohmmeter
Digital Ohmmeter
is set to Port 3.6 and E (Chip Enable Signal) in set to Port 3.7. The declaration of ports is shown below.
In void main(void) function, Digital Ohmmeter and 1k <<-->> 1M ohm is set and shown in LCD address 80 and C0. After that, it will blink 3 times and each time will delay 1 second. Coding of this section is shown below.
After the display character of Digital Ohmmeter, the value of output of ADC0831 is declared as variable x. To get output data from ADC0831, chip select ( ) is set to zero. Clock pulse is then set to 1 and 0. It is used to get negative trigger clock pulse and then to get the value of D0. After that, the first value of D0 which is MSB of 8-bit output is shift to left by bit and then set in or condition in bit with D0. As the value of D0 is out with bit by bit, the step above is using 8 times. It is because the output of ADC0831 is in series mode. After the steps is finish, is set to zero. While(1) is used continue the loop the program. Coding of this section is shown in figure below.
13
Digital Ohmmeter
After the value of x is finish get from ADC0831, calculation is used to get the Vout of the input of ADC0831. Value of Vout is used to calculate the Rmeasure by using voltage divider method. The coding to calculate Rmeasure is shown in below.
The value of Rmeasure is shown in LCD by using various statements. It is used to display the value of Rmeasure in different mode. If the value of Rmeasure is less than 1k, the LCD will display out of range because the range of this digital ohmmeter is between 1k to 1M. If Rmeasure is between 1k to 100k, the output shown in LCD is in 2 decimal points. If Rmeasure is between 100k to 1M, the output shown in LCD is in 1 decimal point. . If the value of Rmeasure is more than 1M, the LCD will display out of range.
After the value of Rmeasure is achieved in previous condition, the output is shown in LCD. The output of display is refreshed every 1 second.
The function of delay1s() is used to delay the output every 1 second. Mode of timer T0 and T1 is first set to mode 1. For loop is set to 20 times because the internal timer used is 1.085s, and the maximum timer that can be used in internal timer is 50ms. TH0 and TL0 is set to 4BH and FEH because the counter for looping in 50ms is 19454 times. After minus with 65536 which is FFFF in hexadecimal, the value of 46082 which is 4BFE in hexadecimal is used to start the timer counter. After the counter is count to FFFFH, TF0 will count to 1 and
14
Digital Ohmmeter
TH0 and TL0 is reset to 0. The process is continuing for 20 times so that 1 second of time is count.
15
Digital Ohmmeter
The title of Digital Ohmmeter and accepted range to measure resistor is shown.
16
Digital Ohmmeter
When 3.3k is inserted in the circuit, the result shown in LCD is 3.27k.
When 47k is inserted in the circuit, the result shown in LCD is 47.14k.
17
Digital Ohmmeter
When 470k is inserted in the circuit, the result shown in LCD is 528.0k.
The result of this project is mainly successfully showing the value of resistor measured. For this project, it is hard to detect whether the measured resistor in circuit or not because when the resistor measured is not inserted in circuit, the output of Vout is exceed 5.0V. The ADC0831 is then converting value to 255 in binary value and the value of 255 is exceeding the range of measured resistor. The output of display in LCD will show out of range because the value of resistor measured is exceed 1M after the calculation of theory of voltage divider.
5.0 Conclusion
18
Digital Ohmmeter
As conclusion, I learned that how to set up a digital ohmmeter by using voltage divider method to calculate the resistance measured. I also learned how to interfacing LCD to 8051 microcontroller. The function of ADC0831 is learned from this project. The results that get from this project are mainly satisfied and achieved the goal that I had set. The further investigation that can be done in this project is by using indicator to control the chip select of ADC0831. In order to solve the inserting resistor measured problem, an external hardware that is indicator is used to control the chip select when a measured resistor is inserted into circuit.
6.0 References
Microcontroller
19
Digital Ohmmeter
http://www.engineersgarage.com/microcontroller Theory of voltage divider http://www.kpsec.freeuk.com/vdivider.htm http://www.electronics-tutorials.ws/resistor/res_3.html http://www.smartcontroller.com.au/publications/voltagedivider.htm Interfacing LCD to 8051 http://www.dnatechindia.com/index.php/Tutorials/8051-Tutorial/InterfacingLCD.html http://www.8051projects.net/lcd-interfacing/introduction.php ADC 0831 http://www.national.com/mpf/DC/ADC0831.html#Overview http://www.national.com/ds/DC/ADC0831.pdf
Rreference
Digital Ohmmeter
#include<reg51.h> #include<stdio.h> #include<string.h> sbit CS = P1^0; sbit CLK = P1^1; sbit D0 = P1^2; sbit RS = P3^5; sbit RW = P3^6; sbit E = P3^7; sfr dat = 0xA0; unsigned int x,i; void delay(void); void LCD_cmd(unsigned char x); void LCD_wr(unsigned char x); void initLCD(void); void delay1s(void); void main(void) { unsigned char y[16]; unsigned char z[16]; unsigned int j,k,f; float V,a,R,b; for(f=0;f<3;f++) { sprintf(y,"Digital Ohmmeter"); sprintf(z,"1k <<-->> 1M ohm"); initLCD(); LCD_cmd(0x80); for(i=0;i<16;i++) LCD_wr(y[i]); LCD_cmd(0xc0); for(j=0;j<16;j++) LCD_wr(z[j]); delay1s(); sprintf(y," "); initLCD(); LCD_cmd(0x80); for(i=0;i<16;i++) LCD_wr(y[i]); LCD_cmd(0xc0); for(j=0;j<16;j++) LCD_wr(y[j]); delay1s(); } while(1) { CS=0; CLK=1; CLK=0; x=0; for(k=0;k<8;k++)
21
Digital Ohmmeter
{ CLK=1; CLK=0; x=(x<<1)|D0; } CS=1; a=(float) x; V=(5.0/255.0)*a; b=V*33000.0/(5.0-V); if(b>=0.0 && b<1000.0) { sprintf(y," resistor < 1k "); sprintf(z," out of range "); } else if(b>=1000.0 && b<100000.0) { R=b/1000.0; sprintf(y," resistance "); sprintf(z," R = %.2fk ohm ",R); } else if(b>=100000.0 && b<1000000.0) { R=b/1000.0; sprintf(y," resistance "); sprintf(z," R = %.1fk ohm ",R); } else if(b>=1000000.0) { printf(y," resistor > 1M "); sprintf(z," out of range "); } initLCD(); LCD_cmd(0x80); for(i=0;i<16;i++) LCD_wr(y[i]); LCD_cmd(0xc0); for(j=0;j<16;j++) LCD_wr(z[j]); delay1s(); } }
void delay(void) { unsigned int i; for(i=0;i<200;i++); } void LCD_cmd(unsigned char x) { dat=x; RS=0;
22
Digital Ohmmeter
RW=0; E=1; E=0; delay(); } void LCD_wr(unsigned char x) { dat=x; RS=1; RW=0; E=1; E=0; delay(); } void initLCD(void) { LCD_cmd(0x38); LCD_cmd(0x38); LCD_cmd(0x38); LCD_cmd(0x06); LCD_cmd(0x0c); LCD_cmd(0x01); } void delay1s(void) { unsigned int i; TMOD=0x11; for(i=0;i<20;i++) { TH0=0x4B; TL0=0xFE; TR0=1; while(TF0==0); TR0=0; TF0=0; } }
23
Digital Ohmmeter
24