[go: up one dir, main page]

100% found this document useful (1 vote)
167 views18 pages

Microprocessors & Interfacing Guide

The document discusses microprocessors and interfacing. It includes questions about features of microcontrollers like the 8051 and PIC and their applications. It also discusses serial communication protocols and embedded system development tools. The last question provides a table of microcontroller manufacturers and their derivatives with costs.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
167 views18 pages

Microprocessors & Interfacing Guide

The document discusses microprocessors and interfacing. It includes questions about features of microcontrollers like the 8051 and PIC and their applications. It also discusses serial communication protocols and embedded system development tools. The last question provides a table of microcontroller manufacturers and their derivatives with costs.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

MICROPROCESSORS AND

INTERFACING
COURSE CODE: EEX4436
ASSIGNMENT NO: 01

NAME : S. R. P. MADUHANSA
REG NO : 416960756
DATE OF SUBMISSION : 23. 04. 2021
CENTRE : KANDY
Q1) a.

• The low time require for performing an operation.


• The processor chips are very small and flexible.
• The micro-controller easy to interface additional RAM, Rom and I/O ports.
Q1) b.
TYPE OF MICRO- FEATURES APPLICATIONS
CONTROLLER
8051 RAM: 128 bytes TV tuners
ROM:4 KB Sewing machines
BUS: Address BUS !6 bits Remote controllers
Data BUS 8 bits Computers
TIMERS: Two (16bits)
INTERRUPT: five-
o Time 0- Overflow
o Time 1- Overflow
o External hardware interrupt
o External hardware interrupt
o Serial communication interrupt

PIC PIC microcontroller based on RISC Video games,


architecture. Audio accessories
Consist two memories:
o Program memory
o Data memory
EEPROM: 256 bytes of memory. It is a
permanent memory like ROM, but its
contents can be erased and changed
during the operation of the
microcontroller.
I/O ports: Five ports (PIC16 series)
Timers: 3 timers, 0 & 2 – 32 bits
1 – 64 bits
A/D convertors: 8 channels (10bit
A/D convertor)
Oscillators: Crystal or RC
Arduino (ATmega328/p) I/O ports: 14 Digital ports (6 can be use Robotics
PMW) DC motor control
6 analog inputs. Motion control rig
USB, POWER JACKS, ICSP header, Ardupilot
RESET button
SRAM: 2KB
EEPROM: 1KB
Clock Speed: 16MHz
PIC

Arduino (ATmega328/p)
Q1) c.
In mechanical engineering field,
Today Micro-controller systems are widely used in automotive electronic systems. because they are very
safe and accurate than humans. in history every machine, vehicles are controlled in fully mechanically, and
its less safe and less accuracy. because of that that time all the machines and vehicles are very primary. but
now a days mechanical engineering field is used modern technology and they embedded systems for their
all the machines and vehicles.
because of micro-controller-based systems, we can take lot of advantages,
mainly improve accuracy, efficiency and cost for high scale productions.
in automotive field,
they give us safety more than humans can do. it also gives vehicle safety. and also embedded
. automotive systems make our lives are easier.
Q1) d.
In digital communication, there are two types of data transfer,

• serial communication
• parallel communication

In serial communication;

➢ I2C Protocol

I2c (Inter-integrated circuit) is a two-wire bidirectional protocol used for an exchange of data between
different devices on the same bus. I2c uses 7 bit or 10-bit address allowing to connect up to 1024 devices.
But it requires clock signal for generating start and stop conditions. The advantage is it provides data
transfer at 400 kbps. It is suitable for onboard communication.

➢ SPI Protocol

SPI (Serial peripheral interface) protocol send and receive data in a continuous stream without any
interruption. This protocol is recommended for highspeed data communication is required. The maximum
speed it can provide is 10 Mbps.

Unlike i2c, SPI has 4 wires. They are MOSI (Master out slave in), MISO (Master in slave out), Clock and
Slave select signal. Theoretically, we can connect unlimited number of slaves and practically it depends on
the load capacitance of the bus.

➢ CAN Protocol

This protocol is dedicated to vehicle systems or automobiles. It is a message-oriented protocol used for
multiplex electric wiring to economize the copper. It is a multi-master multi serial bus used in applications
such as automatic start/stop of vehicles, collision avoidance systems etc.

➢ USB

USB interface is the best alternative to serial or parallel ports. The data transfer associated with USB ports
are quite faster than the serial and parallel interface. USB supports speeds from 1.5 Mbps (USB 1.0) to 4.8
Gbps (USB 3.0). Today most of the embedded devices use USB OTG (On the Go programming) technique
for dumping the hex file to the microcontroller.
Q2) a.

There are two types of embedded system development tools,

I. Embedded software development tools.


II. Embedded hardware development tools.

Embedded software development tools: -

All kinds of Embedded Systems need software’s to run them for performing specific functions. The
microcontroller contains the software for handling all the operations.

➢ Editors
➢ Assemblers
➢ Compilers
➢ Debuggers
➢ Simulators
➢ Emulators

-Editors:

The very first tool in the development of software for an embedded system is a text editor. we need to write
source code. In Embedded System Development Tools, Editor is used to writing code for embedded
systems applications. It is the editor where we write that code. Also, we can use various kinds of
programming languages to implement programs by using editors.

EX: Microsoft Notepad

-Compiler/ Assembler:

Source code will be turned into a .HEX file by using a compiler/ assembler. Compiler/Assembler is the
second tool in your embedded system software development.

Once you are done with your source code, you need to translate that code into the instructions on the basis
of which, the microcontroller will operate. One can say that the purpose of the compiler is the conversion
of a high-level programming language into a low-level programming language

EX: ASM51

-Debugger:

The name debugger speaks itself. This tool is used for debugging your code. The debugger is actually as a
tester and is used to test whether your code contains error or not. The debugger has a complete look at the
code and test if there are any errors or bugs.

-Simulators:

It is also a software segment that make virtual 8051 microprocessor act as physically and show us how our
ALP is play.

-Terminal emulator:

Use to communicate with 8051 board. This provides the ability to transmit the. HEX code to the hardware.

EX: Microsoft Hyper-Terminal

Embedded Hardware development tools: -

AES51 board, Normally the all-hardware components such as, 8051 micro-processor,4-I/O ports, Serial
port, SFRs, Interrupts and Timers/counters that necessary for microcontroller is indicated in the boar of
AES51. It is providing facility for act to 8051.
External tools, the all peripherals that requiring for do our new design. Such as Sensors, Actuators,
Multiplexers, DE-multiplexers, decoders, Motors.

Q2) b.

MANUFACTURER DERIVATIVES WITH THERE COST


PROPRIETOR NAME

AT 89C 1051 $1.75

Almel AT 89C 51 $2.25

C 8051 F000/010 $2.50

Cygnal intergrated product C8051 F220 $2.75

80 C 310 $4.78

Dallas Semiconductors 80 C 320 $6.00

80 C31 $5.20

ISSI 80 C51 $5.40

MSM 80 C 48/49/50 $4.80-$5.38

Okidata MSM 80 C 15 45/830 1545 $5.25-$5.78

TE 502 $3.00

Triscend Corporation TE 505 $3.25

8XC51/80C $4.75-$5.35

Philips 8XC32/51/52/54 $4.75-$6.25

C501 $4.75

Infinenon C504 $5.25

SMC C504 $5.60


Q2) c.

8051 Arduino PIC (16F505) FPGA ARM


(AT89S51) (ATMEGA851 (CORTEX 32bit
5) M3)
I/O pins 32 programmable 35 programmable 12 programmable 5 programmable 136
I/O pins I/O pins I/O Pins I/O pins programmable I/O
pins

Memory 4K bytes of Flash 8K bytes of Flash 1.5 K bytes of RAM Up to 1 Mbyte of


Flash Flash memory

128 x 8-bit 512 Bytes Internal 72 bytes Internal Up to 128 + 4


Internal RAM SRAM RAM Kbytes of SRAM

Full Duplex Programmable In-Circuit Serial Up to 15


Serial UART Serial Serial USART, Programming communication
Communication Channel Master/Slave SPI interfaces
Serial Interface

10,000 100,000 1,000,000 100,000


Availability Write/Erase Write/Erase Write/Erase Write/Erase
Cycles Cycles cycles cycles

Two 16-bit One 16-bit 8-Bit Real-Time Up to twelve 16-


Timer/Counters Timer/Counter Clock/Count er bit and two 32-bit
(TMR0) with 8- timers, up to 120
Bit MHz

Six Interrupt External and External and Up to 140 I/O


Sources Internal Interrupt Internal Interrupt ports with
Sources Sources interrupt
capability
Fast Low
Fast Programming programming
Programming Time Time Fast Programming
Time Time

4.0V to 5.5V 4.5V to 5.5V 2.0V to 5.5V 1.8 V to 3.6 V


Operating Range Operating Range Operating Range Operating Range Operating Range
Used in high

Applications Basic Function Used in high Used in Used for real time
for small projects. technology like refrigerator and application
robotics low budget
project Video Games

Cost (as Average Low Low


compared to Very Low
features provide

PIC16, PIC17, Spartan-Q6 ARMv4,5,6,7 and


Families 8051 variants PIC18, PIC24, series
PIC32

Microchip Apple, Nvidia,


Manufacturer NXP, Atmel, Average Qualcomm,
Silicon Labs, Samsung
Dallas, Cyprus, Electronics, and
Infineon, etc. TI etc.

Q2) d.

HIGH LEVEL LANGUAGE LOW LEVEL LANGUAGE


High-Level Languages are easy to learn and understand. Low-Level Languages are challenging to learn and
understand.
They are executed slower than lower-level languages They execute with high speed.
because they require a translator program.

They allow much more abstraction. They allow little or no abstraction.

They do not provide many facilities at the hardware level. They are very close to the hardware and help to write a
program at the hardware level.
For writing programs, hardware knowledge is not required. For writing programs, hardware knowledge is a must.

The programs are easy to modify. Modifying programs is difficult.

A single statement may execute several instructions. The statements can be directly mapped to processor
instructions.
BASIC, Perl, Pascal, COBOL, Ruby etc. are examples Machine language and Assembly language are Low-Level
of High-Level Languages. Languages.
Q3) a.
8051 There are six types of addressing modes: -

• Immediate Addressing Mode

• Register Addressing Mode

• Direct Addressing Mode

• Register Indirect Addressing Mode

• Indexed Addressing Mode

• Implied Addressing Mode

Immediate Addressing Mode: -


In this Immediate Addressing Mode, the data is provided in the instruction itself. The data is provided immediately after
the opcode.

MOVA, #0AFH;

MOVR3, #45H;

MOVDPTR, #FE00H;

In these instructions, the # symbol is used for immediate data. In the last instruction, there is DPTR. The DPTR stands
for Data Pointer. Using this, it points the external data memory location. In the first instruction, the immediate data is
AFH, but one 0 is added at the beginning. So, when the data is starting with A to F, the data should be preceded by 0.

Register Addressing Mode: -


In the register addressing mode the source or destination data should be present in a register (R0 to R7).

MOVA, R5;

MOVR2, #45H;

MOVR0, A;

Direct Addressing Mode: -


In the Direct Addressing Mode, the source or destination address is specified by using 8-bit data in the instruction. Only
the internal data memory can be used in this mode.

MOV80H, R6;

MOVR2, 45H;

MOVR0, 05H;
The first instruction will send the content of registerR6 to port P0 (Address of Port 0 is 80H). The second one
is forgetting content from 45H to R2. The third one is used to get data from Register R5 (When register bank
RB0 is selected) to register R5.

Register Indirect Addressing Mode: -


the source or destination address is given in the register. By using register indirect addressing mode, the
internal or external addresses can be accessed. The R0 and R1 are used for 8-bit addresses, and DPTR is
used for 16-bit addresses, no other registers can be used for addressing purposes.

MOV0E5H, @R0;

MOV@R1, 80H

In the instructions, the @ symbol is used for register indirect addressing. In the first instruction, it is showing
that theR0 register is used. If the content of R0 is 40H, then that instruction will take the data which is located
at location 40H of the internal RAM. In the second one, if the content of R1 is 30H, then it indicates that the
content of port P0 will be stored at location 30H in the internal RAM.

MOVXA, @R1;

MOV@DPTR, A;

In these two instructions, the X in MOVX indicates the external data memory. The external data memory can only be
accessed in register indirect mode. In the first instruction if the R0 is holding 40H, then A will get the content of external
RAM location40H. And in the second one, the content of A is overwritten in the location pointed by DPTR.

Indexed Addressing Mode: -


In the indexed addressing mode, the source memory can only be accessed from program memory only. The destination
operand is always the register A.

MOVCA, @A+PC;

MOVCA, @A+DPTR;

The C in MOVC instruction refers to code byte. For the first instruction, let us consider A holds 30H. And the PC value
is1125H. The contents of program memory location 1155H (30H + 1125H) are moved to register A.

Implied Addressing Mode: -


In the implied addressing mode, there will be a single operand. These types of instruction can work on specific registers
only. These types of instructions are also known as register specific instruction.

RLA;

SWAPA;

These are 1- byte instruction. The first one is used to rotate the A register content to the Left. The second one is used to
swap the nibbles in A.
Q3) b.

Q3) c. c)

MOV R0, #1
CJNE R0, #6 then
Acall set
Then: JNC set
MOV R1, #X
MOV A, R1
MOV B, R1
MUL AB
MOV R1, A
Acall Exit
Set : MOV R1, #X
ADD R1, #7

Q3) d.
8051 micro controller memory organization: -
This micro controller memory can be dividing in two categories.
I. Program memory (ROM)
II. Data memory (RAM)

Program memory: -
This memory used for permanent saving program (CODE) being executed. Also, this memory is a
read only memory. That mean micro-controller basic operations are doing according to this read only
memory codes. Program memory may also used to store a constant variable.

Data memory: -
RAM memory is used for temporarily storing and keeping intermediate results and variables.
Q3) e.
Memory type RAM ROM PROM EPROM EEPROM FLASH
category Read-write Read only Read only Read-mostly Read-mostly Read - mostly
Erasure Electrically, Not possible Not possible UV light Electrically Electrically
byte level
Write Electrically Masks Electrically Electrically Electrically Electrically
Mechanism
Volatility Volatile Non-Volatile Non-Volatile Non-Volatile Non-Volatile Non-Volatile

Segment Registers Segments are specific areas defined in a program for containing data, code and stack. There are
three main segments:

• Code Segment: it contains all the instructions to be executed. A 16 - bit Code Segment register or CS register
stores the starting address of the code segment.
• Data Segment: it contains data, constants and work areas. A 16 - bit Data Segment register of DS register
stores the starting address of the data segment.
• Stack Segment: it contains data and return addresses of procedures or subroutines. It is implemented as a
'stack' data structure. The Stack Segment register or SS register stores the starting address of the stack.

Q3) f.

A lookup table is a list of values that are stored in the memory of the microcontroller, which then
can be accessed using the ReadTable command. Advantage of lookup tables is that they are
memory efficient, compared to an equivalent set of alternative command statements.
Q3) g.
The main processor stops working and checks if some controller has a message for it, if it has, processes the message
and resumes operation. This is called polling. the main processor does its job, and the devices are doing their job. If
the device finishes its job or an error occurs, the device informs the main processor with an interrupt request. (The
main program is controlling the power element of the oven. The use presses a key on the front panel to cancel the
operation or change the length of cooking time. The main program is interrupted. The Interrupt Service Routine takes
over, reads the keypad and changes the cooking conditions accordingly, then finishes by passing control back to the
main program. The main program continues according to the new conditions set by the Interrupt Service Routine.)

• Polling

CPU monitors all served devices continuously, looking for a “service request flag “Whenever it sees a
request, it serves the device and then keeps polling. CPU is always “busy” with polling doing the “while any
request” loop

• Interrupts

If and when a device is ready and needs attention, it informs the CPUCPU drops whatever it was doing and
serves the device and then returns back to its original task. CPU is always “free”, when not serving any
interrupt
Q4) a.
1) Timers
The timer module, which is strictly speaking a counter module, is an important part of every microcontroller,
and most controllers provide one or more timers with 8 and/or 16-bit resolution. Timers are used for a variety
of tasks ranging from simple delays over measurement of periods to waveform generation. The most basic use
of the timer is in its function as a counter, but timers generally also allow the user to timestamp external events,
to trigger interrupts after a certain number of clock cycles, and even to generate pulse-width modulated signals
for motor control. Timers can generally raise an interrupt whenever they experience an overflow of the count
value. This can be used to implement a rudimentary periodic signal by setting the count value to a given start
value and then waiting for the overflow. some timers provide a modulus mode which automatically reloads
the start value when the timer overflows. Although the timer is generally clocked by the same source as the
microcontroller itself, this need not be the case.

2) Counters
Each timer is basically a counter which is either incremented or decremented upon every clock tick. The
direction (up- or down-counter) is either fixed or configurable. The current count value can be read through a
count register and can be set to a specific value by the user. For a timer resolution of n, the count value is
within [0, 2n − 1]. Care must be taken when the timer length exceeds the word length of the controller, e.g.,
when using a 16-bit timer on an 8-bit controller. In such a case, access to the 16-bit count value must be done
in two passes, which could lead to inconsistent values. Just think of a timer that is at value 0x00FF and will
switch to 0x0100 in the next cycle. If you read the high byte first and the low byte with the next instruction,
you will get 0x0000. If you do it the other way round, you will end up with 0x01FF, which is not any better.
To counter such problems, the ATmega16 controller for example uses a buffer register to store the high byte
of the timer. So whenever the program reads the low byte of the count register, the high byte is simultaneously
stored in the buffer and can then be read at the next cycle. Likewise, to write a new count value, the high byte
should be written first (and is stored in the buffer by the controller), and as soon as the low byte is written,
both high and low byte are written into the count register in one go.

Q4) b.
Q4) c. 1)
SOFTWARE DELAY
We got 60756µS delay as:
So the calculation can show as below,
Crystal frequency = 11.0592µHz
One machine cycle frequency = 11.0592/12 = 921.6 µHz
Time for one machine cycle = 1/921.6 = 1.085 µS
Then, total machine cycle for delay = 60756µS/1.085µS = 55996.31 ~ 55996

Software delay 100p

DELAY: MOV R2, Z


L3: MOV R1, Y
L2: MOV R0, X
L1: DJNZ R0, L1 } 2R0 [(2R0+2+1)R1-1] {[(2R0+3)R1+3]R2 -2}
DJNZ R1, L2
DJNZ R2, L3

Total cycle = [(2R0 + 3) +3]R2 + 1 = 55996


Assume R2 = 100, R1 =20
[(2R0 + 3) 20 +3]100 +1 = 55996
(2R0 + 3)20 + 3 = 55995/100
R0 = (27-3)/2 = 12

So, R0 = 12 = X
R1 = 20 = Y
R2 = 100 = Z
Therefor software delay 100p,

DELAY: MOV R2, # 100


L3: MOV R1, # 20
L2: MOV R0, # 12
L1: DJNZ R0, L1
DJNZ R1, L2
DJNZ R2, L3
Q4) c. 2)
Machine cycle = 55996
Reload rate = 65536- 55996 =9540
Reload rate = 2544 (HEX value of 9540)
TH TL

ORG 0000H
MOV TMOD < #00000001B

MAIN; MOV TH0, #025H


MOV TL0, #044H
SETB TRO
L1; TNB TF0, L1
CLR TR0
CLR TF0
END
Q5) Automated hand sanitizer machine
Hardware:

• Ultrasonic sensor/ IR sensor


• Arduino nano/ Arduino uno
• Relay module 1ch/ 2 ch
• Water pump
• Water valve
• Power source
Software:
➢ Arduino IDE
Mechanism:
Normal hand sanitizer operates in, we have to apply pressure on it and when we apply pressure on it, it
creates pressure on the liquid in the bottle and when the pressure is released, hand sanitizing liquid will be
pumped out.

Now want to apply this logic in the design of automatic hand sanitizer dispenser.

➢ Distance Sensor for Automatic Hand Sanitizer Dispenser


We can use Ultrasonic sensor or IR sensor for that purpose.
 Ultrasonic Sensor for Automatic Hand Sanitizer Dispenser

The ultrasonic sensor uses ultrasonic sound waves to detect the object. The transmitter of the sensor
transmits ultrasonic waves and the receiver of the module receives those ultrasonic waves.

1. Interfacing Ultrasonic with Arduino

The following figure shows the interface of the ultrasonic sensor with the Arduino. In this, we have
connected the trigger pin of the ultrasonic sensor to the D3 of the Arduino board and the D2 pin of
the Arduino to the echo pin of the ultrasonic sensor.

Interfacing ultrasonic with arduino


 IR Sensor for Automatic Hand Sanitizer Dispenser

This is the second option (As a distance sensor) you can use in the design of an automatic hand sanitizer
machine. This sensor uses a light source to detect the obstacle.

IR sensor

*Interfacing Relay with Arduino

The relay is an electrotechnical switch that is used to trigger high volt applications using low volt signals. To
turn on the DC water pump, we are using this 5V relay module. The interfacing diagram of the relay module
with the Arduino is as follows.

Interfacing relay with arduino

You might also like