SlideShare a Scribd company logo
A
Practical Training Report On
Embedded System
Taken at
RaycoreIndia PVT. LTD., Greater NOIDA
Submitted in Partial Fulfilment of
Bachelor of Technology
ECE IV Year VII Semester
Galgotias College of Engineering and Technology
Session (2016-2017)
Submitted by:-
Saket Mishra
Roll No.-1309731082
Submitted To:-
Mr. Depaak Gangwar
Department of Electronics & Communication Engineering
Galgotias College of engineering and technology, Greater NOIDA
CONTENTS
Serial
No.
Topic
1. Company Review
2. Training certificate
3. Embedded System
4. Microcontroller (AVR)
5. Architecture of AVR (Atmega 16)
6. Embedded C
7. Interfacing of AVR
8. Modules
9. Project
10. Bibliography
1. Company Overview
RaycoreIndia Research & automation PVT. LTD. is the start-up leader in electronics,
software, services and solutions that help people and businesses realize their full
potential. At RaycoreIndia, we’re motivated and inspired every day by how our
customers use our services to find creative solutions to business problems, develop
breakthrough ideas, and stay connected to what’s most important to them. AN ISO
9001: 2008 certified company
 Training And Project development
 Embedded | Robotics | Automation
 Placement
 Software development
 Robotics Products
 Research
2. Certification
REFF NO: RAYGN/15/1090
Internship Offer Letter
Date: 01/07/2015
SAKET MISHRA
ROLL NO: 1309731082
COLLEGE: GCET / BRANCH: ECE
Dear,
I am pleased to confirm your acceptance of an internship position as software trainee
in EMBEDDED SYSTEM. Complete module of ONE year at Greater Noida Branch. Your first
day of the training will be 04/07/2015. Your duties and assignments for this position will
be those described to you in your orientation with Mr Pradeep.
Please report to the Human Resources Department at 10 a.m. on 04/07/2015 with
the appropriate documents and completed forms.
If you have any questions, please feel free to contact Mr Amit. We are very pleased that
you have decided to join RaycoreIndia Pvt. Ltd. We look forward to seeing you on
04/17/2015 and offer a very warm welcome.
Sincerely,
Thanking you
HR DEPARTMENT
Satish Bhuyan
Raycore India Research & Automation PVT. LTD.
WWW.RAYCOREINDIA.COM : MOB: +91 9643736342: PHONE: 0120 4126369
3. Introduction of Embedded System
Embedded means something that is attached to another thing. An embedded system can be
thought of as a computer hardware system having software embedded in it. An embedded
system can be an independent system or it can be a part of a large system. An embedded
system is a microcontroller or microprocessor based system which is designed to perform a
specific task.
DEFINITION: Embedded System is a combination of Hardware and Software to meet
specific needs in a given time frame.
Embeddedsystemscontaintwomainelements:
 Embedded system hardware: As with any electronic system, an embedded system
requires a hardware platform on which to run. The hardware will be based around a
microprocessor or microcontroller. The embedded system hardware will also contain
other elements including memory, input output (I/O) interfaces as well as the user
interface, and the display.
 Embedded system software: The embedded system software is written to perform a
particular function. It is typically written in a high level format and then compiled
down to provide code that can be lodged within a non-volatile memory within the
hardware.
Examples of Embedded System:
 Automated transaction machines (ATMS).
 Integrated system in aircraft and missile.
 Cellular telephones and telephonic switches.
 Computer network equipment, including routers timeservers and firewalls
 Computer printers, Copiers.
Basic Structure of an Embedded System
Block diagram of a typical embedded system is shown in fig.
CHARACTERISTICS
 Embedded systems are application specific & single functioned; the programs are
executed repeatedly.
 Efficiency is of paramount importance for embedded systems. They are optimized for
energy, code size, execution time, weight & dimensions, and cost.
 Embedded systems are typically designed to meet real time constraints; a real time
system reacts to stimuli from the controlled object/ operator within the time interval
dictated by the environment. For real time systems, right answers arriving too late (or
even too early) are wrong.
 Embedded systems often interact (sense, manipulate & communicate) with external
world through sensors and actuators and hence are typically reactive systems; a reactive
system is in continual interaction with the environment and executes at a pace
determined by that environment.
 They generally have minimal or no user interface.
4. Microcontroller Embedded Systems
A microcontroller is a functional computer system-on-a-chip. It contains an integrated
processor, memory (a small amount of RAM, program memory, or both), several peripheral
devices, such as timers, analog to digital converters, and serial communication devices all
on one chip resulting in compact and low-power implementations. It is not expandable as
it has no external bus interface.
Microcontrollers provide pin access which allows programs to easily monitor sensors, set
actuators, and transfer data with other devices. Providing specialized instructions improves
performance for embedded systems applications; thus, microcontrollers can be considered
ASIPs to some degree.
AVR
History of AVR:
AVR was developed in the year 1996 by Atmel Corporation. The architecture of AVR was
developed by Alf-Egil Bogen and Vegard Wollan. AVR derives its name from its
developers and stands for Alf-Egil Bogen Vegard Wollan RISC microcontroller, also
known as Advanced Virtual RISC. The AT90S8515 was the first microcontroller which
was based on AVR architecture however the first microcontroller to hit the commercial
market was AT90S1200 in the year 1997.
AVR microcontrollers are available in three categories:
1. Tiny AVR – Less memory, small size, suitable only for simpler applications
2. Mega AVR – These are the most popular ones having good amount of memory (upto
256 KB), higher number of inbuilt peripherals and suitable for moderate to complex
applications.
3. Xmega AVR – Used commercially for complex applications, which require large
program memory and high speed.
The following table compares the above mentioned AVR series of microcontrollers:
Series Name Pins Flash Memory Special Feature
Tiny AVR 6-32 0.5-8 KB Small in size
Mega AVR 28-100 4-256KB Extended peripherals
X mega AVR 44-100 16-384KB
DMA , Event System
included
What’s special about AVR?
They are fast: AVR microcontroller executes most of the instructions in single execution
cycle. AVRs are about 4 times faster than PICs, they consume less power and can be operated
in different power saving modes. Let’s do the comparison between the three most commonly
used families of microcontrollers.
AVR is an 8-bit microcontroller belonging to the family of Reduced Instruction Set Computer
(RISC). In RISC architecture the instruction set of the computer are not only fewer in number
but also simpler and faster in operation. The other type of categorization is CISC (Complex
Instruction Set Computers).
CHARACTERISTICS 8051 PIC AVR
SPEED Slow Moderate Fast
MEMORY Small Large Large
ARCHITECTURE CISC RISC RISC
ADC Not Present Inbuilt Inbuilt
TIMERS Inbuilt Inbuilt Inbuilt
PWM Channels Not Present Inbuilt Inbuilt
What is 8-bit? This means that the microcontroller is capable of transmitting and receiving 8-
bit data. The input/output registers available are of 8-bits. The AVR family controllers have
register based architecture which means that both the operands for an operation are stored in a
register and the result of the operation is also stored in a register. Following figure shows a
simple example performing OR operation between two input registers and storing the value in
Output Register.
The CPU takes values from two input registers INPUT-1 and INPUT-2, performs the logical
operation and stores the value into the OUTPUT register. All this happens in 1 execution cycle.
In our journey with the AVR we will be working on Atmega16 microcontroller, which is a 40-
pin IC and belongs to the mega AVR category of AVR family. Some of the features of
Atmega16 are:
o 16KB of Flash memory
o 1KB of SRAM
o 512 Bytes of EEPROM
o Available in 40-Pin DIP
o 8-Channel 10-bit ADC
o Two 8-bit Timers/Counters
o One 16-bit Timer/Counter
o 4 PWM Channels
o In System Programmer (ISP)
o Serial USART
o SPI Interface
o Digital to Analog Comparator.
5. Architecture of AVR
The AVR microcontrollers are based on the advanced RISC architecture and consist of 32 x 8-
bit general purpose working registers. Within one single clock cycle, AVR can take inputs from
two general purpose registers and put them to ALU for carrying out the requested operation,
and transfer back the result to an arbitrary register. The ALU can perform arithmetic as well as
logical operations over the inputs from the register or between the register and a constant.
Single register operations like taking a complement can also be executed in ALU. We can see
that AVR does not have any register like accumulator as in 8051 family of microcontrollers;
the operations can be performed between any of the registers and can be stored in either of
them.
AVR follows Harvard Architecture format in which the processor is equipped with separate
memories and buses for Program and the Data information. Here while an instruction is being
executed, the next instruction is pre-fetched from the program memory.
Since AVR can perform single cycle execution, it means that AVR can execute 1 million
instructions per second if cycle frequency is 1MHz. The higher is the operating frequency of
the controller, the higher will be its processing speed. We need to optimize the power
consumption with processing speed and hence need to select the operating frequency
accordingly.
There are two flavours for Atmega16 microcontroller:
1. Atmega16:- Operating frequency range is 0 – 16 MHz
2. Atmega16L:- Operating frequency range is 0 – 8 MHz
If we are using a crystal of 8 MHz = 8 x 106 Hertz = 8 Million cycles, then AVR can execute
8 million instructions.
Naming Convention
The AT refers to Atmel the manufacturer, Megameans that the microcontroller belong to Mega
AVR category, 16 signifies the memory of the controller, which is 16KB.
Architecture Diagram: Atmega16
Following points explain the building blocks of Atmega16 architecture:
I/O Ports: Atmega16 has four (PORTA, PORTB, PORTC and PORTD) 8-bit input-output
ports.
Internal Calibrated Oscillator: Atmega16 is equipped with an internal oscillator for driving
its clock. By default Atmega16 is set to operate at internal calibrated oscillator of 1 MHz The
maximum frequency of internal oscillator is 8Mhz. Alternatively, ATmega16 can be operated
using an external crystal oscillator with a maximum frequency of 16MHz.
ADC Interface: Atmega16 is equipped with an 8 channel ADC (Analog to Digital Converter)
with a resolution of 10-bits. ADC reads the analog input for e.g., a sensor input and converts it
into digital information which is understandable by the microcontroller.
Timers/Counters: Atmega16 consists of two 8-bit and one 16-bit timer/counter. Timers are
useful for generating precision actions for e.g., creating time delays between two operations.
Interrupts: Atmega16 consists of 21 interrupt sources out of which four are external. The
remaining are internal interrupts which support the peripherals like USART, ADC, Timers etc.
USART: Universal Synchronous and Asynchronous Receiver and Transmitter interface
is available for interfacing with external device capable of communicating serially (data
transmission bit by bit).
General Purpose Registers: Atmega16 is equipped with 32 general purpose registers which
are coupled directly with the Arithmetic Logical Unit (ALU) of CPU.
Memory: Atmega16 consist of three different memory sections:
 Flash EEPROM: Flash EEPROM or simple flash memory is used to store the program
dumped or burnt by the user on to the microcontroller. It can be easily erased electrically
a single unit. Flash memory is non-volatile i.e., it retains the program even if the power
is cut-off. Atmega16 is available with 16KB of in system programmable Flash
EEPROM.
 Byte Addressable EEPROM: This is also a non-volatile memory used to store data
like values of certain variables. Atmega16 has 512 bytes of EEPROM, this memory can
be useful for storing the lock code if we are designing an application like electronic
door lock.
 SRAM: Static Random Access Memory, this is the volatile memory of microcontroller
i.e., data is lost as soon as power is turned off. Atmega16 is equipped with 1KB of
internal SRAM. A small portion of SRAM is set aside for general purpose registers
used by CPU and some for the peripheral subsystems of the microcontroller.
ISP: AVR family of controllers have In System Programmable Flash Memory which can be
programmed without removing the IC from the circuit, ISP allows to reprogram the controller
while it is in the application circuit.
SPI: Serial Peripheral Interface, SPI port is used for serial communication between two
devices on a common clock source. The data transmission rate of SPI is more than that of
USART.
TWI: Two Wire Interface (TWI) can be used to set up a network of devices, many devices
can be connected over TWI interface forming a network, the devices can simultaneously
transmit and receive and have their own unique address.
DAC: Atmega16 is also equipped with a Digital to Analog Converter (DAC) interface which
can be used for reverse action performed by ADC. DAC can be used when there is a need of
converting a digital signal to analog signal.
AVR Pin description:
Pin No. Pin name Description Alternate Function
1
(XCK/T0)
PB0
I/O PORTB, Pin 0
T0: Timer0 External Counter Input.
XCK : USART External Clock I/O
2 (T1) PB1 I/O PORTB, Pin 1 T1:Timer1 External Counter Input
3
(INT2/AIN0)
PB2
I/O PORTB, Pin 2
AIN0: Analog Comparator Positive I/P
INT2: External Interrupt 2 Input
4
(OC0/AIN1)
PB3
I/O PORTB, Pin 3
AIN1: Analog Comparator Negative I/P
OC0 : Timer0 Output Compare Match Output
5 (SS) PB4 I/O PORTB, Pin 4 In System Programmer (ISP)
Serial Peripheral Interface (SPI)6 (MOSI) PB5 I/O PORTB, Pin 5
7 (MISO) PB6 I/O PORTB, Pin 6
8 (SCK) PB7 I/O PORTB, Pin 7
9 RESET
Reset Pin, Active
Low Reset
10 Vcc Vcc = +5V
11 GND GROUND
12 XTAL2 Output to Inverting Oscillator Amplifier
13 XTAL1 Input to Inverting Oscillator Amplifier
14 (RXD) PD0 I/O PORTD, Pin 0
USART Serial Communication Interface
15 (TXD) PD1 I/O PORTD, Pin 1
16 (INT0) PD2 I/O PORTD, Pin 2 External Interrupt INT0
17 (INT1) PD3 I/O PORTD, Pin 3 External Interrupt INT1
18 (OC1B) PD4 I/O PORTD, Pin 4
PWM Channel Outputs
19 (OC1A) PD5 I/O PORTD, Pin 5
20 (ICP) PD6 I/O PORTD, Pin 6 Timer/Counter1 Input Capture Pin
21 PD7 (OC2) I/O PORTD, Pin 7 Timer/Counter2 Output Compare Match Output
22 PC0 (SCL) I/O PORTC, Pin 0
TWI Interface
23 PC1 (SDA) I/O PORTC, Pin 1
24 PC2 (TCK) I/O PORTC, Pin 2
JTAG Interface
25 PC3 (TMS) I/O PORTC, Pin 3
26 PC4 (TDO) I/O PORTC, Pin 4
27 PC5 (TDI) I/O PORTC, Pin 5
28
PC6
(TOSC1)
I/O PORTC, Pin 6 Timer Oscillator Pin 1
29
PC7
(TOSC2)
I/O PORTC, Pin 7 Timer Oscillator Pin 2
30 AVcc Voltage Supply = Vcc for ADC
31 GND GROUND
32 AREF Analog Reference Pin for ADC
33 PA7 (ADC7) I/O PORTA, Pin 7 ADC Channel 7
34 PA6 (ADC6) I/O PORTA, Pin 6 ADC Channel 6
35 PA5 (ADC5) I/O PORTA, Pin 5 ADC Channel 5
36 PA4 (ADC4) I/O PORTA, Pin 4 ADC Channel 4
37 PA3 (ADC3) I/O PORTA, Pin 3 ADC Channel 3
38 PA2 (ADC2) I/O PORTA, Pin 2 ADC Channel 2
39 PA1 (ADC1) I/O PORTA, Pin 1 ADC Channel 1
40 PA0 (ADC0) I/O PORTA, Pin 0 ADC Channel 0
6. Embedded C (AVR Programming language)
 Embedded c is a subset of c language which is compatible with certain
microcontrollers.
 Some features are added using header files like <avr/io.h>, <util/delay.h>.
 Scanf and printf are removed as the inputs are scanned from the sensors and outputs are
given to the ports.
 Control structures remain the same like if-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);
}
We have four Ports
 PORT A
 PORT B
 PORT C
 PORT D
All ports have Read-Modify-Write functionality (all pins are capable of performing dual
functions)
Points to be noted for Programming:
 PORT : group of 8 pins, or set of pins used for exchanging data with external world
 Width of almost all registers : 8 bits (some 16 bits)
 In port related registers, every bit corresponds to one pin of the port.
Bit 0 corresponds to Pin 0 & Bit 0 corresponds to Pin 1... Etc.
 Remember direct one to one correspondence between HEX and BINARY numbers.
0xFF = 1111 1111
0xAA = 1010 1010
0x11 = 0001 0001
Input/output Basics:
 DDRx: Data Direction (input/output) pins
 Configures data direction of the port - Input / Output
 DDRx.n = 0 > makes corresponding port pin as input
DDRx.n = 1 > makes corresponding port pin as output
 Examples :
1. To make all pins of port A as input pins :
DDRA = 0b00000000;
2. To make all pins of port A as output pins
DDRA = 0b11111111;
3. To make lower nibble of port B as output and higher nibble as input
DDRB = 0b00001111;
 PIN Register
 Used to read data from port pins, when port is configured as input.
 First set DDRx to zero, then use PINx to read the value.
 If PINx is read, when port is configured as output, it will give you data that has
been outputted on port.
1. Example :
DDRA = 0x00; //Set PA as input
x = PINA; //Read contents of PA
 PORT Register
For data output, when port is configured as output:
 Writing to PORTx.n will immediately (in same clock cycle) change state of the
port pins according to given value.
 Do not forget to load DDRx with appropriate value for configuring port pins as
output.
 Examples :
1. To output 0xFF data on PB
DDRB = 0b11111111; //set all pins of port b as outputs
PORTB = 0xFF; //write data on port
2. To output data in variable x on PA
DDRA = 0xFF; //make port a as output
PORTA = x; //output 8 bit variable on port
For configuring pin as tristate/pullup, when port is configured as input):
 When port is configures as input (i.e. DDRx.n=1), then PORTx.n controls the
internal pull-up resistor.
 PORTx.n = 1 : Enables pullup for nth bit
PORTx.n = 0 : Disables pullup for nth bit, thus making it tristate
 Examples :
1. To make PA as input with pull-ups enabled and read data from PA
DDRA = 0x00; //make port a as input
2. PORTA = 0xFF; //enable all pull-ups
y = PINA; //read data from port a pins
3. To make PB as tri stated input
DDRB = 0x00; //make port b as input
4. PORTB = 0x00; //disable pull-ups and make it tri state
7. Interfacing and sending code from PC to AVR
Steps for coding in AVR Studio:
AVR studio is an Integrated Development Environment (IDE) by ATMEL for developing
applications based on AVR microcontroller.
STEP 1:
Click on new project.
STEP 2:
1. Click on AVR GCC
2. Write the project name
3. Select your project location.
4. Click on Next>>
STEP 3:
1. Click on AVR Simulator in left block and then select your controller (e.g.: ATmega16).
2. Click on finish button.
STEP 4:
1. Write the code in main body area.
2. Save the project file.
STEP5:
Go to BUILD -> Compile.
This will compile your code and generate error if there will be any.
STEP 6:
Again go to BUILD and click on Build. This will generate hex file of the code. Use that Hex
file to burn your microcontroller.
USBASP USB Programmer:
The USBasp USB programmer is connected to PC from USB side and to the AVR through
wires from the pin side. The connection is used to send the HEX file from PC to AVR
microcontroller.
The converted HEX file of the code is sent from PC/ system to the microcontroller is done by
a software called, sinaprog.
STEP 1: Click the “Folder” icon in the Hex file section and browse for the Hex file of the
project, which you want to download to the microcontroller and Select the HEX file.
STEP 2: Click the “Program” button in the Flash section to start the download of code/program
(Hex file of project) to the Flash memory of the microcontroller.
STEP 3: If the code/program download succeeds, then “Programming Flash…OK” is displayed
in the Status section band if the download fails, then “Programming failed” is displayed in the
Status section.
8. Modules
1. I R sensors:
The principle of operation of an infrared sensor is based on infrared light that is
reflected when hitting an obstacle. An IR receiver (Photo Diode) captures the reflected
light and the voltage are measured based on the amount of light received. Infrared
sensors are used in a wide range of applications proximity detection, robotic
applications for distance and object detection, and colour detection and tracking. The
output of the IR sensor can be digital or analog.
If the output of the analog IR sensor is analog in nature and these analog signals cannot
be processed directly by the ATmega16 microcontroller. So, first this signal needs to
be converted to digital value to be processed by the microcontroller. The conversion
can be done with the help of ADC of the AVR ATmega16 microcontroller. After
converting the analog signal to digital, the microcontroller will display the digital value
in the 1×8 LED array.
Pin description:
 Pin 1 is the output so we wire this to a visible LED and resistor
 Pin 2 is ground
 Pin 3 is VCC, connect to 5V
2. Relay:
Relays are very interesting and useful electronic component. They are a kind of switch,
like those we use every day in our home and offices to turn on and off electrical devices
like bulbs, TVs, fans etc. The function of relay is to control the switching of a relatively
heavier load which demands high voltages (like 240 V AC mains) or high current, from
a relatively low voltage control signal (like 5v or 12v).
When power flows through the first circuit (1), it activates the electromagnet (brown),
generating a magnetic field (blue) that attracts a contact (red) and activates the second
circuit (2). When the power is switched off, a spring pulls the contact back up to its
original position, switching the second circuit off again.
Relays have the exact working of a switch. A relay is said to switch one or more
poles. Each pole has contacts that can be thrown in mainly three ways. They are
 Normally Open Contact (NO) – NO contact is also called a make contact. It closes
the circuit when the relay is activated. It disconnects the circuit when the relay is
inactive.
 Normally Closed Contact (NC) – NC contact is also known as break contact. This is
opposite to the NO contact. When the relay is activated, the circuit disconnects. When
the relay is deactivated, the circuit connects.
 Change-over (CO) / Double-throw (DT) Contacts – This type of contacts are used
to control two types of circuits. They are used to control a NO contact and also a NC
contact with a common terminal. According to their type they are called by the
names break before make and make before break contacts.
3. Transmitter and receiver :
An RF Transmitter and Receiver pair is used for wireless communication. The wireless
data transmission is done using 433 MHz Radio Frequency signals. The circuit is
divided into transmitter and receiver sections. The transmitter section consists of an RF
Transmitter, HT12E encoder IC and four push buttons. The receiver section consists of
RF Receiver, HT12D Decoder IC and four LEDs. An extra LED is connected to VT
(Valid Transmission) pin of the decoder IC. This is used to indicate a successful
transmission of data
The RF transmitter transmits this serial data using radio signals. At the receiver side,
the RF receiver receives the serial data.
RF Transmitter
Pin
No
Function Name
1 Ground (0V) Ground
2 Serial data input pin Data
3 Supply voltage; 5V Vcc
4 Antenna output pin ANT
RF Receiver
Pin
No
Function Name
1 Ground (0V) Ground
2 Serial data output pin Data
3 Linear output pin; not connected NC
4 Supply voltage; 5V Vcc
5 Supply voltage; 5V Vcc
6 Ground (0V) Ground
7 Ground (0V) Ground
8 Antenna input pin ANT
LCD Module:
LCD (Liquid Crystal Display) screen is an electronic display module and find a wide
range of applications. A 16x2 LCD display is very basic module and is very commonly
used in various devices and circuits. A 16x2 LCD means it can display 16 characters
per line and there are 2 such lines. In this LCD each character is displayed in 5x7 pixel
matrix. This LCD has two registers, namely, Command and Data. The command
register stores the command instructions given to the LCD. A command is an
instruction given to LCD to do a predefined task like initializing it, clearing its screen,
setting the cursor position, controlling display etc. The data register stores the data to
be displayed on the LCD. The data is the ASCII value of the character to be displayed
on the LCD.
Bluetooth Module:
Bluetooth is a type of wireless communication protocol used to send and receive date
between two devices. It is free to use wireless communication protocol.
The Module has two modes of operation namely,
 AT Command Mode:
It is a mode of the module where a set of commands (AT Commands) are used to
setup and configure the module. In this mode, the module can’t be detected by other
Bluetooth Devices. For this mode take Key pin to HIGH. All the Commands are sent
to the module serially as a string.
 Connection Mode:
In this mode the device can directly communicate with other devices. We can search
this device on other devices and can connect via entering the passkey.
The connections between HC05 module & microcontroller or other device are simple
as below:
VCC ——> 5.0V
GND ——> GND
TXD ——> RXD
RXD ——> TXD
9. PROJECT
Title: Bluetooth Based Home Automation system using smart phone.
Tools used: AVR microcontroller, AVR studio 4.0, UASasp programmer, Bluetooth HC
-06, Relays, Motors/ Bulb , Android smart phone , Wires.
Theory: We design a relay and HC-06 Bluetooth based Android Mobile controlled wireless
Home Automation system with AVR ATmega16 microcontroller .We will also use
the Android Mobile as the input device to control the appliances wirelessly.
The communication between HC-06 Bluetooth Module and Android Mobile takes
place through wireless Bluetooth technology. And the communication between
HC-06 Bluetooth Module and ATmega16 microcontroller takes place through
UART serial communication protocol. The HC-06 Bluetooth Module and Android
Mobile are connected through Bluetooth. User enters the control signal from
Android Mobile through Bluetooth Terminal App and the Android Mobile
transmits the control signal to the HC-06 Bluetooth Module through its bluetooth.
The HC-06 Bluetooth Module receives the control signal and transmits it to the
ATmega16 microcontroller through UART.The ATmega16 microcontroller
receives the control signal and processes it and sends the required control signal to
the Relay Driver. Relay Driver will turn On or Off the home appliances according
the control signal received from the ATmega16 microcontroller. The ATmega16
microcontroller also sends the appliance status to the Android Mobile through
bluetooth.
Circuit Design:
Code on AVR Studio 4.0:
#define F_CPU 8000000UL
#define USART_BAUDRATE 9600
#define BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE * 16UL))) - 1)
#include<avr/io.h>
#include<util/delay.h>
void BlueInit()
{
UCSRB |= (1 << RXEN) | (1 << TXEN); // Enable transmission and reception
UCSRC |= (1 << URSEL) | (1<<USBS) | (1 << UCSZ0) | (1 << UCSZ1); // Use 8-bit character sizes
UBRRL = BAUD_PRESCALE;
UBRRH = (BAUD_PRESCALE >> 8);
}
void BlueWrChar(unsigned char d)
{ while ((UCSRA & (1 << UDRE)) == 0); // wait till UDR is ready
UDR = d; // send data
}
unsigned int BlueRdChar()
{ while ((UCSRA & (1 << RXC)) == 0); // wait until data has been received
return(UDR); // return the byte
}
int main()
{
unsigned char value;
DDRA=0x0F;
_delay_ms(50); // delay of 50 mili seconds
BlueInit(); // initialization of USART
while(1)
{
value=BlueRdChar(); // get data from serial port
BlueWrChar(value);
if (value=='u' || value=='U')
{
PORTA=0b11111110; // Pattren 1 flow
}
else if (value=='l' || value=='L')
{
PORTA=0b11111101; // Pattren 2 flow
}
else if (value=='d' || value=='D')
{
PORTA=0b11111011; // Pattren 3 flow
}
else if (value=='r' || value=='R')
{
PORTA=0b11110111; // Pattren 4 flow
}
else if (value=='a' || value=='A')
{
PORTA=0b11110000; // Pattren 5 flow
}
else if (value=='b' || value=='B')
{
PORTA=0b11111000; // Pattren 6 flow
}
else if (value=='c' || value=='C')
{
PORTA=0b11111100; // Pattren 7 flow
}
else if (value=='e' || value=='E')
{
PORTA=0b11111110; // Pattren 8 flow
_delay_ma(500);
PORTA=0b11111101;
_delay_ma(500);
PORTA=0b11111011;
_delay_ma(500);
PORTA=0b11110111;
_delay_ma(500);
}
else if (value=='f' || value=='F')
{
PORTA=0b11110111; // Pattren 9 flow
_delay_ma(500);
PORTA=0b11111011;
_delay_ma(500);
PORTA=0b11111101;
_delay_ma(500);
PORTA=0b11111110;
_delay_ma(500);
}
else if (value=='g' || value=='G')
{
PORTA=0b11110101;
_delay_ma(500); // Pattren 10 flow
PORTA=0b11111010;
_delay_ma(500);
}
else if (value=='h' || value=='H')
{
PORTA=0xff; // Stopped
}
}
return 0;
}
10. Bibliography:
 www.engineersgarage.com
 http://raycoreindia.com
 www.ablab.in
 www.extremeelectronics.co.in

More Related Content

What's hot (20)

PPTX
PPT ON PCB DESIGN INTERNSHIP
SujoyHalder4
 
PPTX
Timer counter in arm7(lpc2148)
Aarav Soni
 
PPT
Adc interfacing
Monica Gunjal
 
PPTX
Advance Microcontroller AVR
Daksh Raj Chopra
 
PDF
Controlling a home appliance using IR remote
Chittaranjan Baliarsingh
 
PPT
Arm organization and implementation
Shubham Singh
 
PPT
Interrupts for PIC18
raosandy11
 
PDF
Microcontroller pic 16f877 architecture and basics
Nilesh Bhaskarrao Bahadure
 
PDF
Lecture 2 Sensor and Actuation Systems for Mechatronics
Amanuel Diriba From Jimma Institute of Technology
 
PDF
Project report on bidirectional visitor counter & home automation
Roshan Mani
 
PDF
Embedded system in Smart Cards
Rebecca D'souza
 
PPTX
Smart home Environment using iot
parvathy s m
 
PPTX
Use of plc in industrial automation
Aloka Patro
 
PPTX
Obstacle Avoidance ROBOT using ARDUINO
jovin Richard
 
PDF
Unit VI CPLD-FPGA Architecture
Principal,Guru Nanak Institute of Technology, Nagpur
 
PPTX
IR Sensor Working and Concepts
Robo India
 
PPTX
ppt on embedded system
manish katara
 
PPTX
Line follower robot
Rohit Dadoriya
 
PPTX
timer counter (1).pptx
SujalKumar73
 
PPS
What is Arduino ?
Niket Chandrawanshi
 
PPT ON PCB DESIGN INTERNSHIP
SujoyHalder4
 
Timer counter in arm7(lpc2148)
Aarav Soni
 
Adc interfacing
Monica Gunjal
 
Advance Microcontroller AVR
Daksh Raj Chopra
 
Controlling a home appliance using IR remote
Chittaranjan Baliarsingh
 
Arm organization and implementation
Shubham Singh
 
Interrupts for PIC18
raosandy11
 
Microcontroller pic 16f877 architecture and basics
Nilesh Bhaskarrao Bahadure
 
Lecture 2 Sensor and Actuation Systems for Mechatronics
Amanuel Diriba From Jimma Institute of Technology
 
Project report on bidirectional visitor counter & home automation
Roshan Mani
 
Embedded system in Smart Cards
Rebecca D'souza
 
Smart home Environment using iot
parvathy s m
 
Use of plc in industrial automation
Aloka Patro
 
Obstacle Avoidance ROBOT using ARDUINO
jovin Richard
 
IR Sensor Working and Concepts
Robo India
 
ppt on embedded system
manish katara
 
Line follower robot
Rohit Dadoriya
 
timer counter (1).pptx
SujalKumar73
 
What is Arduino ?
Niket Chandrawanshi
 

Viewers also liked (16)

DOCX
100317
ivanov15548
 
DOCX
100321
ivanov15548
 
DOCX
Examine the view that climate change is undermining the achievement of sustai...
herbert chitongo
 
DOCX
100336
ivanov15548
 
PPTX
Una muestra sobre nuestra historia en
RODOLFO ESPINOZACORDOBA
 
DOC
Buy Twitter Followers
DeEasta Hitt
 
PDF
Slide Share Features 8M ICT Work
helzlance
 
DOCX
100409
ivanov15548
 
DOCX
100454
ivanov15548
 
PPTX
Infoxificación (copia en conflicto de 2 ci2016d88c8f60 2014 06-14)
Peke Ño
 
PDF
International civil protection and risk reduction Functional Center
Riccardo Cocozza
 
PPTX
Creative commons TIA2 María Isabel
Maria Isabel Lora Martín
 
PPTX
internet of things
Galgotias College of Engg. & Tech.
 
PPTX
Johann Sebastian Bach, Music History
Yoelvis Medero Lunar
 
PPT
Simulating communication systems with MATLAB: An introduction
Aniruddha Chandra
 
100317
ivanov15548
 
100321
ivanov15548
 
Examine the view that climate change is undermining the achievement of sustai...
herbert chitongo
 
100336
ivanov15548
 
Una muestra sobre nuestra historia en
RODOLFO ESPINOZACORDOBA
 
Buy Twitter Followers
DeEasta Hitt
 
Slide Share Features 8M ICT Work
helzlance
 
100409
ivanov15548
 
100454
ivanov15548
 
Infoxificación (copia en conflicto de 2 ci2016d88c8f60 2014 06-14)
Peke Ño
 
International civil protection and risk reduction Functional Center
Riccardo Cocozza
 
Creative commons TIA2 María Isabel
Maria Isabel Lora Martín
 
Johann Sebastian Bach, Music History
Yoelvis Medero Lunar
 
Simulating communication systems with MATLAB: An introduction
Aniruddha Chandra
 
Ad

Similar to Training report on embedded sys_AVR (20)

PDF
Microcontroller
Kumar Satyam
 
PDF
Microprocessor vs. Microcontroller - Understand the Key Differences | Piest S...
PiestSystems
 
PPTX
PPT MES class.pptx
kavithadcs
 
PPTX
MES PPT.pptx
kavithadcs
 
PDF
Micro controller
محمدعبد الحى
 
PPT
Embeddedsystem
anshul parmar
 
PPT
Embedded system
Anmol Bagga
 
PPTX
Introduction to embedded System.pptx
Pratik Gohel
 
PPT
Ajal mod 1
AJAL A J
 
PDF
Report (2)
Shivangi Dwivedi
 
PPTX
Microcontoller and Embedded System
Karan Thakkar
 
PDF
Embedded systems introduction
mohamed drahem
 
PDF
Basics of Embedded System
Rajesh Roshan
 
PPTX
Basics of Embedded Systems & IoT..................
novedh
 
PPTX
13. Module-3-Embedded systems.pptx
Chaitanya Jambotkar
 
PPTX
Prerna sharma
RCET
 
PPTX
Embedded Systems Introdution
Sheikh Ismail
 
PDF
introduction to embedded systems part 2
Hatem Abd El-Salam
 
PPTX
ESD unit 1.pptx
VamsiReddy171587
 
PDF
Module-1 Embedded computing.pdf
Sitamarhi Institute of Technology
 
Microcontroller
Kumar Satyam
 
Microprocessor vs. Microcontroller - Understand the Key Differences | Piest S...
PiestSystems
 
PPT MES class.pptx
kavithadcs
 
MES PPT.pptx
kavithadcs
 
Micro controller
محمدعبد الحى
 
Embeddedsystem
anshul parmar
 
Embedded system
Anmol Bagga
 
Introduction to embedded System.pptx
Pratik Gohel
 
Ajal mod 1
AJAL A J
 
Report (2)
Shivangi Dwivedi
 
Microcontoller and Embedded System
Karan Thakkar
 
Embedded systems introduction
mohamed drahem
 
Basics of Embedded System
Rajesh Roshan
 
Basics of Embedded Systems & IoT..................
novedh
 
13. Module-3-Embedded systems.pptx
Chaitanya Jambotkar
 
Prerna sharma
RCET
 
Embedded Systems Introdution
Sheikh Ismail
 
introduction to embedded systems part 2
Hatem Abd El-Salam
 
ESD unit 1.pptx
VamsiReddy171587
 
Module-1 Embedded computing.pdf
Sitamarhi Institute of Technology
 
Ad

Recently uploaded (20)

PDF
REINFORCEMENT LEARNING IN DECISION MAKING SEMINAR REPORT
anushaashraf20
 
PDF
SERVERLESS PERSONAL TO-DO LIST APPLICATION
anushaashraf20
 
PDF
Electrical Engineer operation Supervisor
ssaruntatapower143
 
PPTX
What is Shot Peening | Shot Peening is a Surface Treatment Process
Vibra Finish
 
PDF
WD2(I)-RFQ-GW-1415_ Shifting and Filling of Sand in the Pond at the WD5 Area_...
ShahadathHossain23
 
PDF
Electrical Machines and Their Protection.pdf
Nabajyoti Banik
 
PDF
Halide Perovskites’ Multifunctional Properties: Coordination Engineering, Coo...
TaameBerhe2
 
PDF
Digital water marking system project report
Kamal Acharya
 
PPTX
OCS353 DATA SCIENCE FUNDAMENTALS- Unit 1 Introduction to Data Science
A R SIVANESH M.E., (Ph.D)
 
PDF
Submit Your Papers-International Journal on Cybernetics & Informatics ( IJCI)
IJCI JOURNAL
 
PPTX
Numerical-Solutions-of-Ordinary-Differential-Equations.pptx
SAMUKTHAARM
 
PDF
methodology-driven-mbse-murphy-july-hsv-huntsville6680038572db67488e78ff00003...
henriqueltorres1
 
PDF
Reasons for the succes of MENARD PRESSUREMETER.pdf
majdiamz
 
PDF
AN EMPIRICAL STUDY ON THE USAGE OF SOCIAL MEDIA IN GERMAN B2C-ONLINE STORES
ijait
 
PPTX
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
PPTX
Introduction to Internal Combustion Engines - Types, Working and Camparison.pptx
UtkarshPatil98
 
PDF
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
PDF
Viol_Alessandro_Presentazione_prelaurea.pdf
dsecqyvhbowrzxshhf
 
PPTX
fatigue in aircraft structures-221113192308-0ad6dc8c.pptx
aviatecofficial
 
PPTX
澳洲电子毕业证澳大利亚圣母大学水印成绩单UNDA学生证网上可查学历
Taqyea
 
REINFORCEMENT LEARNING IN DECISION MAKING SEMINAR REPORT
anushaashraf20
 
SERVERLESS PERSONAL TO-DO LIST APPLICATION
anushaashraf20
 
Electrical Engineer operation Supervisor
ssaruntatapower143
 
What is Shot Peening | Shot Peening is a Surface Treatment Process
Vibra Finish
 
WD2(I)-RFQ-GW-1415_ Shifting and Filling of Sand in the Pond at the WD5 Area_...
ShahadathHossain23
 
Electrical Machines and Their Protection.pdf
Nabajyoti Banik
 
Halide Perovskites’ Multifunctional Properties: Coordination Engineering, Coo...
TaameBerhe2
 
Digital water marking system project report
Kamal Acharya
 
OCS353 DATA SCIENCE FUNDAMENTALS- Unit 1 Introduction to Data Science
A R SIVANESH M.E., (Ph.D)
 
Submit Your Papers-International Journal on Cybernetics & Informatics ( IJCI)
IJCI JOURNAL
 
Numerical-Solutions-of-Ordinary-Differential-Equations.pptx
SAMUKTHAARM
 
methodology-driven-mbse-murphy-july-hsv-huntsville6680038572db67488e78ff00003...
henriqueltorres1
 
Reasons for the succes of MENARD PRESSUREMETER.pdf
majdiamz
 
AN EMPIRICAL STUDY ON THE USAGE OF SOCIAL MEDIA IN GERMAN B2C-ONLINE STORES
ijait
 
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
Introduction to Internal Combustion Engines - Types, Working and Camparison.pptx
UtkarshPatil98
 
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
Viol_Alessandro_Presentazione_prelaurea.pdf
dsecqyvhbowrzxshhf
 
fatigue in aircraft structures-221113192308-0ad6dc8c.pptx
aviatecofficial
 
澳洲电子毕业证澳大利亚圣母大学水印成绩单UNDA学生证网上可查学历
Taqyea
 

Training report on embedded sys_AVR

  • 1. A Practical Training Report On Embedded System Taken at RaycoreIndia PVT. LTD., Greater NOIDA Submitted in Partial Fulfilment of Bachelor of Technology ECE IV Year VII Semester Galgotias College of Engineering and Technology Session (2016-2017) Submitted by:- Saket Mishra Roll No.-1309731082 Submitted To:- Mr. Depaak Gangwar Department of Electronics & Communication Engineering Galgotias College of engineering and technology, Greater NOIDA
  • 2. CONTENTS Serial No. Topic 1. Company Review 2. Training certificate 3. Embedded System 4. Microcontroller (AVR) 5. Architecture of AVR (Atmega 16) 6. Embedded C 7. Interfacing of AVR 8. Modules 9. Project 10. Bibliography
  • 3. 1. Company Overview RaycoreIndia Research & automation PVT. LTD. is the start-up leader in electronics, software, services and solutions that help people and businesses realize their full potential. At RaycoreIndia, we’re motivated and inspired every day by how our customers use our services to find creative solutions to business problems, develop breakthrough ideas, and stay connected to what’s most important to them. AN ISO 9001: 2008 certified company  Training And Project development  Embedded | Robotics | Automation  Placement  Software development  Robotics Products  Research
  • 4. 2. Certification REFF NO: RAYGN/15/1090 Internship Offer Letter Date: 01/07/2015 SAKET MISHRA ROLL NO: 1309731082 COLLEGE: GCET / BRANCH: ECE Dear, I am pleased to confirm your acceptance of an internship position as software trainee in EMBEDDED SYSTEM. Complete module of ONE year at Greater Noida Branch. Your first day of the training will be 04/07/2015. Your duties and assignments for this position will be those described to you in your orientation with Mr Pradeep. Please report to the Human Resources Department at 10 a.m. on 04/07/2015 with the appropriate documents and completed forms. If you have any questions, please feel free to contact Mr Amit. We are very pleased that you have decided to join RaycoreIndia Pvt. Ltd. We look forward to seeing you on 04/17/2015 and offer a very warm welcome. Sincerely, Thanking you HR DEPARTMENT Satish Bhuyan Raycore India Research & Automation PVT. LTD. WWW.RAYCOREINDIA.COM : MOB: +91 9643736342: PHONE: 0120 4126369
  • 5. 3. Introduction of Embedded System Embedded means something that is attached to another thing. An embedded system can be thought of as a computer hardware system having software embedded in it. An embedded system can be an independent system or it can be a part of a large system. An embedded system is a microcontroller or microprocessor based system which is designed to perform a specific task. DEFINITION: Embedded System is a combination of Hardware and Software to meet specific needs in a given time frame. Embeddedsystemscontaintwomainelements:  Embedded system hardware: As with any electronic system, an embedded system requires a hardware platform on which to run. The hardware will be based around a microprocessor or microcontroller. The embedded system hardware will also contain other elements including memory, input output (I/O) interfaces as well as the user interface, and the display.  Embedded system software: The embedded system software is written to perform a particular function. It is typically written in a high level format and then compiled down to provide code that can be lodged within a non-volatile memory within the hardware. Examples of Embedded System:  Automated transaction machines (ATMS).  Integrated system in aircraft and missile.  Cellular telephones and telephonic switches.  Computer network equipment, including routers timeservers and firewalls  Computer printers, Copiers.
  • 6. Basic Structure of an Embedded System Block diagram of a typical embedded system is shown in fig. CHARACTERISTICS  Embedded systems are application specific & single functioned; the programs are executed repeatedly.  Efficiency is of paramount importance for embedded systems. They are optimized for energy, code size, execution time, weight & dimensions, and cost.  Embedded systems are typically designed to meet real time constraints; a real time system reacts to stimuli from the controlled object/ operator within the time interval dictated by the environment. For real time systems, right answers arriving too late (or even too early) are wrong.  Embedded systems often interact (sense, manipulate & communicate) with external world through sensors and actuators and hence are typically reactive systems; a reactive system is in continual interaction with the environment and executes at a pace determined by that environment.  They generally have minimal or no user interface. 4. Microcontroller Embedded Systems
  • 7. A microcontroller is a functional computer system-on-a-chip. It contains an integrated processor, memory (a small amount of RAM, program memory, or both), several peripheral devices, such as timers, analog to digital converters, and serial communication devices all on one chip resulting in compact and low-power implementations. It is not expandable as it has no external bus interface. Microcontrollers provide pin access which allows programs to easily monitor sensors, set actuators, and transfer data with other devices. Providing specialized instructions improves performance for embedded systems applications; thus, microcontrollers can be considered ASIPs to some degree. AVR History of AVR: AVR was developed in the year 1996 by Atmel Corporation. The architecture of AVR was developed by Alf-Egil Bogen and Vegard Wollan. AVR derives its name from its developers and stands for Alf-Egil Bogen Vegard Wollan RISC microcontroller, also known as Advanced Virtual RISC. The AT90S8515 was the first microcontroller which was based on AVR architecture however the first microcontroller to hit the commercial market was AT90S1200 in the year 1997. AVR microcontrollers are available in three categories: 1. Tiny AVR – Less memory, small size, suitable only for simpler applications
  • 8. 2. Mega AVR – These are the most popular ones having good amount of memory (upto 256 KB), higher number of inbuilt peripherals and suitable for moderate to complex applications. 3. Xmega AVR – Used commercially for complex applications, which require large program memory and high speed. The following table compares the above mentioned AVR series of microcontrollers: Series Name Pins Flash Memory Special Feature Tiny AVR 6-32 0.5-8 KB Small in size Mega AVR 28-100 4-256KB Extended peripherals X mega AVR 44-100 16-384KB DMA , Event System included What’s special about AVR? They are fast: AVR microcontroller executes most of the instructions in single execution cycle. AVRs are about 4 times faster than PICs, they consume less power and can be operated in different power saving modes. Let’s do the comparison between the three most commonly used families of microcontrollers. AVR is an 8-bit microcontroller belonging to the family of Reduced Instruction Set Computer (RISC). In RISC architecture the instruction set of the computer are not only fewer in number but also simpler and faster in operation. The other type of categorization is CISC (Complex Instruction Set Computers). CHARACTERISTICS 8051 PIC AVR SPEED Slow Moderate Fast MEMORY Small Large Large ARCHITECTURE CISC RISC RISC ADC Not Present Inbuilt Inbuilt TIMERS Inbuilt Inbuilt Inbuilt PWM Channels Not Present Inbuilt Inbuilt
  • 9. What is 8-bit? This means that the microcontroller is capable of transmitting and receiving 8- bit data. The input/output registers available are of 8-bits. The AVR family controllers have register based architecture which means that both the operands for an operation are stored in a register and the result of the operation is also stored in a register. Following figure shows a simple example performing OR operation between two input registers and storing the value in Output Register. The CPU takes values from two input registers INPUT-1 and INPUT-2, performs the logical operation and stores the value into the OUTPUT register. All this happens in 1 execution cycle. In our journey with the AVR we will be working on Atmega16 microcontroller, which is a 40- pin IC and belongs to the mega AVR category of AVR family. Some of the features of Atmega16 are: o 16KB of Flash memory o 1KB of SRAM o 512 Bytes of EEPROM o Available in 40-Pin DIP o 8-Channel 10-bit ADC o Two 8-bit Timers/Counters o One 16-bit Timer/Counter o 4 PWM Channels
  • 10. o In System Programmer (ISP) o Serial USART o SPI Interface o Digital to Analog Comparator. 5. Architecture of AVR The AVR microcontrollers are based on the advanced RISC architecture and consist of 32 x 8- bit general purpose working registers. Within one single clock cycle, AVR can take inputs from two general purpose registers and put them to ALU for carrying out the requested operation, and transfer back the result to an arbitrary register. The ALU can perform arithmetic as well as logical operations over the inputs from the register or between the register and a constant. Single register operations like taking a complement can also be executed in ALU. We can see that AVR does not have any register like accumulator as in 8051 family of microcontrollers; the operations can be performed between any of the registers and can be stored in either of them. AVR follows Harvard Architecture format in which the processor is equipped with separate memories and buses for Program and the Data information. Here while an instruction is being executed, the next instruction is pre-fetched from the program memory. Since AVR can perform single cycle execution, it means that AVR can execute 1 million instructions per second if cycle frequency is 1MHz. The higher is the operating frequency of the controller, the higher will be its processing speed. We need to optimize the power consumption with processing speed and hence need to select the operating frequency
  • 11. accordingly. There are two flavours for Atmega16 microcontroller: 1. Atmega16:- Operating frequency range is 0 – 16 MHz 2. Atmega16L:- Operating frequency range is 0 – 8 MHz If we are using a crystal of 8 MHz = 8 x 106 Hertz = 8 Million cycles, then AVR can execute 8 million instructions. Naming Convention The AT refers to Atmel the manufacturer, Megameans that the microcontroller belong to Mega AVR category, 16 signifies the memory of the controller, which is 16KB. Architecture Diagram: Atmega16 Following points explain the building blocks of Atmega16 architecture: I/O Ports: Atmega16 has four (PORTA, PORTB, PORTC and PORTD) 8-bit input-output ports. Internal Calibrated Oscillator: Atmega16 is equipped with an internal oscillator for driving its clock. By default Atmega16 is set to operate at internal calibrated oscillator of 1 MHz The maximum frequency of internal oscillator is 8Mhz. Alternatively, ATmega16 can be operated using an external crystal oscillator with a maximum frequency of 16MHz.
  • 12. ADC Interface: Atmega16 is equipped with an 8 channel ADC (Analog to Digital Converter) with a resolution of 10-bits. ADC reads the analog input for e.g., a sensor input and converts it into digital information which is understandable by the microcontroller. Timers/Counters: Atmega16 consists of two 8-bit and one 16-bit timer/counter. Timers are useful for generating precision actions for e.g., creating time delays between two operations. Interrupts: Atmega16 consists of 21 interrupt sources out of which four are external. The remaining are internal interrupts which support the peripherals like USART, ADC, Timers etc. USART: Universal Synchronous and Asynchronous Receiver and Transmitter interface is available for interfacing with external device capable of communicating serially (data transmission bit by bit). General Purpose Registers: Atmega16 is equipped with 32 general purpose registers which are coupled directly with the Arithmetic Logical Unit (ALU) of CPU. Memory: Atmega16 consist of three different memory sections:  Flash EEPROM: Flash EEPROM or simple flash memory is used to store the program dumped or burnt by the user on to the microcontroller. It can be easily erased electrically a single unit. Flash memory is non-volatile i.e., it retains the program even if the power is cut-off. Atmega16 is available with 16KB of in system programmable Flash EEPROM.  Byte Addressable EEPROM: This is also a non-volatile memory used to store data like values of certain variables. Atmega16 has 512 bytes of EEPROM, this memory can
  • 13. be useful for storing the lock code if we are designing an application like electronic door lock.  SRAM: Static Random Access Memory, this is the volatile memory of microcontroller i.e., data is lost as soon as power is turned off. Atmega16 is equipped with 1KB of internal SRAM. A small portion of SRAM is set aside for general purpose registers used by CPU and some for the peripheral subsystems of the microcontroller. ISP: AVR family of controllers have In System Programmable Flash Memory which can be programmed without removing the IC from the circuit, ISP allows to reprogram the controller while it is in the application circuit. SPI: Serial Peripheral Interface, SPI port is used for serial communication between two devices on a common clock source. The data transmission rate of SPI is more than that of USART. TWI: Two Wire Interface (TWI) can be used to set up a network of devices, many devices can be connected over TWI interface forming a network, the devices can simultaneously transmit and receive and have their own unique address. DAC: Atmega16 is also equipped with a Digital to Analog Converter (DAC) interface which can be used for reverse action performed by ADC. DAC can be used when there is a need of converting a digital signal to analog signal. AVR Pin description: Pin No. Pin name Description Alternate Function 1 (XCK/T0) PB0 I/O PORTB, Pin 0 T0: Timer0 External Counter Input. XCK : USART External Clock I/O 2 (T1) PB1 I/O PORTB, Pin 1 T1:Timer1 External Counter Input 3 (INT2/AIN0) PB2 I/O PORTB, Pin 2 AIN0: Analog Comparator Positive I/P INT2: External Interrupt 2 Input 4 (OC0/AIN1) PB3 I/O PORTB, Pin 3 AIN1: Analog Comparator Negative I/P OC0 : Timer0 Output Compare Match Output 5 (SS) PB4 I/O PORTB, Pin 4 In System Programmer (ISP) Serial Peripheral Interface (SPI)6 (MOSI) PB5 I/O PORTB, Pin 5
  • 14. 7 (MISO) PB6 I/O PORTB, Pin 6 8 (SCK) PB7 I/O PORTB, Pin 7 9 RESET Reset Pin, Active Low Reset 10 Vcc Vcc = +5V 11 GND GROUND 12 XTAL2 Output to Inverting Oscillator Amplifier 13 XTAL1 Input to Inverting Oscillator Amplifier 14 (RXD) PD0 I/O PORTD, Pin 0 USART Serial Communication Interface 15 (TXD) PD1 I/O PORTD, Pin 1 16 (INT0) PD2 I/O PORTD, Pin 2 External Interrupt INT0 17 (INT1) PD3 I/O PORTD, Pin 3 External Interrupt INT1 18 (OC1B) PD4 I/O PORTD, Pin 4 PWM Channel Outputs 19 (OC1A) PD5 I/O PORTD, Pin 5 20 (ICP) PD6 I/O PORTD, Pin 6 Timer/Counter1 Input Capture Pin 21 PD7 (OC2) I/O PORTD, Pin 7 Timer/Counter2 Output Compare Match Output 22 PC0 (SCL) I/O PORTC, Pin 0 TWI Interface 23 PC1 (SDA) I/O PORTC, Pin 1 24 PC2 (TCK) I/O PORTC, Pin 2 JTAG Interface 25 PC3 (TMS) I/O PORTC, Pin 3 26 PC4 (TDO) I/O PORTC, Pin 4 27 PC5 (TDI) I/O PORTC, Pin 5 28 PC6 (TOSC1) I/O PORTC, Pin 6 Timer Oscillator Pin 1 29 PC7 (TOSC2) I/O PORTC, Pin 7 Timer Oscillator Pin 2 30 AVcc Voltage Supply = Vcc for ADC 31 GND GROUND
  • 15. 32 AREF Analog Reference Pin for ADC 33 PA7 (ADC7) I/O PORTA, Pin 7 ADC Channel 7 34 PA6 (ADC6) I/O PORTA, Pin 6 ADC Channel 6 35 PA5 (ADC5) I/O PORTA, Pin 5 ADC Channel 5 36 PA4 (ADC4) I/O PORTA, Pin 4 ADC Channel 4 37 PA3 (ADC3) I/O PORTA, Pin 3 ADC Channel 3 38 PA2 (ADC2) I/O PORTA, Pin 2 ADC Channel 2 39 PA1 (ADC1) I/O PORTA, Pin 1 ADC Channel 1 40 PA0 (ADC0) I/O PORTA, Pin 0 ADC Channel 0
  • 16. 6. Embedded C (AVR Programming language)  Embedded c is a subset of c language which is compatible with certain microcontrollers.  Some features are added using header files like <avr/io.h>, <util/delay.h>.  Scanf and printf are removed as the inputs are scanned from the sensors and outputs are given to the ports.  Control structures remain the same like if-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); } We have four Ports  PORT A  PORT B  PORT C  PORT D All ports have Read-Modify-Write functionality (all pins are capable of performing dual functions)
  • 17. Points to be noted for Programming:  PORT : group of 8 pins, or set of pins used for exchanging data with external world  Width of almost all registers : 8 bits (some 16 bits)  In port related registers, every bit corresponds to one pin of the port. Bit 0 corresponds to Pin 0 & Bit 0 corresponds to Pin 1... Etc.  Remember direct one to one correspondence between HEX and BINARY numbers. 0xFF = 1111 1111 0xAA = 1010 1010 0x11 = 0001 0001 Input/output Basics:  DDRx: Data Direction (input/output) pins  Configures data direction of the port - Input / Output  DDRx.n = 0 > makes corresponding port pin as input DDRx.n = 1 > makes corresponding port pin as output  Examples : 1. To make all pins of port A as input pins : DDRA = 0b00000000; 2. To make all pins of port A as output pins DDRA = 0b11111111; 3. To make lower nibble of port B as output and higher nibble as input DDRB = 0b00001111;  PIN Register  Used to read data from port pins, when port is configured as input.  First set DDRx to zero, then use PINx to read the value.  If PINx is read, when port is configured as output, it will give you data that has been outputted on port. 1. Example : DDRA = 0x00; //Set PA as input x = PINA; //Read contents of PA
  • 18.  PORT Register For data output, when port is configured as output:  Writing to PORTx.n will immediately (in same clock cycle) change state of the port pins according to given value.  Do not forget to load DDRx with appropriate value for configuring port pins as output.  Examples : 1. To output 0xFF data on PB DDRB = 0b11111111; //set all pins of port b as outputs PORTB = 0xFF; //write data on port 2. To output data in variable x on PA DDRA = 0xFF; //make port a as output PORTA = x; //output 8 bit variable on port For configuring pin as tristate/pullup, when port is configured as input):  When port is configures as input (i.e. DDRx.n=1), then PORTx.n controls the internal pull-up resistor.  PORTx.n = 1 : Enables pullup for nth bit PORTx.n = 0 : Disables pullup for nth bit, thus making it tristate  Examples : 1. To make PA as input with pull-ups enabled and read data from PA DDRA = 0x00; //make port a as input 2. PORTA = 0xFF; //enable all pull-ups y = PINA; //read data from port a pins 3. To make PB as tri stated input DDRB = 0x00; //make port b as input 4. PORTB = 0x00; //disable pull-ups and make it tri state
  • 19. 7. Interfacing and sending code from PC to AVR Steps for coding in AVR Studio: AVR studio is an Integrated Development Environment (IDE) by ATMEL for developing applications based on AVR microcontroller. STEP 1: Click on new project. STEP 2:
  • 20. 1. Click on AVR GCC 2. Write the project name 3. Select your project location. 4. Click on Next>> STEP 3: 1. Click on AVR Simulator in left block and then select your controller (e.g.: ATmega16). 2. Click on finish button. STEP 4: 1. Write the code in main body area.
  • 21. 2. Save the project file. STEP5: Go to BUILD -> Compile. This will compile your code and generate error if there will be any. STEP 6:
  • 22. Again go to BUILD and click on Build. This will generate hex file of the code. Use that Hex file to burn your microcontroller. USBASP USB Programmer: The USBasp USB programmer is connected to PC from USB side and to the AVR through wires from the pin side. The connection is used to send the HEX file from PC to AVR microcontroller. The converted HEX file of the code is sent from PC/ system to the microcontroller is done by a software called, sinaprog. STEP 1: Click the “Folder” icon in the Hex file section and browse for the Hex file of the project, which you want to download to the microcontroller and Select the HEX file.
  • 23. STEP 2: Click the “Program” button in the Flash section to start the download of code/program (Hex file of project) to the Flash memory of the microcontroller.
  • 24. STEP 3: If the code/program download succeeds, then “Programming Flash…OK” is displayed in the Status section band if the download fails, then “Programming failed” is displayed in the Status section. 8. Modules 1. I R sensors: The principle of operation of an infrared sensor is based on infrared light that is reflected when hitting an obstacle. An IR receiver (Photo Diode) captures the reflected light and the voltage are measured based on the amount of light received. Infrared sensors are used in a wide range of applications proximity detection, robotic applications for distance and object detection, and colour detection and tracking. The output of the IR sensor can be digital or analog.
  • 25. If the output of the analog IR sensor is analog in nature and these analog signals cannot be processed directly by the ATmega16 microcontroller. So, first this signal needs to be converted to digital value to be processed by the microcontroller. The conversion can be done with the help of ADC of the AVR ATmega16 microcontroller. After converting the analog signal to digital, the microcontroller will display the digital value in the 1×8 LED array. Pin description:  Pin 1 is the output so we wire this to a visible LED and resistor  Pin 2 is ground  Pin 3 is VCC, connect to 5V 2. Relay: Relays are very interesting and useful electronic component. They are a kind of switch, like those we use every day in our home and offices to turn on and off electrical devices like bulbs, TVs, fans etc. The function of relay is to control the switching of a relatively heavier load which demands high voltages (like 240 V AC mains) or high current, from a relatively low voltage control signal (like 5v or 12v). When power flows through the first circuit (1), it activates the electromagnet (brown), generating a magnetic field (blue) that attracts a contact (red) and activates the second circuit (2). When the power is switched off, a spring pulls the contact back up to its original position, switching the second circuit off again. Relays have the exact working of a switch. A relay is said to switch one or more poles. Each pole has contacts that can be thrown in mainly three ways. They are  Normally Open Contact (NO) – NO contact is also called a make contact. It closes the circuit when the relay is activated. It disconnects the circuit when the relay is inactive.
  • 26.  Normally Closed Contact (NC) – NC contact is also known as break contact. This is opposite to the NO contact. When the relay is activated, the circuit disconnects. When the relay is deactivated, the circuit connects.  Change-over (CO) / Double-throw (DT) Contacts – This type of contacts are used to control two types of circuits. They are used to control a NO contact and also a NC contact with a common terminal. According to their type they are called by the names break before make and make before break contacts. 3. Transmitter and receiver : An RF Transmitter and Receiver pair is used for wireless communication. The wireless data transmission is done using 433 MHz Radio Frequency signals. The circuit is divided into transmitter and receiver sections. The transmitter section consists of an RF Transmitter, HT12E encoder IC and four push buttons. The receiver section consists of RF Receiver, HT12D Decoder IC and four LEDs. An extra LED is connected to VT (Valid Transmission) pin of the decoder IC. This is used to indicate a successful transmission of data The RF transmitter transmits this serial data using radio signals. At the receiver side, the RF receiver receives the serial data.
  • 27. RF Transmitter Pin No Function Name 1 Ground (0V) Ground 2 Serial data input pin Data 3 Supply voltage; 5V Vcc 4 Antenna output pin ANT RF Receiver Pin No Function Name 1 Ground (0V) Ground 2 Serial data output pin Data 3 Linear output pin; not connected NC 4 Supply voltage; 5V Vcc 5 Supply voltage; 5V Vcc 6 Ground (0V) Ground 7 Ground (0V) Ground 8 Antenna input pin ANT LCD Module: LCD (Liquid Crystal Display) screen is an electronic display module and find a wide range of applications. A 16x2 LCD display is very basic module and is very commonly used in various devices and circuits. A 16x2 LCD means it can display 16 characters per line and there are 2 such lines. In this LCD each character is displayed in 5x7 pixel matrix. This LCD has two registers, namely, Command and Data. The command register stores the command instructions given to the LCD. A command is an instruction given to LCD to do a predefined task like initializing it, clearing its screen, setting the cursor position, controlling display etc. The data register stores the data to
  • 28. be displayed on the LCD. The data is the ASCII value of the character to be displayed on the LCD. Bluetooth Module: Bluetooth is a type of wireless communication protocol used to send and receive date between two devices. It is free to use wireless communication protocol. The Module has two modes of operation namely,  AT Command Mode: It is a mode of the module where a set of commands (AT Commands) are used to setup and configure the module. In this mode, the module can’t be detected by other Bluetooth Devices. For this mode take Key pin to HIGH. All the Commands are sent to the module serially as a string.  Connection Mode: In this mode the device can directly communicate with other devices. We can search this device on other devices and can connect via entering the passkey.
  • 29. The connections between HC05 module & microcontroller or other device are simple as below: VCC ——> 5.0V GND ——> GND TXD ——> RXD RXD ——> TXD 9. PROJECT Title: Bluetooth Based Home Automation system using smart phone. Tools used: AVR microcontroller, AVR studio 4.0, UASasp programmer, Bluetooth HC -06, Relays, Motors/ Bulb , Android smart phone , Wires. Theory: We design a relay and HC-06 Bluetooth based Android Mobile controlled wireless Home Automation system with AVR ATmega16 microcontroller .We will also use the Android Mobile as the input device to control the appliances wirelessly. The communication between HC-06 Bluetooth Module and Android Mobile takes place through wireless Bluetooth technology. And the communication between HC-06 Bluetooth Module and ATmega16 microcontroller takes place through UART serial communication protocol. The HC-06 Bluetooth Module and Android Mobile are connected through Bluetooth. User enters the control signal from Android Mobile through Bluetooth Terminal App and the Android Mobile transmits the control signal to the HC-06 Bluetooth Module through its bluetooth. The HC-06 Bluetooth Module receives the control signal and transmits it to the ATmega16 microcontroller through UART.The ATmega16 microcontroller receives the control signal and processes it and sends the required control signal to the Relay Driver. Relay Driver will turn On or Off the home appliances according the control signal received from the ATmega16 microcontroller. The ATmega16 microcontroller also sends the appliance status to the Android Mobile through bluetooth.
  • 30. Circuit Design: Code on AVR Studio 4.0: #define F_CPU 8000000UL #define USART_BAUDRATE 9600
  • 31. #define BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE * 16UL))) - 1) #include<avr/io.h> #include<util/delay.h> void BlueInit() { UCSRB |= (1 << RXEN) | (1 << TXEN); // Enable transmission and reception UCSRC |= (1 << URSEL) | (1<<USBS) | (1 << UCSZ0) | (1 << UCSZ1); // Use 8-bit character sizes UBRRL = BAUD_PRESCALE; UBRRH = (BAUD_PRESCALE >> 8); } void BlueWrChar(unsigned char d) { while ((UCSRA & (1 << UDRE)) == 0); // wait till UDR is ready UDR = d; // send data } unsigned int BlueRdChar() { while ((UCSRA & (1 << RXC)) == 0); // wait until data has been received return(UDR); // return the byte } int main() { unsigned char value; DDRA=0x0F; _delay_ms(50); // delay of 50 mili seconds BlueInit(); // initialization of USART while(1) { value=BlueRdChar(); // get data from serial port BlueWrChar(value); if (value=='u' || value=='U') { PORTA=0b11111110; // Pattren 1 flow }
  • 32. else if (value=='l' || value=='L') { PORTA=0b11111101; // Pattren 2 flow } else if (value=='d' || value=='D') { PORTA=0b11111011; // Pattren 3 flow } else if (value=='r' || value=='R') { PORTA=0b11110111; // Pattren 4 flow } else if (value=='a' || value=='A') { PORTA=0b11110000; // Pattren 5 flow } else if (value=='b' || value=='B') { PORTA=0b11111000; // Pattren 6 flow } else if (value=='c' || value=='C') { PORTA=0b11111100; // Pattren 7 flow } else if (value=='e' || value=='E') { PORTA=0b11111110; // Pattren 8 flow _delay_ma(500); PORTA=0b11111101; _delay_ma(500); PORTA=0b11111011;
  • 33. _delay_ma(500); PORTA=0b11110111; _delay_ma(500); } else if (value=='f' || value=='F') { PORTA=0b11110111; // Pattren 9 flow _delay_ma(500); PORTA=0b11111011; _delay_ma(500); PORTA=0b11111101; _delay_ma(500); PORTA=0b11111110; _delay_ma(500); } else if (value=='g' || value=='G') { PORTA=0b11110101; _delay_ma(500); // Pattren 10 flow PORTA=0b11111010; _delay_ma(500); } else if (value=='h' || value=='H') { PORTA=0xff; // Stopped } } return 0; }
  • 34. 10. Bibliography:  www.engineersgarage.com  http://raycoreindia.com  www.ablab.in  www.extremeelectronics.co.in