Embedded System Design Using Arduino
Embedded System Design Using Arduino
DESIGN USING
ARDUINO
Santosh Kumar Verma
Content
1.
2.
3.
4.
5.
6.
7.
8.
Introduction of p and c
Introduction of 8051 c
Introduction of Arduino
Atmega328 : Basics and internal
Architecture
Atmega328 : Instruction Set
Arduino programming interface
Analog/Digital components and its
application with arduino
References
Input
Control Unit
Memory
Output
Introduction to
Microprocessor
ARITHMATIC LOGIC
UNIT
INPUT
CONTROL UNIT
MICROPROCESS
OR
OUTPU
T
MEMORY
MICROCOMPUT
ER
Microprocessor Based
System
INPUT
OUTPUT
MEMORY
MEMORY
INPUT
C
MEMORY
OUTPUT
External
addition
memory
desired
memory in
to internal
may
be
Address
Bus
Control
Bus
I/O
Device
I/O
Device
Data Bus
I/O
Device
Memory
Microcontroller
A microcontroller is a complete computer system, including
a CPU, memory, a clock oscillator, and I/O on a single
integrated circuit chip. [1]
ANALOG
INPUTS
http://www.freescale.com/files/microcontrollers/doc/ref_manual/M68HC05TB.pdf, p. 25
8051 MICROCONTROLLER
General Facilities
8 bit CPU
On chip clock oscillator
4 KB of ROM (Program memory)
128 bytes RAM (Data Memory)
21 Special Function Registers(SFR)
32 I/O lines (Ports P0 to P3)
64 KB address space for external data memory
64 KB address space for program memory
8051 MICROCONTROLLER
2- 16 bit timer/counter
5 source interrupt structure
Full duplex serial port
Bit addressability
Bit processing capability
MCS-51 compatible chips
8031 Romless version 4KB ROM not available
8751 EPROM version 4KB EPROM
8052- (8 KB ROM + 256 byte Data memory )
8051 MICROCONTROLLER
8051 MICROCONTROLLER
The 8051 was one of the very early
microcontrollers (~1980).
WHAT IS ARDUINO?
Introduced in 2005 as a project for students at the Interaction Design
Institute Ivrea in Ivrea, Italy, Arduino is a single board
microcontroller.
An Arduino board consists of an Atmel 8-bit AVR microcontroller with
complementary components to facilitate programming and incorporation
into other circuits [2].
Arduino can sense the environment by receiving input from a variety
of sensors and can affect its surroundings by controlling lights, motors,
and other actuators.
The boards can be assembled or purchased preassembled; the opensource IDE can be downloaded for free.
The Arduino programming language is very simple and follows C
like syntax.
Arduino projects can be stand-alone or they can communicate with
software running on a computer (e.g. Processing).
WHY ARDUINO?
Other similar microcontrollers
platforms are: Parallax Basic Stamp,
Netmedia's BX-24, Phidgets, MIT's
Handyboard, and many more.
All these platforms have an easy-touse package.
Why
Arduino?
Arduino also simplifies the process of
working with
microcontrollers, but it offers some
advantage:
ADVANTAGES OF ARDUINO
1. Inexpensive - Arduino boards are relatively
inexpensive compared to other microcontroller
platforms.
2. Cross-platform - The Arduino software runs on
Windows, Macintosh OSX, and Linux operating
systems. Most microcontroller systems are limited
to Windows.
3. Simple, clear programming environment The Arduino programming environment is easyto-use.
4. Open source and extensible software- The
Arduino software is published as open source
tools. The language can be expanded through C+
Features
8051
Modern
Microcontrollers
Execution Time
12 clock cycles/Instr.
1 clock cycle/Instr.
Architecture
Harvard
Harvard
Memory
Internal + External
(may compromise with
security)
Instruction Set
Architecture (ISA)
CISC
RISC
Port
With limited
functionality
Fully Functional
Timer
Simple
PWM, Complex
features
Intra Communication
Busses
Few
Operating Mode
Sleep
ADC
NIL
ATMEGA328 INTERNAL
ARCHITECTURE
http://www.adafruit.com/index.php?
ATMEGA328 MICROCONTROLLER
Pin
name
Pin
number
Special
functio
n
Note the
limitations!
p. 316
Source:http://www.atmel.com/dyn/products/product_card.asp?PN=ATmega328P
ATMEGA328 FEATURES
ATMEGA328 FEATURES
Peripheral Features
Two 8-bit Timer/Counters
One 16-bit Timer/Counter
Real Time Counter with Separate
Oscillator
Six PWM Channels
6-channel 10-bit ADC
Programmable Serial USART
Master/Slave SPI Serial Interface
Special Microcontroller Features
Internal Calibrated Oscillator
External and Internal Interrupt
Sources
Six Sleep Modes: Idle, ADC Noise
Reduction, Power-save, Power-down,
ATMEGA328 FEATURES
Absolute Maximums
The communication
channels through which
information flows into or
out of the microcontroller
Ex. PORTB
Pins PB0 PB7
May not be
contiguous
Often bi-directional
Output
When you want to change the state of
something outside the MCU (turn a motor on
or off, etc.)
ATmega328
Block Diagram
Inpu
t
Outp
ut
ATmega328
Ardui
no
pin 0
(PD0)
Source:http://www.atmel.com/dyn/products/product_card.asp?PN=ATmega328P p. 93
Example 1
Make Arduino pins 3, 5, and 7 (PD3, PD5,
and PD7) to be outputs
Arduino approach
pinMode(3, OUTPUT);
pinMode(5, OUTPUT);
pinMode(7, OUTPUT);
Or if me106.h is used:
pinMode(PIN_D3, OUTPUT);
pinMode(PIN_D5, OUTPUT);
pinMode(PIN_D7, OUTPUT);
DDRD = 0b10101000;
or
DDRD
Alternate
= 0xA8; approach
Example 2
Make pins Arduino pins 0 and 1 (PD0 and
PD1) inputs, and turn on the LEDs connected to
it.
Arduino approach
pinMode(0, INPUT);
pinMode(1, INPUT);
digitalWrite(0, HIGH);
digitalWrite(1, HIGH);
Or if me106.h is used:
pinMode(PIN_D0, INPUT);
pinMode(PIN_D1, INPUT);
digitalWrite(PIN_D0, HIGH);
digitalWrite(PIN_D1, HIGH);
OFFICIAL BOARDS
Arduino Duemilanove
http://www.arduino.cc/en/Main/ArduinoBoardDuemilanove
See the handout:
Arduino_ATmega328_pin_mapping_and_schematic
Pin 13
LED
USB
connect
or
Digital pins
header
Reset
button
ATmega328
MCU
Barrel
jack
Analog pins
header
Power-ground
header
http://arduino.cc/en/uploads/Main/ArduinoDuemilano
ve.jpg
Arduino Uno R3
ATmega16u2 replaces FT232RL for USB-serial comms
http://www.adafruit.com/index.php?
main_page=popup_image&pID=50
See: http://learn.adafruit.com/arduino-tips-tricks-andtechniques/arduino-uno-faq
Arduino
Due
Note: 3.3 V !!
Atmel SAM3X8E processor (32 bit ARM Cortex M3 architecture,
84MHz)
http://www.adafruit.com/index.php?
main_page=popup_image&pID=1076
See:
http://arduino.cc/en/Main/ArduinoBoardDue
Arduino Duemilanove/Uno
Features
Microcontroller
ATmega168/328
Operating Voltage
5V
Input Voltage
(recommended)
7-12V
6-20V
40 mA
50 mA
Flash Memory
16 KB (ATmega168) or 32 KB (ATmega328) of
which 2 KB used by bootloader
SRAM
1 KB (ATmega168) or 2 KB (ATmega328)
EEPROM
Clock Speed
16 MHz
http://www.arduino.cc/en/Main/ArduinoBoardDuemilanov
e
An arduino program ==
sketch
Must have:
setup()
loop()
setup()
configures pin modes and
registers
loop()
runs the main body of the
program forever
like while(1) {}
Where is main() ?
Arduino simplifies things
Does things for you
main()
{
init();
setup();
while (1)
loop();
}
Various Components
REFERENCES
1.
http://www.freescale.com/files/microcontrollers/doc/ref_manual/M68HC0
5TB.pdf
, p. 25
2.
3.
4.
5.
http://www.atmel.com/dyn/products/product_card.asp?PN=ATmega328
6.
J. Provost, Why the arduino won and why its here to stay, Tech.Rep.
7.
http://learn.adafruit.com/arduino-tips-tricks-and-techniques/arduino-unofaq
Thank
You.