This document provides an industrial internship report for work completed at DRDO (Defense Research & Development Organization) in India. The internship focused on studying the AVR Atmega16 microcontroller architecture and applying it in a general purpose circuit. The report includes an acknowledgment, abstract, background on DRDO and the host lab SAG, and a detailed section-by-section summary of the work completed on microcontrollers, embedded systems, and a comparison of microcontrollers and microprocessors.
Micro-Scholarship, What it is, How can it help me.pdf
Atmega 16 drdo report
1. NORTHERN INDIA ENGINEERING
COLLEGE
INDUSTRIAL INTERNSHIP REPORT
Undertaken at
SAG, DRDO
(Defense Research & Development Organization)
June 20th 2017- August 20th 2017
ON THE TOPIC OF
“AVR Atmega16 Architecture and
its applications through a general purpose circuit”
Under the Supervisor: Submitted by:
Mr. Vineet dwivedi Himanshu baunthiyal
Scientist-F
(Electrical and Electronics Engg)
4th Year 08715604914
2. ACKNOWLEDGEMENT
I am deeplyintendedto Dr VINEET DWIVEDI,Scientist-
F,Metcalfehouse,Delhi for providingme theopportunity
to work on project“AVR Atmega16 Architecture and
its applicationsthrough a general purposecircuit “ as
part of my B.TECH(Electricaland electronicsengineering)
curriculum.
Again I shall be thankfulto all the department members
for providingme the same opportunity.
3. ABSTRACT
This report contains brief information about microcontroller, microcontroller
VS microprocessor,usesofmicrocontrollerin daily life,
4. DRDO
DRDO (Defence Research & Development Organization) was formed in 1958
from the amalgamation of the then already functioning Technical
Development Establishment (TDEs) of the Indian Army and the Directorate
of Technical Development & Production (DTDP) with the Defence Science
Organization (DSO). DRDO was then a small organization with 10 establishments
or laboratories. Over the years, it has grown multi-directionally in terms of the
variety of subject disciplines, number of laboratories, achievements and stature.
Today, DRDO is a network of 51 laboratories which are deeply engaged in
developing defence technologies covering various disciplines, like aeronautics,
armaments, electronics, combat vehicles, engineering systems, instrumentation,
missiles, advanced computing and simulation, special materials, naval systems,
lifesciences,training, information systemsand agriculture.
Presently, the Organization is backed by over 5000 scientists and about 25,000
otherscientific, technicaland supportingpersonnel.
Several major projects for the development of missiles, armaments, light combat
aircrafts, radars, electronic warfare systems etc are on hand and significant
achievements have already beenmade in severalsuchtechnologies.
5. DRDOSAG
Scientific Analysis Group (SAG) was established in 1963 for evolving new
scientific methods for design and analysis of communication systems. It
was situated in Central Secretariat Complex and consisted of 12
scientists. This group was placed under direct control of Chief Controller
(R&D) in 1973 and became a full fledged Directorate in R&D R&D
Headquarters.
In 1976, SAG started undertaking R&D projects on mathematical,
communication and speech analysis. Due to the increasing
responsibilities of SAG, the manpower component of SAG underwent
expansion and additional accommodation was allotted to SAG at Metcalfe
House Complex. SAG was further entrusted with R&D work in the field of
electronics. Work related to evaluating communication equipment to be
introduced in Services was taken up during 1980. The manpower
structure was again revised and the electronic facilities were enhanced.
Presently SAG is housed in two independent buildings with a total
manpower of 140 scientists/technicaland other staff.
6. DRDO - Vision
Make India prosperousbyestablishing world class scienceand technology base and
provideourDefence Services decisive edgeby equipping them with internationally
competitive systems and solutions.
DRDO - Mission
· Design, develop and lead to productionstate-of-the-artsensors,weapon
systems, platformsand allied equipmentfor ourDefence Services.
· Providetechnologicalsolutions to the Services to optimisecombat
effectiveness and to promotewell-being ofthe troops.
·Develop infrastructureand committed quality manpowerand build strong
indigenous technologybase.
8. 1.INTRODUCTION TO MICROCONTROLLER
A Microcontroller is a programmabledigital processor with necessary peripherals.
Both microcontrollers and microprocessors arecomplexsequential digital circuits
meant to carry outjob according to the program / instructions.
ATMEGA16 MICROCONTROLLER:
We will be working on Atmega16 microcontroller, which is a 40-pin IC
and belongs to the MegaAVR category of AVR family.
Some of the features of Atmega16 are:
16KB of Flash memory
1KB of SRAM
512 Bytes of EEPROM
Available in 40-Pin DIP
8- Channel 10-bitADC
Two 8-bit Timers/Counters
One 16-bit Timer/Counter
4 PWMChannels
Serial USART
Digital to AnalogComparator
PIN DIAGRAM
9. I/O PORTS
InputOutputfunctions are set by Three Registers for each PORT.
• DDRX ‐‐‐‐>Sets whether a pin is Inputor Outputof PORTX.
• PORTX ‐‐‐> Sets the OutputValue of PORTX.
• PINX ‐‐‐‐‐>Reads the Value of PORTX.
(WhereX= A, B, C or D)
DDRX (Data DirectionRegister)
Now to make a pin act as I/O weset its corresponding bit in its DDRregister.
• To make Inputsetbit 0
• To make Outputset bit 1
PORTX(PORTXData Register)
If a pin is set to be output, then by setting bit 1 wemake output High that
is +5V and by setting bit 0, make output Low that is 0V.
If a pin is set to be input, then by setting its corresponding bit in PORTX
register will make it asfollows, Setbit 0 ‐‐‐> Tri‐Stated Set bit 1 ‐‐‐> Pull Up.
PORTX ‐‐‐‐> to set value of PORTX with a byte.
PORTX.y ‐‐>to set value of yth pin of PORTX with a bit (works only with
CVAVR).
PINX (Data ReadRegister)This register is used to read the value of a PORT. If a
pin is set as input then corresponding biton PINregister is,
• 0 for Low Inputthat is V < 2.5V
• 1 for High Inputthat is V > 2.5V (Ideally, butactually 0.8 V ‐ 2.8 V is error zone!)
10. • PINX ‐‐‐‐>Read complete value of PORTX as a byte.
• PINX.y ‐‐>Read yth pin of PORTX as a bit (works only with CVAVR).
SOFTWARE
The softwarewhich supportthis hardwareand can communicate with micro
controller using this circuit is-
• AVRStudio 4
12. INTRODUCTIONTO AT89C51:
Description:
The AT89C51 is a low-power, high-performance CMOS 8-bit microcomputer with
4K bytes of Flash Programmable and Erasable Read Only Memory (PEROM). The
device is manufactured using Atmel’s high density nonvolatile memory technology
and is compatible with the industry standard MCS-51™ instruction set and pinout.
The on-chip Flash allows the program memory to be reprogrammed in-system or
by a conventional nonvolatile memory programmer. By combining a versatile 8-bit
CPU with Flash on a monolithic chip, the Atmel AT89C51 is a powerful
microcomputer which provides a highly flexible and costeffective solution to
many embedded controlapplications.
Pin Diagram and architecture of AT89C51
PIN DESCRIPTION
VCC:Supply voltage.
GND:Ground.
Port 0:Port0 is an 8-bit open drain bidirectional I/O port. As an output port each
pin can sink eight TTL inputs.When 1s are written to port 0 pins, the pins can be
used as high impedance inputs.
Port 0 may also be configured to be the multiplexed low order address/databus
during accesses to external program and data memory. In this mode P0 has internal
pull ups. Port 0 also receives the codebytes during Flash programming, and
13. outputs the codebytes during program verification. External pull ups are required
during program verification.
Port 1:
Port 1 is an 8-bit bidirectional I/O port with internal pull ups. The Port 1 output
buffers can sink/source four TTL inputs. When 1s are written to Port 1 pins they
are pulled high by the internal pull ups and can be used as inputs. As inputs, Port1
pins that are externally being pulled low will source current (IIL) because of the
internal pull ups. Port 1 also receives the low-order address bytes low-order
address bytes during Flash programming and verification.
Port 2:
Port 2 is an 8-bit bidirectional I/O port with internal pull ups. The Port 2 output
buffers can sink/source four TTL inputs. When 1s are written to Port 2 pins they
are pulled high by the internal pull ups and can be used as inputs. As inputs, Port2
pins that are externally being pulled low will source current (IIL) because of the
internal pull ups. Port 2 emits the high-order address byte during fetches from
external program memory and during accesses to external data memory that use
16-bit addresses (MOVX @DPTR). In this application it uses strong internal pull
ups when emitting 1s. During accesses to external data memory that use 8-bit
addresses (MOVX @ RI), Port 2 emits the contents of the P2 Special Function
Register. Port2 also receives the high-order address bits and some control signals
during Flash programming and verification.
Port 3:
Port 3 is an 8-bit bidirectional I/O port with internal pull ups. The Port 3 output
buffers can sink/source four TTL inputs. When 1s are written to Port 3 pins they
are pulled high by the internal pull ups and can be used as inputs. As inputs, Port3
pins that are externally being pulled low will source current (IIL) because
of the pull ups. Port 3 also serves the functions of various special features of the
AT89C51 as listed below:
Port Pin Alternate Functions
P3.0 RXD (serial input port)
P3.1 TXD (serial output port)
P3.2 INT0 (external interrupt 0)
P3.3 INT1 (external interrupt 1)
P3.4 T0 (timer 0 external input)
P3.5 T1 (timer 1 external input)
P3.6 WR (external data memory write strobe)
14. P3.7 RD (external data memory read strobe)
Port 3 also receives some control signals for Flash programming and verification.
RST:
Reset input. A high on this pin for two machine cycles while the oscillator is
running resets the device.
ALE/PROG:
Address Latch Enable output pulse for latching the low byte of the address during
accesses to external memory. This pin is also the program pulse input (PROG)
during Flash programming.In normal operation ALE is emitted at a constant rate of
1/6 the oscillator frequency, and may be used for external timing or clocking
purposes. Note, however, that one ALE pulse is skipped during each access to
external Data Memory. If desired, ALE operation can be disabled by setting bit 0
of SFR location 8EH.With the bit set, ALE is active only during a MOVX or
MOVC instruction. Otherwise, the pin is weakly pulled high. Setting the ALE-
disable bit has no effect if the microcontroller is in external execution mode.
PSEN:
Program Store Enable is the read strobeto external program memory.
When the AT89C51 is executing codefrom external program memory, PSEN is
activated twice each machine cycle, except that two PSEN activations are skipped
during each access to external data memory.
EA/VPP:
External Access Enable. EA must be strapped to GND in order to enable the device
to fetch codefrom external program memory locations starting at 0000H up to
FFFFH. Note, however, that if lock bit 1 is programmed, EA will be internally
latched on reset.EA should be strapped to VCC for internal program executions.
This pin also receives the 12-volt programming enable voltage (VPP) during Flash
programming, for parts that require 12-volt VPP.
XTAL1:
Input to the inverting oscillator amplifier and input to the internal clock operating
circuit.
XTAL2: Output from the inverting oscillator amplifier.
MEMORYSPACE ALLOCATION:
The 8051 has three very general types of memory. To effectively program the 8051
it is necessary to have a basic understanding of these memory types. The memory
15. types are illustrated in the following graphic.They are: On-Chip Memory, External
CodeMemory, and External RAM.
Onchip ROM:
The 89C51 has a 4K bytes of on-chip ROM. This 4K bytes ROM memory has
memory addresses of0000 to 0FFFh. Program addresses higher than 0FFFh, which
exceed the internal ROM capacity will cause the microcontroller to automatically
fetch codebytes from external memory. Code bytes can also be fetched exclusively
from an external memory, addresses 0000h to FFFFh, by connecting the external
access pin to ground. The program counter doesn’tcare where the codeis: the
circuit designer decides whether the code is found totally in internal ROM, totally
in external ROM or in a combination of internal and external
ROM.
Onchip RAM:
The 1289 bytes of RAM inside the 8051 are assigned addresses 00 to 7Fh. These
128 bytes can be divided into three different groups as follows:
A total of 32 bytes from locations 00 to 1Fh are set aside for register banks and the
stack.A total of 16 bytes from locations 20h to 2Fh are set aside for bit addressable
read/write memory and instructions.
A total of 80 bytes from locations 30h to 7Fh are used for read and write storage,
or what is normally called a scratchpad. These 80 locations of RAM are widely
used for the purposeof storing data and parameters by 8051 programmers.
16. ROM & RAM Memory in 8051 Microcontroller
External Code Memory :
External CodeMemory is code(or program) memory that resides off-chip. This is
often in the form of an external EPROM.
External RAM :
External RAM is RAM memory that resides off-chip. This is often in the form of
standard static RAM or flash refers to any memory (Code, RAM, or other) that
physically exists on the microcontroller itself. Onchip memory can be of several
types, but we'll get into that shortly. External RAM As an obvious oppositeof
Internal RAM, the 8051 also supports what is called External RAM. As the name
suggests, External RAM is any random access memory which is found off-chip.
Since the memory is off-chip it is not as flexible in terms of accessing, and is also
slower. For example, to increment an Internal RAM location by 1 requires only 1
instruction and 1 instruction cycle. To increment a 1-byte value stored in External
17. RAM requires 4 instructions and 7 instruction cycles. In this case,external memory
is 7 times slower!
Code Memory :
Codememory is the memory that holds the actual 8051 program that is to be run.
This memory is limited to 64K and comes in many shapes and sizes: Codememory
may be found on-chip, either burned into the microcontroller as ROM or EPROM.
Codemay also be stored completely off-chip in an external ROM or, more
commonly, an external EPROM. Flash RAM is also another popular method of
storing a program.Various combinations of these memory types may also be used
that is to say, it is possible to have 4K of codememory on-chip and 64k of code
memory off-chip in an EPROM.
Registers:
In the CPU, registers are used to store information temporarily. That information
could be a byte of data to be processed, oran address pointing to the data to be
fetched. In the 8051 there us only one data type: 8 bits. With an 8- bit data type,
any data larger than 8 bits has to be broken into 8-bit chunks before it is
processed.Themostcommonly used registers of the 8051 are A(accumulator), B,
R0, R1, R2, R3, R4, R5, R6, R7,DPTR (data pointer) and PC (program counter).
All the above registers are 8-bit registers except DPTR and the program counter.
The accumulator A is used for all arithmetic and logic instructions.
FIG. Some 8-bit registers & some 16-bit registers
18. 4. Embedded Systems
Introduction:-
Embedded system is a scaled down computersystem which is designed to
perform a specific taskor operation. The whole system is embedded into
an appliance. This reduces human effortto a great extent. A single chip
contains both hardware and software.
Some importantthings to note aboutembedded systems:
1. Once an embedded hardware is programmed fora certain task, it is
used foreverfor the same task. Changing the firmware afterwards is not
possible.
2. Such systems are limited in computational resources like memory, CPU
processing speed,I/O facilities but are still capable of performing the task
given to them very efficiently.
3. Embeddedsystems can also be having a reduced functionality version
of operating system called RTOS (Real Time Operating System) for highly
specialized applications.
4. Interacts with physical elements in our environment, viz. controlling and
driving a motor, sensing temperature, etc.
EMBEDDED SYSTEM IN DAILY LIFE
Digital Clock Traffic Light
DVD Player Smart Phones
19. 3. Analog to Digital Converters
Microcontroller understands only digital language.
To convert the analog output from the sensors to digital we
need ADC.
In AVR family of microcontroller we have inbuilt ADC on
PORTA. Each pin in PORTA has an ADC circuit connected
behind it. Thus we have 8 channels of ADC.
The resolution of ADC output is 10 bit i.e. the output from the
ADC is any number between 0 to 1023
ADC registers:
The inbuilt ADC of AVR microcontroller have three register
which are used for configuring the ADC. They are:
ADMUX: it is used for selecting the ADC pin to be used for
connecting the Analog sensors. It is also used for setting
the reference value of the ADC.
ADSCRA: it is used for controlling the ADC e.g. when
should it start the conversion? Should it repeat the
conversion? Should interrupt be generated after the
conversion is complete? Etc.
ADCH & ADCL: these are used for storing the ADC output
values. Both the registers are 8 bit wide and we require 10
bits for storing the ADC value. Thus the two registers are
used. The way of storing the ADC value is configured using
ADSCRA.
20. ADMUX
ADLAR:-This bit is setting the manner, the ADC result will be
stored in ADC data register.
ADLAR = 0
ADCH& ADCL
ADCSR
21. 4.Timers in ATMega16
In Atmega16, we have three timers:TIMER0 TIMER1 and
TIMER2
Out of these, TIMER0 and TIMER2 are 8 bit timer, while
TIMER1 is a 16 bit timer.
All the timers have three unique registers and two common
registers.
TIMER1 has a special register, called ICR(Input Capture
Register).Ithas two channels(channel A and channel B).
TIMER2 has a special register known as ASSR, which is used
two generate PWM using asynchronous clock.
Timer Registers
• Each timer has three registers.They are:
TCCR(TimerCounter Control Register)
TCNT(TimerCounter),
OCR (Output Compare Register).
• Thus, three registers for TIMER0 are TCCR0, TCNT0 and
OCR0.
• Similarly for TIMER1 and TIMER2, we have TCCR1, TCNT1,
OCR1 and TCCR2,TCNT2 and OCR2.
• The three timers have two commonregisters.They are:
TIMSK (Timer Interrupt Mask)
TIFR (Timer Interrupt Flag Register
Register Function Description
• TCCR (Timer Counter Control Register): It is used for
configuring the timer i.e. modes and pre scale factor.
• TCNT: It stores the present value of the timer. It is used for
monitoring the status of the timer. After each incrementing in
the timer value, this register compares its value with the OCR
registervalue.
• OCR(Output Compare Register): It is used for setting the
required duty Cycle
22. 6. LCD INTERFACING
• LCD’s are all around us so liquid crystal displays are very useful in
these days.
• It is a kind of display that is made up of a special matter state formed
using liquid and crystal both , it’s a forth state of matter
• The most popular one is 16x2 LCD module.It has 2 rows & 16
columns.The intelligent displays are two types:
Text Display
Graphics Display
PIN DESCRIPTION
Figure 4.1: pin configuration for 16 X 2 LCD
8 data pins D7:D0
Bi-directional data/command pins. Alphanumeric characters are sent in
ASCII format.
RS: Register Select
23. RS = 0 -> Command Registeris selected
RS = 1 -> Data Registeris selected
R/W: Read or Write
0 -> Write, 1 -> Read
E: Enable (Latch data)
Used to latch the data presenton the data pins.
A high-to-low edge is needed to latch the data.
VEE: contrastcontrol.
VDD & VSS: Power supply
VDD= +5V
VSS=GND
FIG. Pin Description of LCD
24. LCD INTERFACING PROGRAM:
#include <avr/io.h>
#include <util/delay.h>
#include "lcd.h"
int main(void)
{
lcd_init(LCD_DISP_ON_CURSOR); /* initialize lcd, display on,
cursor on */
/* for more options for
/* lcd_init(), view lcd.h file
while(1) /* run continuously */
{
lcd_clrscr(); /* clear screen of lcd */
lcd_home(); /* bring cursor to 0,0 */
lcd_puts("hello"); /* type something random */
lcd_gotoxy(0,1); /* go to 2nd row 1st col */
lcd_puts("maxEmbedded"); /* type something random */
_delay_ms(50); /* wait 50ms */
}
}
25. EMBEDDED SYSTEM
INTRODUCTIONTO EMBEDDEDSYSTEM
Embedded System is a special purposecomputer. It helps in infusing artificial
intelligence into an electronic system.
DEFINITION:
Embedded System is a combination of Hardware and Software to meet specific
needs in a given time frame.
E.g.: Daily life embedded systems arecell phones, printers, ATMetc.
Why embedded system?
motor, shall be a part of embedded.
with our software to perform a certain task
programmed to perform a particular task’ , but it’s a human need to utilize a
gadget (electronics) as much as it could do, here we come with general purpose
system (a system which can perform many task).This part has software and
efficient coding in main concern.
human-machine interface.
26. INTRODUCTION TO EMBEDDED C
microcontrollers.
inputs are sanned from the sensors and
outputs are given to the ports.
-statement, for loop, do while etc.
STRUCTURE OF A C PROGRAM FOR AN EMBEDDED
SYSTEM
//Headers
#include<avr/io.h>//header file for avr i/o
#include<util/delay.h>//header file for delay
//main program
{
Int main ()
While(1)
{
code….
}
Return (0);
}
27. Pin Configurations:
Pin Descriptions:
VCC: Digital supply voltage.
GND: Ground.
Port A (PA7..PA0) :
Port A serves as the analog inputs to the A/D Converter.Port A also serves
as an 8-bit bi-directional I/O port, if the A/D Converter is not used. Port pins
can provide internal pull-up resistors (selected foreach bit). The Port A
output buffers have symmetrical
28. drive characteristics with both high sink and source capability. When pins
PA0 to PA7 are used as inputs and are externally pulled low, they will
source current if the internal pull-up resistors are activated. The Port A pins
are tri-stated when a reset condition becomesactive,even if the clock is not
running.
Port B (PB7..PB0) :
Port B is an 8-bit bi-directional I/O port with internal pull-up resistors
(selected foreach bit). The Port B output buffers have symmetrical drive
characteristics with both high sink and source capability. As inputs, Port B
pins that are externally pulled low will source current if the pull-up
resistors are activated. The Port B pins are tri-stated when a reset condition
becomes active,even if the clock is not running.
Port C (PC7..PC0):
Port C is an 8-bit bi-directional I/O port with internal pull-up resistors
(selected foreach bit). ThePort C output buffers have symmetrical drive
characteristics with both high sink and source capability. As inputs, Port C
pins that are externally pulled low will source current if the pull-up
resistors are activated. The Port C pins are tri-stated when a reset
condition becomes active,even if the clock is not running. If the JTAG
interface is enabled, the pull-up resistors on pins PC5(TDI),PC3(TMS)and
PC2(TCK)will be activated even if a reset occurs.
Port C also serves the functions of the JTAG interface and other special
features of the
Port D (PD7..PD0):
Port D is an 8-bit bi-directional I/O port with internal pull-up resistors
(selected foreach bit). The Port D output buffers have symmetricaldrive
characteristics with both high sink and source capability. As inputs, Port D
pins that are externally pulled low will source current if the pull-up resistors
are activated. The Port D pins are tri-stated when a resetcondition
becomes active,even if the clock is not running.
RESET:
ResetInput. A low level on this pin for longer than the minimum pulse
length will generate a
reset, even if the clock is not running.Shorter pulses are not guaranteed to
generate a reset.
XTAL1:
Input to the inverting Oscillator amplifierand input to the internal clock
operating circuit.
XTAL2:
Output from the inverting Oscillator amplifier.
29. AVCC :
AVCC is the supply voltage pin for Port A and the A/D Converter. It should
be externally connected
to VCC, even if the ADC is not used. If the ADC is used, it should be
connected to VCC
through a low-pass filter.
AREF:
AREF is the analog reference pin for the A/D Converter.
30. CONCLUSION
The industrial training at DEFENCERESEARCHAND DEVELOPMENT
ORGANISATION (DRDO), Delhi has given me an exposure to the activities at a
large public sector – undertaking unit . This being a large organization deals with
wide spectrum of technologies . The exposure on LITHOGRAPHY has given me
great confidence and knowledge.
31. BIBLIOGRAPHY
Books Referred
• Vlsi Technology By S.M.SZE
• Vlsi Fabrication Principles by Ralph Williams
Web Section
• www.google.com
• www.wikipedia.com
• www.pdf.com
• http://www.ece.gatech.edu/research/labs/vc/theory/PosNegRes.html
• http://dspace.library.iitb.ac.in