Micro Controller
Micro Controller
Microcontrollers
Please note that many diagrams used in this presentation have been taken from different sources. I am very thankful to the resource
providers as these items have rendered clarity to discussions.
What is a Microcontroller?
Very-large-scale integration
(VLSI) is the process of creating
an integrated circuit (IC) by A transistor is a semiconductor
combining thousands of device used to amplify or switch
transistors into a single chip. electrical signals and power. It is one
VLSI began in the 1970s when of the basic building blocks of
complex semiconductor and modern electronics. It is composed
communication technologies of semiconductor material, usually
were being developed. The with at least three terminals for
microprocessor is also a VLSI connection to an electronic circuit.
device.
What is a Microcontroller?
Basic Components of a Microcontroller
● CPU: It can be thought of as the brain of the device. It processes and responds to various instructions
that direct the microcontroller's function. This involves performing basic arithmetic, logic and I/O
operations.
● RAM: (Random Access Memory) It can read and write data. It is volatile in the sense that it cannot
retain data in the absence of power; i.e., data is lost after the removal of power.
● Flash: It is a long-life and non-volatile storage chip that is widely used in embedded systems. It can
keep stored data and information even when the power is off. It can be electrically erased and
reprogrammed.
Flash EEPROM
Type NAND-type memory NOR type memory
Need used when large amounts are needed used when only small amounts are
needed
Basic Components of a Microcontroller
● Oscillator: Oscillators are responsible for supplying the clock signals in microcontrollers. All the
instructions executed by microcontrollers are in synchronization with clock signals. The timing for different
operations in a microcontroller is assigned with the help of oscillators.
● I/O Pins: These pins allow exchange of data and signals between external devices and a microcontroller.
● Serial Ports: Serial communication enables a microcontroller to communicate with other devices using the
serial RS232 communication protocol.
● ADC: An analog-to-digital converter (ADC) is used to convert an analog signal such as voltage to a digital
form so that it can be read and processed by a microcontroller.
● DAC: A digital to analogue converter (DAC) converts a digital signal from the computer into an electrical
voltage which can be used to drive electrical equipment, for example, a motor.
● 8051 microcontrollers have 4
I/O ports each of 8-bit, which
can be configured as input or
output.
GND (Ground):
It is considered as the common
reference point to measure
voltage against any point of the
circuit and is considered to have
zero voltage.
Basic Assignment!!
QFP
Quad Flat Package
32 pins
IC Packaging
● A ball grid array is a type of surface-
mount packaging used for integrated
circuits.
BGA
Ball Grid Array
100 pins Basic Assignment!!
Harvard Memory Architecture MCU Princeton Memory Architecture MCU (Von Neumann)
● Separate storage and signal pathways for instructions ● Program instructions and data share the same memory and
and data pathways
● An instruction is executed in a single cycle. ● Two clock cycles are required to execute single instruction.
● Increased complexity and development cost ● Issues of Bottleneck (The shared bus between the program
memory and data memory leads to the bottleneck, the limited
throughput (data transfer rate) between the CPU and memory
compared to the amount of memory.)
Classifications of Microcontrollers
Based on Instruction Set
RISC CISC
It requires multiple register sets to store the instruction. It requires a single register set to store the instruction.
RISC has simple decoding of instruction. CISC has complex decoding of instruction.
It uses a limited number of instruction that requires less time It uses a large number of instruction that requires more time
to execute the instructions. to execute the instructions.
RISC architecture can be used with high-end applications like CISC architecture can be used with low-end applications like
telecommunication, image processing, video processing, etc. home automation, security system, etc.
Program written needs to take more space in memory. Program written tends to take less space in memory.
Classifications of Microcontrollers
RISC
Clock Speed
Arduino UNO
ATMega328P
Clock Speed 16 MHz
5 V Input Voltage
Few Common Microcontrollers
The ESP8266 is a microcontroller with
ESP8266
Clock Speed 80 MHz
3.3 V Input Voltage
Few Common Microcontrollers
The ARM Cortex-M is a group of
● Harvard architecture 32-bit
RISC ARM processor cores
ARM Cortex M3
Clock Speed 72MHZ
3.3V Input Voltage
Microcontroller vs Microprocessor
Application Specific General Computational Purpose
Limited Clock Speed (Less-paced High Clock Speed (Fast-paced
Computation) e.g.: Arduino. 16MHz computation) e.g.: Apple M1 3.2GHz
(0.016GHz)
Requires external components to function
Self-sufficient
High Intake of Energy
Low Intake of Energy
High Cost
Low Cost
What about Raspberry Pi??
Raspberry Pi
Microcontroller/
Microcontroller board Microprocessor based mini computer
Microprocessor
One can power Arduino from the USB port of a It needs more more current than Arduino. So, one
Power requirement
computer. needs a power adapter for Raspberry Pi.
● Two extra wires are needed in addition to the data lines. They are
called RTS (Request to Send) and CTS (Clear to Send). These
wires are cross-coupled between the two devices, so RTS on one
UART device is connected to CTS on the remote device and vice versa.
(Universal Asynchronous Receiver/ Transmitter)
● UARTs transmit data asynchronously, which means there is no
clock signal to synchronize the output of bits from the
transmitting UART to the sampling of bits by the receiving
UART.
How UART works?
START BIT
● The UART data transmission line is normally held at a high voltage level when it’s not transmitting data.
● To start the transfer of data, the transmitting UART pulls the transmission line from high to low for one clock
cycle.
● When the receiving UART detects the high to low voltage transition, it begins reading the bits in the data frame at
the frequency of the baud rate.
DATA FRAME
● The data frame contains the actual data being transferred.
● It can be 5 bits up to 8 bits long if a parity bit is used.
● If no parity bit is used, the data frame can be 9 bits long.
● In most cases, the data is sent with the least significant bit first.
How UART works?
Packet
PARITY
● Parity describes the evenness or oddness of a number.
● The parity bit is a way for the receiving UART to tell if any data has changed during transmission.
● Bits can be changed by electromagnetic radiation, mismatched baud rates, or long distance data transfers.
● After the receiving UART reads the data frame, it counts the number of bits with a value of 1 and checks if the
● If the parity bit is a 0 (even parity), the 1 bits in the data frame should total to an even number. If the parity bit is a 1
(odd parity), the 1 bits in the data frame should total to an odd number.
● When the parity bit matches the data, the UART knows that the transmission was free of errors. But if the parity
bit is a 0, and the total is odd; or the parity bit is a 1, and the total is even, the UART knows that bits in the data
Note:
UARTs transmit data asynchronously, which means there is no clock signal to synchronize the output of bits from the
transmitting UART to the sampling of bits by the receiving UART. Instead of a clock signal, the transmitting UART adds
start and stop bits to the data packet being transferred. These bits define the beginning and end of the data packet so the
Note:
When the receiving UART detects a start bit, it starts to read the incoming bits at a specific frequency known as the baud rate.
Baud rate is a measure of the speed of data transfer, expressed in bits per second (bps). Both UARTs must operate at about
the same baud rate. The baud rate between the transmitting and receiving UARTs can only differ by about 10% before the
Both UARTs must also must be configured to transmit and receive the same data packet structure.
How UART works?
Advantages and Disadvantages of UART
No communication protocol is perfect, but UARTs are pretty good at what they do. Here are some pros and cons to help you
ADVANTAGES
● Only uses two wires
● The structure of the data packet can be changed as long as both sides are set up for it
DISADVANTAGES
● The size of the data frame is limited to a maximum of 9 bits
● The baud rates of each UART must be within 10% of each other
NodeMCU
ESP8266
Pinout
CP2101
USB* to TTL** converter Flash Button
NodeMCU ESP8266 Parts
Voltage Regulator
Reset Button
ESP8266 Chip
■ GPIO 06 : SDCLK
■ GPIO 07 : SDD0
■ GPIO 08 : SDD1
■ GPIO 09 : SDD2 (can be used)
■ GPIO 10 : SDD3 (can be used)
NodeMCU ESP8266 Pinout
● 4 GND Pins
NodeMCU ESP8266 Pinout
SPI Protocol
MOSI: Master Out Slave In
CS: Chip Select
MISO: Master In Slave Out
CLK : Clock
I2C Protocol
SDA: Serial Data
SCL: Serial Clock
UART Protocol
TX: Transmitter
RX: Receiver
CTS: Clear to Send
RTS : Ready to Send
1. RXD0, TXD0
2. TXD1
NodeMCU ESP8266 Pinout
Analog Pins
10 bit resolution
NodeMCU ESP8266 Pinout
● Add #include <ESP8266WiFi.h> at the top ● Can act both as a Wifi Station and Wifi