Introduction To Microcontroller
Introduction To Microcontroller
RAM/Primary
memory or input
device
ROM Microprocessor
RAM/Primary
memory or output
device
2
Dr. Mohammad Mahbubur Rahman
Microcomputer is used to describe a system that includes a minimum of a microprocessor, program memory,
data memory, and input/output (I/O). Some microcomputer systems include additional components such as
timers, counters, analogue-to-digital converters and so on.
Input
RAM device
ROM Microprocessor
Output device
3
Dr. Mohammad Mahbubur Rahman
Microcontroller
• A smaller computer on a CHIP
• On-chip RAM, ROM, I/O Ports, Timer, Serial Controller…
• Example: Motorola’s 6811, Intel’s 8051, Atmel 32
Microprocessor vs. Microcontroller
Microprocessor Microcontroller
• CPU is stand-alone, RAM, • CPU, RAM, ROM, I/O and timer
ROM, I/O, timer are separate are all on a single chip
1
Dr. Mohammad Mahbubur Rahman
2
Read Only Memory (ROM)
• Central Processing Unit
Read Only Memory (ROM) is a type of memory used to permanently save the program being
• System Bus
executed.The size of the program that can be written depends on the size of this memory.
• Memory Unit
• Input/Output Port ROM is nonvolatile. It stores the program.
• Serial Communication
• Timer Unit. Random Access Memory (RAM)
• Interrupt System.
• Watchdog Random Access Memory (RAM) is a type of memory used for temporary storing data and
• Analog to Digital Converter intermediate results created and used during the operation of the microcontrollers. The content of this
• Oscillator memory is cleared once the power supply is off.
• Program RAM is volatile memory. It stores the variables of the program.
14
Dr. Mohammad Mahbubur Rahman
Serial communication is the most widely
• Central Processing Unit used approach to transfer information
• System Bus (data) between microcontroller and
• Memory Unit peripherals (sensors, communication
• Input/Output Port devices etc)
• Serial Communication The most commonly used serial
• Timer Unit. communication systems are:
• Interrupt System.
• I2C (Inter Integrated Circuit)
• Watchdog
• SPI (Serial Peripheral Interface Bus)
• Analog to Digital Converter
• UART (Universal Asynchronous
• Oscillator
Receiver/Transmitter)
• Program
15
Dr. Mohammad Mahbubur Rahman
• Central Processing Unit Timer Unit. Watchdog
• System Bus
• Memory Unit
• Input/Output Port
• Serial Communication
• Timer Unit.
• Interrupt System.
• Watchdog
• Analog to Digital Converter Timer act as miniature electronic "stopwatches“. These are commonly 8- or 16-bit
• Oscillator SFRs the contents of which is automatically incremented by each coming pulse.
• Program When timer clock comes from peripherals they are called counter.
16
Dr. Mohammad Mahbubur Rahman
• Central Processing Unit
• System Bus
• Memory Unit
• Input/Output Port
• Serial Communication
• Converts analog signal into digital
• Timer Unit.
• Interrupt System.
signal.
• Watchdog • May have 8-16 bit A/D converter.
• Analog to Digital Converter
• Oscillator
• Program
17
Dr. Mohammad Mahbubur Rahman
• Central Processing Unit I/O Pin
• System Bus
• Memory Unit
• Input/Output Port Timer
Interrupt
• Serial Communication Microprocessor
Controller
• Timer Unit. A/D
• Interrupt System. Converter
• Watchdog
• Analog to Digital Converter Instruction-1
• Oscillator Instruction-1
• Program UART ……………
……………
Why INTERRUPT? ……………
The purpose of the microcontroller is mainly to respond to changes in its surrounding. In …………...
other words, when an event takes place, the microcontroller does something. Instruction-N
If the microcontroller spent most of its time endlessly checking peripherals, it would not be
practical at all.
This is why the microcontroller has learnt a trick during its evolution. Instead of checking each pin or bit constantly, the microcontroller
delegates the‘wait issue’to a‘specialist’which will respond only when something attention worthy happens.
18
Dr. Mohammad Mahbubur Rahman
Basic microcontroller architecture (Continued)
RPM Meter
14
Dr. Mohammad MahbuburRahman
Name of Some Microcontroller Manufacturer
ATMEL(AVR microcontroller)
Microchip (PIC microcontroller)
Texas Instruments (TI)
Freescale
Philips
Motorola ARDUINO
20
Dr. Mohammad Mahbubur Rahman
Advantages of Arduino: Reduces hardware complexity
21
Dr. Mohammad Mahbubur Rahman
Advantages of Arduino: Programming Easy
• Programming in C/C+
• Lot of functions in the library.
• No need to learn internal
architecture of microcontroller.
22 Microprocessor and Interfacing Sessional,Exp-8, By- MohammedAbdul Kader,Assistant Prof., EEE, IIUC
Dr. Mohammad Mahbubur Rahman
Features of Arduino UNO
Microcontroller ATmega328
OperatingVoltage 5V
InputVoltage (recommended) 7-12V
InputVoltage (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
32 KB (ATmega328) of which 0.5 KB
Flash Memory used
by bootloader
SRAM 2 KB (ATmega328)
EEPROM 1 KB (ATmega328)
Clock Speed 16 MHz
Length 68.6 mm
Width 53.4 mm
Weight 25 g
Dr. Mohammad Mahbubur Rahman
Digital I/O Pins
▪ Most of the important pins of microcontroller are digital input-output pins.
▪ These pins are used to connect INPUT Device (i.e. Push Button, keypad, digital sensors etc) and OUTPUT
Device (i.e. LED, Display, Relay, Motor etc.) with microcontroller.
void setup()
{
pinMode(13,OUTPUT);
}
void loop()
{
digitalWrite(13,HIGH);
delay(300);
digitalWrite(13,LOW);
delay(300);
}
Note: To insert a time delay in the program use following function-
delay(time_in_ms);