Vous êtes sur la page 1sur 39

MK-4306 SISTEM MIKROKONTROLER

Microcontroller System

Introduction to Microcontroller
HENDAWAN SOEBHAKTI, ST., MT.

PROGRAM STUDI TEKNIK MEKATRONIKA D-IV


JURUSAN TEKNIK ELEKTRO
POLITEKNIK NEGERI BATAM
2013

Topics
1. Introduction
2. Microcontroller architecture
3. Arduino

MK-4306 SISTEM MIKROKONTROLER - HENDAWAN SOEBHAKTI, ST., MT.

1. Introduction

What is microcontroller?
Microcontroller is an integrated chip that
typically containts integrated CPU, memory
(RAM, ROM), I/O ports on a single chip.
Microcontroller is designed to execute a
specific task to control a single system.
Differs from microprocessor :
General purpose chip, require multiple chip to
handle various tasks.
4

Microcontroller vs Microprocessor
General Purpose Microprocessors
Data BUS

General
Purpose
Micro
processor

RAM

ROM

Timer

Serial
COM
Port

IO
Port

Address BUS
Control BUS

Microcontrollers
CPU

RAM

ROM

Serial
Port

Timer

I/O
5

Microcontroller Type
8-bit microcontrollers
AVR
PIC
HCS12
8051

32-bit microcontrollers
ARM
PIC32
6

AVR Microcontroller
AVR = Advanced Virtual RISC.
RISC = Reduced Instruction Set Computer.
The founder are Alf Egil Bogen and Vegard
Wollan, students at Norwegian Institute of
Technology on 1994.

AVR Microcontroller Family


Classic AVR
e.g. AT90S2313, AT90S4433

Mega
e.g. ATmega8, ATmega32, ATmega128

Tiny
e.g. ATtiny13, ATtiny25

Special Purpose AVR


e.g. AT90PWM216,AT90USB1287
8

AVR Classic Family

AVR Mega Family

10

AVR Tiny Family

11

AVR Special Purpose Family

12

AVR Part Numbers


ATmega128
Atmel

ATtiny44
Atmel
Tiny
group

Flash =4K

group

Flash =128K

AT90S4433
Atmel

Classic
group

Flash =4K

13

2. Microcontroller
Architecture
14

ATmega328 Pin Configuration

15

Pin Descriptions (1)

VCC
Digital supply voltage.
GND
Ground.
Port B (PB7:0) XTAL1/XTAL2/TOSC1/TOSC2
Port B is an 8-bit bi-directional I/O port with internal pull-up resistors.
Depending on the clock selection fuse settings, PB6 can be used as input
to the inverting Oscillator amplifier and input to the internal clock
operating circuit.
Depending on the clock selection fuse settings, PB7 can be used as output
from the inverting Oscillator amplifier.
If the Internal Calibrated RC Oscillator is used as chip clock source, PB7..6
is used as TOSC2..1 input for the Asynchronous Timer/Counter2 if the AS2
bit in ASSR is set.

16

Pin Descriptions (2)

Port C (PC5:0)
Port C is a 7-bit bi-directional I/O port with internal pull-up resistor.
PC6/RESET
If the RSTDISBL Fuse is programmed, PC6 is used as an I/O pin.
If RSTDISBL Fuse is unprogrammed, PC6 is used as a Reset input. A low
level on this pin for longer than the f the minimum pulse length will
generate a Reset, even if the clock is not running.
Port D (PD7:0)
Port D is an 8-bit bi-directional I/O port with internal pull-up resistors.
AVCC
AVCC is the supply voltage pin for the A/D Converter, PC3:0, and ADC7:6. 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. Note that PC6..4 use digital supply voltage, VCC.
17

Pin Descriptions (3)

AREF
AREF is the analog reference pin for the A/D Converter.
ADC7:6 (TQFP and QFN/MLF Package Only)
In the TQFP and QFN/MLF package, ADC7:6 serve as analog inputs to the
A/D converter.
These pins are powered from the analog supply and serve as 10-bit ADC
channels

18

Block Diagram
Features :
32K bytes of In-System Programmable Flash
1K bytes EEPROM
2K bytes SRAM
23 programmable I/O lines
Two 8 bit Timers/Counters
One 16 bit Timer/Counter
Six PWM channels
6 channels 10 bit ADC
External and internal interrupts
Programmable serial USART

19

3. Arduino

20

Arduino
Arduino is a single board microcontroller to
make using electronics in multidisciplinary
project more accessible.
The hardware consists of an open-source
hardware board designed araound and an 8
bit Atmel AVR or a 32 bit Atmel ARM.
Arduino started in 2005 as a project for
students at the Design Instutute of Ivrea, Italy.
21

Some Arduino Boards

Uno

Duemilanove

Nano
Leonardo

Mega

22

Specs Compare
Name
Uno
Due
Leonardo
Mega 2560
Mega ADK
Micro
Mini
Nano
Ethernet
Esplora
ArduinoBT
Fio
Pro (168)
Pro (328)
Pro Mini
LilyPad
LilyPad USB
LilyPad
Simple
LilyPad
SimpleSnap

Processor
ATmega328
AT91SAM3X8E
ATmega32u4
ATmega2560
ATmega2560
ATmega32u4
ATmega328
ATmega168
ATmega328
ATmega328
ATmega32u4
ATmega328
ATmega328P
ATmega168
ATmega328
ATmega168
ATmega168V
ATmega328V
ATmega32u4
ATmega328
ATmega328

Operating
Voltage/Input
Voltage
5 V/7-12 V
3.3 V/7-12 V
5 V/7-12 V
5 V/7-12 V
5 V/7-12 V
5 V/7-12 V
5 V/7-9 V

CPU
Speed

Analog
In/Out

Digital
IO/PWM

EEPROM
[KB]

SRAM
[KB]

Flash
[KB]

16 Mhz
84 Mhz
16 Mhz
16 Mhz
16 Mhz
16 Mhz
16 Mhz

6/0
12/2
12/0
16/0
16/0
12/0
8/0

14/6
54/12
20/7
54/15
54/15
20/7
14/6

8/0

14/6

Mini-B

5 V/7-12 V
5 V/7-12 V
5 V/2.5-12 V
3.3 V/3.7-7 V
3.3 V/3.35-12 V
5 V/5-12 V
3.3 V/3.35-12 V
5 V/5-12 V
2.7-5.5 V/2.75.5 V
3.3 V/3.8-5V
2.7-5.5 V/2.75.5 V
2.7-5.5 V/2.75.5 V

16 Mhz
16 Mhz
16 Mhz
8 Mhz
8 Mhz
16 Mhz
8 Mhz
16Mhz

6/0
6/0
8/0
6/0
6/0

14/4
14/6
14/6
14/6
14/6

32
512
32
256
256
32
32
16
32
32
32
32
32
16
32

1
4
1
4
4
1
-

16 Mhz

2
96
2.5
8
8
2.5
2
1
2
2
2.5
2
2
1
2

Regular
2 Micro
Micro
Regular
Regular
Micro
-

5 V/7-9 V

1
1
4
4
1
1
0.512
1
1
1
1
1
0.512
1

Regular
Micro
Mini
-

1
1
1
1

6/0

14/6

0.512

16

8 Mhz

6/0

14/6

0.512

16

8 Mhz

4/0

9/4

2.5

32

Micro

8 Mhz

4/0

9/4

32

8 Mhz

4/0

9/4

32

USB

UART

23

Arduino Shield

Adafruit data logging shield

Protoboard shield
Adafruit motor shield

24

Arduino Uno

The Arduino Uno is a microcontroller board based on the ATmega328.


It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog
inputs, a 16 MHz ceramic resonator, a USB connection, a power jack, an ICSP header,
and a reset button.
25

Arduino Uno Board Features


Features
Microcontroller

: ATmega328

Operating Voltage

: 5V

Input Voltage (recommended)

: 7-12V

Input Voltage (limits)

: 6-20V

Digital I/O Pins

: 14 (of which 6 provide PWM output)

Analog Input Pins

:6

DC Current per I/O Pin

: 40 mA

DC Current for 3.3V Pin

: 50 mA

Flash Memory used by bootloader

: 32 KB (ATmega328) of which 0.5 KB

SRAM

: 2 KB (ATmega328)

EEPROM

: 1 KB (ATmega328)

Clock Speed

: 16 MHz
26

Schematic Diagram

27

Power
The Arduino Uno can be powered via the USB
connection or with an external power supply. The
power source is selected automatically.
External (non-USB) power can come either from an
AC-to-DC adapter (wall-wart) or battery.
The board can operate on an external supply of 6 to 20
volts. If supplied with less than 7V, however, the 5V pin
may supply less than five volts and the board may be
unstable. If using more than 12V, the voltage regulator
may overheat and damage the board. The
recommended range is 7 to 12 volts.
28

Power (2)

VIN. The input voltage to the Arduino board when it's


using an external power source (as opposed to 5 volts
from the USB connection or other regulated power
source). You can supply voltage through this pin, or, if
supplying voltage via the power jack, access it through this
pin.
5V.This pin outputs a regulated 5V from the regulator on
the board. The board can be supplied with power either
from the DC power jack (7 - 12V), the USB connector (5V),
or the VIN pin of the board (7-12V). Supplying voltage via
the 5V or 3.3V pins bypasses the regulator, and can
damage your board. We don't advise it.
3V3. A 3.3 volt supply generated by the on-board
regulator. Maximum current draw is 50 mA.
GND. Ground pins.

29

Memory
The ATmega328 has 32 KB (with 0.5 KB used
for the bootloader). It also has 2 KB of SRAM
and 1 KB of EEPROM (which can be read and
written with the EEPROM library).

30

Input and Output


Each of the 14 digital pins on the Uno
can be used as an input or output,
using pinMode(), digitalWrite(), and
digitalRead() functions.
They operate at 5 volts.
Each pin can provide or receive a
maximum of 40 mA and has an
internal pull-up resistor (disconnected
by default) of 20-50 kOhms.
31

Input and Output (2)


In addition, some pins have specialized functions:
Serial: 0 (RX) and 1 (TX).
Used to receive (RX) and transmit (TX) TTL serial data. These pins are connected to
the corresponding pins of the ATmega8U2 USB-to-TTL Serial chip.
External Interrupts: 2 and 3.
These pins can be configured to trigger an interrupt on a low value, a rising or
falling edge, or a change in value. See the attachInterrupt() function for details.
PWM: 3, 5, 6, 9, 10, and 11.
Provide 8-bit PWM output with the analogWrite() function.
SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK).
These pins support SPI communication using the SPI library.
LED: 13.
There is a built-in LED connected to digital pin 13. When the pin is HIGH value, the
LED is on, when the pin is LOW, it's off.
32

Analog Inputs
The Uno has 6 analog inputs, labeled A0
through A5, each of which provide 10 bits
of resolution (i.e. 1024 different values).
By default they measure from ground to 5
volts, though is it possible to change the
upper end of their range using the AREF pin
and the analogReference() function.
Additionally, some pins have specialized
functionality:
TWI: A4 or SDA pin and A5 or SCL pin.
Support TWI communication using the Wire
library.
33

Other Pins
AREF. Reference voltage for the analog inputs.
Used with analogReference().
Reset. Bring this line LOW to reset the
microcontroller. Typically used to add a reset
button to shields which block the one on the
board.

34

Communications

The ATmega328 provides UART TTL (5V) serial communication, which is


available on digital pins 0 (RX) and 1 (TX). An ATmega16U2 on the board
channels this serial communication over USB and appears as a virtual com
port to software on the computer. The '16U2 firmware uses the standard
USB COM drivers, and no external driver is needed.
The Arduino software includes a serial monitor which allows simple
textual data to be sent to and from the Arduino board. The RX and TX LEDs
on the board will flash when data is being transmitted via the USB-toserial chip and USB connection to the computer (but not for serial
communication on pins 0 and 1).
A SoftwareSerial library allows for serial communication on any of the
Uno's digital pins.
The ATmega328 also supports I2C (TWI) and SPI communication. The
Arduino software includes a Wire library to simplify use of the I2C bus; see
the documentation for details. For SPI communication, use the SPI library.

35

Software

The Arduino integrated development


environment (IDE) is a cross-platform
application written in Java. It is
designed to introduce programming
to artists and other newcomers
unfamiliar with software
development.
A program or code written for
Arduino is called a "sketch
Arduino 1.5.3 (release notes)
http://arduino.cc/en/Main/Software

36

Example : LED Blink


// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led, HIGH);
// turn the LED on
delay(1000);
// wait for a second
digitalWrite(led, LOW);
// turn the LED off
delay(1000);
// wait for a second
}

37

LED on Arduino board

It is a feature of most Arduino boards that they have an LED and load
resistor connected between pin 13 and ground; a convenient feature for
many simple tests.

38

Any Question?

39

Vous aimerez peut-être aussi