Sei sulla pagina 1di 59

ROBONICS

15
Powered By:

EMBEDDED SYSTEM

An embedded system is some combination of


computer hardware and software, either fixed in
capability or programmable, that is specifically
designed for a particular function.

APPLICATIONS

Aerospace

Navigation systems, automatic landing systems,


flight attitude controls, engine controls, space
exploration (e.g.. The mars pathfinder)

APPLICATIONS

Automotive

Fuel injection control, passenger environmental


controls, anti-locking braking systems, air bag
controls, GPS mapping.

APPLICATIONS

Communicati
ons

Satellites, network routers, switches, hubs

APPLICATIONS

Medical

CT, One touch glucose meter, almost all medical


facility.

APPLICATIONS

Personal

Pagers, cell phones, video games, I-pod, MP3


players

APPLICATIONS

Home

Dishwashers, microwave ovens, VCRs, DVD,


televisions, stereos, fire/security alarm systems,
lawn sprinkler controls, thermostats, digital
cameras, clock radios, cell phones

Features/Components

Central Processing Unit and


Software
Output: LCD Display , SSD , Matrix
Display

Memory: ROM , RAM , EEPROM ,


Flash
Input: Buttons, knobs, probes ,
sensors.

MICROCONTROLLER
What Wikipedia says

A microcontroller (sometimes abbreviated C, uC or


MCU) is a small computer on a single integrated circuit
containing a processor core, memory, and
programmable input/output peripherals. Program
memory in the form of NOR flash is also often included
on chip, as well as a typically small amount of RAM.
Microcontrollers are designed for embedded
applications, in contrast to the microprocessors used in
personal computers or other general purpose
applications.

Formal Definition

Microcontrollers are programmable single chip


computers specifically designed to:
Read input devices, such as buttons and sensors
Process data or information
Control devices, such as lights, displays, motors
and speakers
Have on-chip Peripherals

Different Microcontrollers

Intel
Motorolla
Microchip

Atmel
STMicroelectronics
Texas Instruments
NXP
Toshiba
Freecscale

Atmel Microcontrollers

ATmega

ATtiny

o Atmega 8

o Atmega 16
o Atmega 32
o Atmega 328
o Atmega 644 etc

ATxmega

ATMEGA 16 : AN OVERVIEW

8-bit Micro-controller

40-pin DIP

32 Programmable I/O Lines

Operating Voltages

Speed Grades 0 - 8 MHz

16K Bytes of In-System Self-programmable Flash program memory 512


Bytes EEPROM

Two 8-bit Timer/Counters with Separate Prescalers and Compare Modes

One 16-bit Timer/Counter with Separate Prescaler, Compare Mode, and 8channel, 10-bit ADC

Programmable Serial USART

Master/Slave SPI Serial Interface

I2C interface

2.7 - 5.5V

Pin Diagram

Architecture

Simplified Diagram

Personal Computer

uP
RAM
HDD
Clock
Ports (Serial/USB)
Ports (Parallel)
Mic /Headphone Jack (ADC/ DAC)
Power Supply Unit (SMPS)
Reset Button
Mother-board

Microcontroller

uP

SRAM
EEPROM & Flash Memory
Clock Unit
SPI / UART Controllers
Digital I/O Ports
ADC
Power Supply Unit
Reset Pin
IC

MICROCONTROLLER PROGRAMMING

Machine Language
Programming
Assembly Language
Programming
High Level Language

Machine Language Programming

Code in binary instructions form


that is directly executed by the
device.

Assembly Language Programming

Code using keywords that are easy


to understand, use a software to
convert keywords into binary
instructions.
Assembler

High Level Programming

Code in symbolic form, use a software to


break symbolic instructions into actual
instructions of uC
Compiler &
Linker

OS

We will use the High Level programming


language for driving and exploiting the
capabilities of our microcontroller.

OUR PROGRAMMING ENVIRONMENT

WinAVR
Cross-Compiler & linker

PC / Laptop

Target System
(Atmega R&D Board)

PORT PROGRAMMIMG
Normal C program

Program for Ports

int x;
float y;

DDRA = 0b11111111 or 0xFF // o/p


DDRC = 0b11111111 or 0xFF // o/p

x= 10;
y= 8.97;

PORTA = 27;
// decimal
PORTC= 0b11010110; // binary

DDRx defines whether the port will act as input port or o/p port. Just as int
declares a variable as integer type. It does not assign any value to it.
PORTx assigns the value to be output. If DDRx=0 i.e port is defined as input
port, PORTx will store the value but will not o/p it.

More Examples

PORTA=0x5A ;
PORTA=0b01011010;
PORTA=5;
DDRA=0xFF;
DDRA=0b11110000;

// pins A7-A4 as o/p & A3-A0 as i/p

You can even address individual pins of any Port


DDRA.3= 1;
// Only Pin 3 of Port A (A4) is configured as o/p pin , rest
untouched

PORTA.0=1;

// pin 0 of Port A outputs 1, rest retain there previous values

Taking Input

To take Digital i/p from external world first configure the port as i/p port
using DDRx=0
Use PINx to read the digital value.
x = PINA
y= PINB

// read 8 bit integer value from Port A.

0 < x < 255

x, y must be defined as unsigned integers in ur C program.


Individual pins can be read in the same way.
x= PINA.2
either be 0 or 1

y= PINC.6

// as the individual pins are read n the value is digital, therefore x can

CHOCOLATE QUESTION

Write a program to o/p 33 (hex) on PortD and


read pins 2 and 7 of Port A

Solution

#include <avr/io.h>
#include <util/delay.h>
void main( )
{
unsigned int x,y;
DDRD=0xFF;
DDRA=0b01111011;
PORTD=0x33;
x=PINA.2;
y=PINA.7;
}

// all pins o/p


// pin 7 & 2 i/p rest immaterial

Creating the programming environment in


WinAVR

Create a folder Demo on desktop

Go to start Menu. Select WinAVR and click on Mfile

Mfile window will appear


Go to File and click on Save As

Save the mfile in the folder Demo created on desktop.


Name of the file should be Makefile .

Go to start Menu again. Select WinAVR and click on


Programmers notepad

Programmers notepad window will appear

Go to File menu and click on Save As.

Save the file naming it as main.c in the Demo folder


created on desktop.

Go to Programmers Notepad again and click on Open

Select the Makefile and open it.

We have to make certain changes in the Makefile.


MCU= atmega16

We have to make certain changes in the Makefile.


F_CPU=
8000000
TARGET= main

We have to make certain changes in the Makefile.


AVRDUDE_PROGRAMMER = usbasp
AVRDUDE_PORT =
usb001

Include the basic header files and create the main


function.

Go to Tools menu and click on Make All . Check if


there is any error or not at output window

Go to Tools menu and click on Program in order to


burn your code in the microcontroller

RESEARCH & DEVELOPMENT (R&D) BOARDS

R & D Boards are used for the rapid prototyping


of the Embedded Systems

Serial Port
IC 7805

ADC
Port

Supply

Motor
Port

LCD
Port

Motor
Driver

Reset
Button

+5V
GND

LCD
Port

Motor
Port

ADC
Port

Power
Button
IC 7805
Reset
Button
Adapter

Buzzer

LED BLINKING

HELLO! TO EMBEDDED
WORLD

Light Emitting Diode

GND
+V

Longer leg is positive Terminal

A light emitting diode is


essentially a PN junction that
emits a monochromatic light
when operated in forward bias

LED connection to Atmega

Complete Code!!

A program to make a blinking pattern


#include <avr/io.h>
#include <util/delay.h>
void main( )
{
DDRB=0xFF;
While (1) {
PORTB=0xFF;
delay_ms(500);
PORTB=0x00;
delay_ms(500);
}
}

// all pins o/p


// all LEDs ON
// all LEDs OFF

LIQUID CRYSTAL DISPLAY

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.

PIN DIAGRAM

PIN DESCRIPTION

MODES OF LCD

Two modes are there in LCD.


8 BIT MODE: In this mode of operation of
LCD, data flows on 8 bit data bus.
4BIT MODE: In this mode of operation of
LCD, data flows on 4 bit data bus.

LCD DEMO

PRINT YOUR NAME ON


LCD!!

Contact Us:
www.amuroboclub.in
www.amu.ac.in/rclub.jsp

amuroboclub@gmail.com

fb.com/amuroboculb

Potrebbero piacerti anche