Вы находитесь на странице: 1из 19

RESISTANCE MEASUREMENT USING AVR ATMega8

MICROCONTROLLER
A Mini Project report submitted in partial fulfillment of the requirements
For the award of the degree of

MASTER OF SCIENCE
IN
EMBEDDED SYSTEMS
(UGC INNOVATIVE PROGRAMME)

BY

GOWTHAMRAJ K T P13E7001
Under the guidance of
Mr.K.Mathan Kumar, M.Sc., M.Tech.,
Assistant Professor of M.Sc., Embedded Systems

NEHRU MEMORIAL COLLEGE (AUTONOMOUS)


Nationally Accredited with “A” Grade by NAAC
PUTHANAMPATTI-621007
TIRUCHIRAPPALLI

APRIL 2014
ACKNOWLEGDEMENT
This is to place on record my appreciation and deep gratitude to the persons without
whose support this project would never seen the light of day.

I wish to express my propound sense of gratitude to Dr.T.Jayaprakasam, Principal


for his encouragement, and all facilities to complete this project.

I wish to express my sincere thanks to Dr.S.Kumararaman, HOD, Department of


Physics & Mr.M.Muralidharan, HOD, Department of Computer Science for extending
their support.

I wish to express my propound sense of gratitude to Dr.A.Rajendran, Coordinator,


M.Sc., Embedded Systems for his valuable guidance to complete the project.

I also express my sincere thanks and deep sense of gratitude to my guide


Mr.K.Mathan Kumar, Assistant Professor, Department of Embedded Systems for his
guidance throughout this project.

Finally, I express my sincere gratitude to all the members of faculty and my friends
who contributed their valuable advice and helped to complete the project successfully.

GOWTHAMRAJ K T
ABSTRACT

A Microcontroller OhmMeter (Resistance meter) to measure resistance of different


unknown resistors. This design measures resistance from 1Ω to 1MΩ with an accuracy of
±5% approximately. Using AVR Studio 4 and Proteus Simulation on v7.0 to do code
compiling and designing purpose. This code is written in C Language and will work on
ATmega8, ATmega16, ATmega32 (16bit microcontroller) by slightly changing the code. A
method of deriving the equivalent methods like color code finding and using formula also.
Experimental results are found to be in good and it work as a real time project of AVR
Microcontroller.
CONTENT
1. INTRODUCTION :
1.1 The Resistance Measurement
1.2 Description
2. TOOLS USED :
2.1 Software Tools.
3. FLOW DIAGRAM:
4. BLOCK DIAGRAM:
4.1 Description of Block Diagram.
5. OPERATION:
5.1 Operation or Working of Project.
6. SOFTWARE CODE:
6.1 C Code.
6.2 Proteus File.
7. HARDWARE DESIGN
8. ADVANTAGES & APPLICATIONS
9. CONCLUSION
CHAPTER – 1

1. INTRODUCTION

1.1 The Resistance Measurement:

1) Calculate the resistance of resistor in a series, parallel or parallel-series


circuit.
2) Calculate the resistance of a resistor based on the colour coded
band on a resistor.
1.2 Description:
1. This program can calculate resistances of resistors.
2. The circuit taken into consideration includes series, parallel and
parallel-series circuit.
3. This programme can calculate resistances of resistors based on the
colour bands of the resistors.
4. The circuit taken into consideration must only consist of a power
source, and resistors either in the connection of series or parallel or the
combination of both.
5. The equivalent resistance is calculated without considering the effective
range of resistance but only the average resistance value of the resistors
in the circuit.
6. In this project, we tried to utilize as many commands as we are capable
of to demonstrate our familiarity with these commands besides showing
variation. Among the commands used are: for, if, if-else, switch, do-
while, looping, function, pointer and arrays.
CHAPTER – 2

2. TOOLS USED
2.2 Software Tools.
AVR STUDIO 4:
The AVR Studio4 Development Tools are designed to solve the complex problems facing
embedded software developers.

When starting a new project, simply select the microcontroller you use from the device
Database and the software consist compiler, assembler, linker and memory options for use.
The AVR Studio 4 Debugger accurately on – chips(I2C,CAN,UART,SPI,Interrupts,
I/O Ports, A/D Converter, D/A Converter and PWM Modules) of your AVR device.
Simulation helps you to understand hardware configurations and avoids time wasted on setup
problems, Additionally, with simulation, you can write and test applications before target
hardware is available.

PROTEUS SOFTWARE:
Proteus 7.0 is a Virtual System Modelling (VSM) that combines circuit simulation, animated
components and microprocessor models to co-simulate the complete microcontroller based
designs. This is the perfect tool for engineers to test their microcontroller designs before
constructing a physical prototype in real time.
This program allows users to interact with the design using on-screen indicators and/or LED
and LCD displays and, if attached to the PC, switches and buttons. One of the main
components of Proteus 7.0 is the Circuit Simulation -- a product that uses a SPICE3f5 analogue
simulator kernel combined with an event-driven digital simulator that allow users to utilize any
SPICE model by any manufacturer.
Proteus VSM comes with extensive debugging features, including breakpoints, single stepping
and variable display for a neat design prior to hardware prototyping. In summary, Proteus 7.0
is the program to use when you want to simulate the interaction between software running on a
microcontroller and any analog or digital electronic device connected to it.

ADVANTAGES:
Real time simulation.
Time and money saving.
CHAPTER – 3

3. FLOW CHAT

START

SYSTEM, ADC
INITIALIZATION

CALIBRATION MANUAL
CALIBRATION
TYPE?

DEFAULT OR STORED
CALIBRATION VALUES

WHILE (1)

RESISTANCE FINDER

SYSTEMS WAKING

RESISTANCE CALCULATION

1Ω TO 1MΩ LOOP CONTROL


CHAPTER – 4

4. BLOCK DIAGRAM OF RESISTANCE MEASUREMNT

VARIABLE
RESISTANCE ATmega8
Microcontroller LCD -
DISPLAY

POWER
SUPPLY
4.1 Description in Detail:

The “Resistance Measurement” basically consists of four main blocks; these are resistors,
microcontroller, display and switches.

Fig4.2 ATMega8 Micro Controller

Microcontroller: Microcontroller senses the signal given from switches and the mode of
operation voting mode it increments the data for corresponding key. In measuring mode
micro controllers fetches data from memory location and send it to display devices.

Fig4.3 LCD

LCD: Liquid Crystal Display which is commonly known as LCD is an Alphanumeric


Display it means that it can display Alphabets, Numbers as well as special symbols thus
LCD is a user friendly Display device which can be used for displaying various messages
unlike seven segment display which can display only numbers and some of the alphabets.
The only disadvantage of LCD over seven segment is that seven segment is robust display
and be visualized from a longer distance as compared to LCD. Here I have used 16 x 2
Alphanumeric Display which means on this display I can display two lines with maximum
of 16 characters in one line.
CHAPTER – 5

OPERATION

Operation or Working of Project:

RESISTANCE:

Ohm’s Law V = I x R (Volts = Current x Resistance). The Ohm (Ω) is a unit of


electrical resistance equal to that of a conductor in which a current of one ampere is
produced by a potential of one volt across its terminals. Ohm's law, named after its
discoverer the German physicist Georg Ohm, is one of the most important, basic laws of
electricity. It defines the relationship between the three fundamental electrical
quantities: current, voltage and resistance. When a voltage is applied to a circuit containing
only resistive elements, current flows according to Ohm's Law, which is shown below.

To calculate the resistor value using this formula we can find out it.

Small resistances

Small resistances of the order of ten ohm or less have resistances similar or even
smaller than the ones of the cables and connectors needed in the measurement. The s.c.
four-wire method is well suited for measurements of small resistances. For small
resistances you may also use the volt-ampere method, the Wheatstone bridge or a digital
general purpose meter (GPM). The effect of wires and connector is the larger the smaller
the resistance under study is.
Middle-range resistances

Middle-range resistances (1 Ω - 10 kΩ) can be measured directly with a GPM or


more accurately using the Wheatstone bridge.

Large resistances

For large resistances (over 10 kΩ) the effect of cables and connectors is negligible so

GPM’s or special resistance meters are well suited.


The structure and functioning of the potentiometer

Potentiometer is usually three-pole electronic device which resistance can be adjusted


manually. The potentiometer includes a resistor which is connected to circuit from three
points (poles). Two of them are solid, at the ends of the resistor and the third one is
movable (fig.1). Thus the third pole divides the resistor in two pieces. In some
potentiometers have fourth pole, but as in fig.1, it is actually the same as the pole 2.

The magnitude of the resistance can be adjusted with the third pole. If e.g. the third
pole would be at the top of the resistor the resistance would be the entire resistance of the
resistor. If the third pole would be exactly in the middle of the resistor, the resistance
would be 50% of the entire resistance.
CHAPTER – 6

SOFTWARE CODE

//********************************************************
// ******** avr core v 1.1 ***********
//********************************************************
//processor : AVR(MEGA)
//Controller : ATmega8 (Crystal: int8 Mhz)
//Compiler : winAVR (AVRStudio)
//Author : Gowthamraj.K.T
//Date : may- 2014
//********************************************************

#define F_CPU 8000000


#include <avr/io.h>
#include <avr/iom8.h>
#include "util/delay.h"
#include "adc.h"
#include "serial.h"
#include "lcd4bit.h"
#include <avr/interrupt.h>
void port_init(void)
{
DDRB = 0xff;
PORTB = 0x00;
DDRD = 0x3e;
PORTD = 0x0C;
DDRC = 0x00;
PORTC = 0xFF;
}

//call this routine to initialize all peripherals


void init_devices(void)
{
port_init();
LCDInit(LS_NONE);
init_usart();
init_adc();
//init_gsm();
sei();
}
//****************** MAIN FUNCTION *******************

int main(void)
{
init_devices();

LCDWriteStringXY(0,0,"PROJECT DONE BY ");


LCDWriteStringXY(0,1,"GOWTHAMRAJ K T ");
_delay_ms(1000);

LCDWriteStringXY(0,0," M.Sc.,ES ");


LCDWriteStringXY(0,1," 2013 -2014 ");
_delay_ms(900);

LCDWriteStringXY(0,0," REISITANCE ");


LCDWriteStringXY(0,1," MEASUREMENT ");
_delay_ms(900);

LCDWriteStringXY(0,0,"please wait......");
LCDWriteStringXY(0,1,"system waking*****");
_delay_ms(900);
LCDClear();

while(1)
{

LCDWriteStringXY(0,0,"RESISTANCE ");
LCDWriteStringXY(0,1,"R= KOhm ");
result();
_delay_ms(200);

}
PROTEUS FILE :

Fig6.2 Proteus File


CHAPTER – 7

HARDWARE DESIGN
CHAPTER – 8

ADVANTAGES AND APPLICATION

1. It is economical
2. Less manpower required
3. Time conscious, as less time required for measuring the resistors.
4. Avoids invalid value while measuring
5. Saves transportation cost due to its compact size
6. Convenient on the part of measuring resistors.
CONCLUSION:

Measuring resistance is difficult but can be achieved using an electrometer and


proper measurement techniques. Depending upon the application, either the constant
voltage or the constant current method is used. Knowing the sources of measurement
errors and taking the steps to eliminate them is essential to making meaningful high
resistance measurements.
REFERENCE

1. Muhammad Ali Mazidi, Rolin D. Mckinlay, Danny Causey “AVR Microcontroller


and Embedded Systems using Assembly and C”, Pearson Eduction 2013.

2. Kirk Zurell, “C Programming for Embedded Systems”, R&D Books.

Вам также может понравиться