8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com
-
Upload
pratik-deshpande -
Category
Documents
-
view
180 -
download
4
description
Transcript of 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com
![Page 1: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/1.jpg)
www.EmbeddedMarket.com
www.EmbeddedMarket.com
Robot Controls using 8051Presented by: Pratik Deshpande
![Page 2: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/2.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mWorkshop Objective
Understand the real world development using Microcontrollers
Explore the features of microcontroller and use them in real life applications
Use 89V51RD2 microcontroller to control a Hobby Robot
![Page 3: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/3.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mDetails of Workshop
Your Basic Preparation
Interface 8051 with various circuits
Use built-in features of 8051
Apply above said learning to control a hobby robot
This workshop is to learn the control techniques. Mechanical aspects will not be discussed.
![Page 4: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/4.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mMicrocontroller & Computer
Basic Parts of a Computer
Processor
Hard disk
RAM
Monitor
Keyboard
Mouse
Ports
![Page 5: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/5.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mMicrocontroller & Digital Circuits
Microcontroller has built in
Processor
Memory to Store Program
Memory to Store Data
Ports for Input & Outputs
Flexible
Multipurpose
![Page 6: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/6.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mWhy to use a Microcontroller?
Why use Microcontroller instead of PC?
Why use Microcontroller instead of Digital Circuits?
![Page 7: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/7.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mProducts using Microcontroller
![Page 8: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/8.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mEmbedded Vs IT Sector
Microcontroller is entry point to the Embedded Development
Embedded is Hardware + Software
IT is Software only
Recent Global Economic downturn has less effect on Embedded Related companies
![Page 9: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/9.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mLet’s get prepared
You should know:
Internals of microcontrollers
Writing programs to create application
Programming languages
Bits , Bytes and Address
Binary, Decimal & Hexadecimal Numbers
Details of Interface (Input / Output circuits)
Built-in Features of Microcontroller
![Page 10: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/10.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mLet’s get prepared
8051 Microcontroller
AT89S51
AT89S52
P89V51RD2
Differs in
Program memory Size
Data Memory Size
Certain built-in features
![Page 11: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/11.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mLet’s get prepared
Internals of 89V51RD2
8 Bit processor
64 KB Flash (Memory to store program)
1 KB RAM (Memory to store data)
Special Function Registers (SFR – Used
for Configuration of Built-in Features)
32 I/O Lines
![Page 12: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/12.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mLet’s get prepared
Writing programs to create application Assign value to a Port
Read value from a Port
Process input values
Configure, Enable & disable
Built-in Features
![Page 13: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/13.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mLet’s get prepared
Programming languages For Microcontrollers Human readable programming language
• Assembly Language
• C Language
• Basic Language
Machine Code
• Hex File
Start:
JB P2.0,Start
JB P1.0,MakeItON
SETB P1.0
:1000000020A0FD209004D2908002C290
30A0FD80FC
:01001000EF00
:00000001FF
Assembler Software
![Page 14: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/14.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mLet’s get prepared
Copy Hex File to Microcontroller
HEX
File
Programmer
Device
![Page 15: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/15.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mLet’s get prepared
Bits , Bytes and Address
1 0 1 0 1 0 1 0
0th Bit7th Bit
MSB LSB
1 Byte
Value
Binary = 10101010b
Decimal = 170d
Hexadecimal = AAh
![Page 16: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/16.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mLet’s get prepared
Bits , Bytes and Address
22d
22h
10111001b
25d
122d
220d
2Ah
02d
128 Byte RAM
00h
01h
02h
03h
04h
05h
06h
07h
![Page 17: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/17.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mLet’s get prepared
Details of Interface (Input / Output circuits)
LED Interfacing
Seven Segment Interfacing
Reading Input from Switch
Display text to LCD
Drive DC Motor using L293D
Drive Stepper Motor using ULN2803
Driver Relay using ULN2803
Send text to PC using RS232 Serial Communication
Transmit Infrared
Receive Infrared Signal
![Page 18: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/18.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mLet’s get prepared
Built-in Features of Microcontroller
Timer
Counter
Serial Communication
Interrupts
![Page 19: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/19.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mLet’s get prepared
Flash memory & Data memory
Program is written in Assembly Language
“Assembler software” converts it to HEX
file
Hex File is downloaded to Microcontroller
via “Programming Device”
Hex File is Stored in Microcontroller’s
“Flash memory”
Variables used by this program are stored
in Microcontroller’s Data memory (RAM)
![Page 20: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/20.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mTime to See a Demo
Running LEDs
Seven Segment Display showing Numbers 0 to 9
![Page 21: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/21.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mAre you prepared now?
By now you know
Difference between microcontroller, PC and digital
circuit
Internals of microcontrollers
Writing programs to create application
Programming languages
Bits , Bytes and Address
Binary, Decimal & Hexadecimal Numbers
Details of Interface (Input / Output circuits)
Built-in Features of Microcontroller
You have seen one demo
![Page 22: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/22.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
m?
Are you prepared to learn “How to write a program in Assembly Language?”
![Page 23: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/23.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mAssembly Language
We will learn (Limited Scope to fit available time)
Assigning Byte values
Assigning Bit values
Logical Operations on Bytes
Logical Operations on Bits
Rotate Values
Increment & Decrement Values
Direct Jumps
Conditional Jumps For Bytes
Calls
Conditional Jumps For Bits
![Page 24: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/24.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mAssembly Language
Assigning & Copy Byte values
MOV R0, #55h
MOV A, R0
MOV A, #55h
MOV 90h, A
MOV 90h, #33h
![Page 25: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/25.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mAssembly Language
Assigning Bit values
SETB 00h
CLR 00h
CPL 00h
Copy Bit values
MOV C, 00h
MOV 00h, C
![Page 26: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/26.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mAssembly Language
Logical operations on Byte
ANL A, R0
ANL A, 90h
ANL A, #55h
ANL 90h, A
ANL 90h, #55h
Same format applies for
ORL
XRL
![Page 27: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/27.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mAssembly Language
Logical Operations on Bits
ANL C, 00h
ORL C, 00h
![Page 28: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/28.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mAssembly Language
Rotate Values
RL A
RR A
1 0 1 0 1 1 0 0
1 0 1 0 1 1 0 0
![Page 29: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/29.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mAssembly Language
Increment & Decrement values
INC A
INC R0
INC 00h
DEC A
DEC R0
DEC 00h
![Page 30: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/30.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mAssembly Language
Following types of commands will be covered during further demos
Direct Jumps
Conditional Jumps For Bytes
Calls
Conditional Jumps For Bits
![Page 31: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/31.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mWhy 89V51RD2?
Reasons for selecting 89V51RD2
8051 compatible
No expensive programmer device required
Big Flash memory size to store large
program hex
Easily available
![Page 32: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/32.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mFree Gift & Purchase
Register yourself to www.EmbeddedMarket.com
Facebook.com/EmbeddedMarket
![Page 33: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/33.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mPCB Design & Manufacturing
Email your schematics and get the price estimate for PCB Design & manufacturing
Payment by DD
Delivery by courier
Delivery time 6-10 days
Single & Double Side Designs
Email ID: [email protected]
![Page 34: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/34.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mGet, Set, Go…
Let’s begin the real learning
Its time to write your First program
To Glow One LED
• CLR P1.0
To Glow alternate 4 LEDs ON and 4 LEDs OFF
• MOV P1, #55h
Refer next slide for LED circuit.
How to write this code?
Where to write this code?
How to convert it to HEX?
![Page 35: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/35.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mGet, Set, Go…
LED Circuit on 89V51RD2 Starter Kit
![Page 36: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/36.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
m8051IDE & FlashMagic
1
2
3
4
5
89V51RD2
COM1
2400
Check this
Select Hex File
Start After
Hardware
Setup is ready
![Page 37: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/37.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
m89V51RD2 Starter Kit
1
23
4 56
8
9
10
11
12
![Page 38: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/38.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
m89V51RD2 Starter Kit
Hardware Setup to Program
Connect Serial
Cable
9-12V DC
![Page 39: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/39.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
m89V51RD2 Internals
64KB Flash memory
1KB Data RAM
Special Function Registers
4 Ports
![Page 40: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/40.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
m89V51RD2 Internals
Internal Memory Organization Configuration
Registers,
Port Registers,
Maths registers
Memory to
Store values of
variables.
e.g. Count is 12
Memory from 00h to 07h is
also termed as R0 to R7
![Page 41: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/41.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
m89V51RD2 Internals
List of Special Function Registers (SFR)
Math – A, B
Interrupt – IE
Timer Control – TMOD, TCON
Timer / Counter – TH0, TL0, TH1, TL1
Serial Communication – SCON, SBUF
PORT – P0, P1, P2, P3
![Page 42: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/42.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
m89V51RD2 Pin details
P1
P3
P0
P2
+5V
GND
Crystal
![Page 43: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/43.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mGenerate Delay using Timer
1
Crystal
11.0592
MHz
![Page 44: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/44.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mGenerate Delay using Timer
Crystal Frequency is 11.0592 MHz
1 Machine cycle = Crystal frequency/12
i.e. 12 clocks makes one machine cycle
Machine cycle is time required to
• Fetch instruction from Flash Memory
• +
• Execute the instruction
Every microcontroller has different Machine cycle time
![Page 45: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/45.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mGenerate Delay using Timer
How much time is require to fill this glass?
Depends on Water Speed
& Glass size
![Page 46: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/46.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mGenerate Delay using Timer
89V51RD2 has 3 Timers built-in
They are Timer0, Timer1, Timer2
Let’s use Timer0 to Generate a delay of approximate 1 second
Timer0 is built-in feature of 89V51RD2
SFRs related to Timer0 are:
TH0, TL0 (Call it as T0)
TMOD
TCON
![Page 47: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/47.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mGenerate Delay using Timer
Special Function register TH0 and TL0 is like empty glass
Combined size of TH0 and TL0 is 16 Bits
i.e. T0 is of 16 bit size
Now you know the size of empty Glass
Next Task is to calculate the Time required to fill these 16bits.
![Page 48: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/48.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mGenerate Delay using Timer
1 Machine cycle Frequency
=11.0592MHz /12
= 0.9216 MHz
T=1/ F
T (Time required for 1 machine cycle)
=1/0.9216
=1.0850694
=1.085 Micro Seconds (Round Off)
![Page 49: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/49.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mGenerate Delay using Timer
In other words we can say that with 11.0592 MHZ Crystal Connected, Timer’s value will increment every 1.085 micro seconds.
T0 is of 16 bit size, thus it can store 65536 drops of water.
T0 will take
65536 x 1.085= 71106.56 Micro Sec
Or 71.10 MiliSec to overflow
![Page 50: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/50.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mGenerate Delay using Timer
If we want to count 1 second then we have to overflow timer approximately 14 times.
Because 1 sec = 1000 mili sec
1000 / 71.1 =14.06 = 14 times approx
![Page 51: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/51.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mGenerate Delay using Timer
Now let’s configure the SFRs
TMOD
Gate C/T M1 M0 Gate C/T M1 M0
7 6 5 4 3 2 1 0
Timer 1 Timer 0
![Page 52: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/52.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mGenerate Delay using Timer
TMOD register is divided into 2 identical parts.
Bit M0 and M1 are used to set Mode of timer
Bit C/T is used to specify if you want a timer or counter
Gate Bit will allow you to use timer as stopwatch, i.e. timer will run only if externally a switch is pressed.
Gate C/T M1 M0 Gate C/T M1 M0
7 6 5 4 3 2 1 0
Timer 1 Timer 0
![Page 53: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/53.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mGenerate Delay using Timer
What will be value of TMOD to generate 1 Second delay?
Gate = 0 (We don’t want a stop watch)
C/T = 0 (We want timer, not counter)
M1=0 (*)
M0=1 (*)
• * M1=0 and M0=1 configures the Timer1 as 16bit timer.
• Other settings are 13 bit timer, 8 Bit timer, Split Timer. The 16 bit timer mode is most suitable for our application.
![Page 54: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/54.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mGenerate Delay using Timer
Now we have configured the Timer0 in 16bit timer mode
We know that Timer0 must overflow 14 times to generate 1 second delay
But how to Start the Timer?
![Page 55: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/55.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mGenerate Delay using Timer
Use SFR named TCON to start timer
TR0 is used to start and stop the Timer0
Let’s see our partial code now
TF1 TR1 TF0 TR0 IE1 IT1 IE0 IT0
7 6 5 4 3 2 1 0
Used for Timer
Control
![Page 56: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/56.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mGenerate Delay using Timer
Partial Code to generate 1 Second delay
MOV TMOD,#00000001b
SETB TR0
Now how to monitor the 14 times overflow?
![Page 57: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/57.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mGenerate Delay using Timer
TF0 is set to 1 automatically as T0 Overflows after 71.1 mili sec
Thus we should count 14 such overflows by monitoring TF0.
See full code on the next page
TF1 TR1 TF0 TR0 IE1 IT1 IE0 IT0
7 6 5 4 3 2 1 0
Used for Timer
Control
![Page 58: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/58.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mGenerate Delay using Timer
Delay:
MOV R0,#14d
MOV TMOD,#00000001b
Tstart:
SETB TR0
Loop:
JNB TF0,Loop
CLR TF0
CLR TR0
DJNZ R0,Tstart
RET
Configure TMOD
Start Timer0
Wait for one Overflow
Clear Overflow
Stop Timer
Do it for 14 Times
![Page 59: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/59.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mGenerate Delay using Timer
SETB P1.0
Start:
LCALL Delay
CPL P1.0
SJMP StartDelay:
MOV R0,#14d
MOV TMOD,#00000001b
Tstart:
SETB TR0
Loop:
JNB TF0,Loop
CLR TF0
CLR TR0
DJNZ R0,Tstart
RET
![Page 60: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/60.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mRead Switch Input
![Page 61: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/61.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mRead Switch Input
MOV P2,#00h
Start:
JB P1.0,Start
CPL P2.0
Wait:
JNB P1.0,Wait
Sjmp Start
![Page 62: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/62.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mDC Motor Control
-
+-
+
Try connecting DC
Motor here
Let’s now control it using 89V51RD2 Microcontroller
H
H
OFF
H
L
CLK
L
H
ANTI
CLK
L
L
OFF
![Page 63: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/63.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mDC Motor Control
L293D DC Motor Driver Circuit
![Page 64: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/64.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mDC Motor Control
Refer source Code
![Page 65: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/65.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mSeven Segment Display
![Page 66: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/66.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mSeven Segment Display
8
9
V
5
1
R
D
2
Board mapping on
the next screen.
Refer source code
![Page 67: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/67.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mSeven Segment Display
![Page 68: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/68.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mStepper Motor Driver
Demonstrated using MITSUMI Make Stepper Motor M35SP-8
Step Angle 7.5o
Thus requires 360/7.5 = 48 Steps to complete one full rotation.
Stepper motors are used for their accuracy.
Stepper motors have no Speed or RPM parameter
Most common use is in CNC machines
![Page 69: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/69.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mStepper Motor Driver
A
B
A1
B1
+V
A B A1 B1
![Page 70: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/70.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mStepper Motor Driver
ON
ON
OFF
OFF
A
B
A1
B1
+V
A B A1 B1
1 1 0 0
![Page 71: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/71.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mStepper Motor Driver
OFF
ON
ON
OFF
A
B
A1
B1
+V
A B A1 B1
0 1 1 0
![Page 72: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/72.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mStepper Motor Driver
OFF
OFF
ON
ON
A
B
A1
B1
+V
A B A1 B1
0 0 1 1
![Page 73: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/73.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mStepper Motor Driver
ON
OFF
OFF
ON
A
B
A1
B1
+V
A B A1 B1
1 0 0 1
![Page 74: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/74.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mStepper Motor Driver
VCC
![Page 75: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/75.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mStepper Motor Driver
Refer Source code
![Page 76: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/76.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mInterrupts
![Page 77: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/77.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mInterrupts
An interrupt is some event which interrupts normal program execution
Normal Program Running
|
Interrupt Received
|
Normal Program Halted
|
Sub-Routine Executed as expected by the Interrupt
|
Normal Program Continues
![Page 78: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/78.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mInterrupts
This subroutine, called an interrupt handler, is only executed when a certain event (interrupt) occurs.
Types of interrupts
Timer 0 Overflow.
Timer 1 Overflow.
Timer 2 Overflow
Reception/Transmission of Serial Character.
External Event 0.
External Event 1.
![Page 79: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/79.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mExternal Interrupt
This subroutine must be written at specific flash memory address.
External 0 at Program memory address 0003h
External 1 at Program memory address 0013h
Timer 0 at Program memory address 000Bh
Timer 1 at Program memory address 001Bh
Serial Tx/Rx at Program memory address 0023h
![Page 80: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/80.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mExternal Interrupt
How to Enable Interrupt
EA: All interrupt enable
ES: Enable Serial Interrupt
ET1: Enable Timer 1 Interrupt
EX1: Enable External 1 Interrupt
ET0: Enable Timer 0 Interrupt
EX0: Enable External 0 Interrupt
EA - - ES ET1 EX1 ET0 EX0
7 6 5 4 3 2 1 0
IE
![Page 81: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/81.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mExternal Interrupt
Refer Source Code
P3.2
![Page 82: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/82.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mCounter
P3.4
TF1 TR1 TF0 TR0 IE1 IT1 IE0 IT0
7 6 5 4 3 2 1 0
Used for Timer
Control
TCON
Gate C/T M1 M0 Gate C/T M1 M0
7 6 5 4 3 2 1 0
Timer 1 Timer 0
MOV TMOD,#00000101b
SETB TR0
TMOD
![Page 83: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/83.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mCounter
start:
MOV TMOD,#00000101b
SETB TR0
Loop:
MOV P2,TL0
SJMP Loop
![Page 84: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/84.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mRelay Interfacing
N/C
C
N/O
?
+V
Use a Switch to
ON & Off Relay,
Observe the
“Tick” sound
generated when
Relay’s magnet
is energized
![Page 85: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/85.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mRelay Interfacing
N/C
C
N/O
?
+V
230V PhN
![Page 86: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/86.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mLCD Interfacing
LCD Circuit
![Page 87: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/87.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mLCD Interfacing
![Page 88: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/88.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mTSOP1738 RC5 Remote
38KHZ Industrial Grade IR receiver
![Page 89: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/89.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mTSOP1738 RC5 Remote
![Page 90: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/90.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mTSOP1738 RC5 Remote
Refer Source Code
![Page 91: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/91.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mRS232
Use RS232 to communicate between a PC and embedded product
Data logger is common example of it
![Page 92: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/92.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mRS232
Rx & Tx
Pins
![Page 93: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/93.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mRS232
Steps to Communicate
Both devices (PC & embedded product)
must decide on common speed of
communication,
This speed is called as baud rate
We will use 2400 baud rate
i.e. 2400 bits per second
![Page 94: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/94.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mRS232
SFR’s required for Serial Comunication
SCON
PCON
SBUF
TMOD
TCON
TL1
TH1
Baud rate settings
![Page 95: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/95.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mRS232
SCON register is used to specify RS232 communication settings:
SM0SM1SM2RENTB8 RB8 TI RI
7 6 5 4 3 2 1 0
Mode of
RS232I want to
receive data
over RS232
Indicates
that Data is
transmitted
Indicates
that Data is
received
![Page 96: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/96.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mRS232
Mode of serial communicationSM0 SM1 Serial
ModeExplanation Baud Rate
0 0 0 8-bit Shift Register
Oscillator / 12
0 1 1 8-bit UART Set by Timer 1
1 0 2 9-bit UART Oscillator / 32
1 1 3 9-bit UART Set by Timer 1
![Page 97: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/97.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mRS232
Baud rate = 2400.
Mode type = Mode 1 of serial communication.
In this mode we can send and receive 8 bit data.
Baud rate to send this data can be set using Timer 1.
![Page 98: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/98.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mRS232
Timer 1 is used in 8-bit auto reload mode to generate required BAUD rate.
We can not use Timer 0. There no such internal provision to do so
![Page 99: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/99.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mRS232
Lets understand Timer 1 Configurations:
TMOD = 00100000b (8-bit auto reload mode)
In 8 bit auto-reload mode, Timer 1 acts as 8 bit and not 16 bits.
8 bits of TL1 are used to increment timer value.
8 bits of TH1 are used to tell TL1 to start incrementing again from this value as it overflows. This is called as auto-reload.
![Page 100: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/100.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mRS232
This re-load value for TH1 will be calculated using this formula:
TH1 = 256 - ((Crystal / 384) / Baud)
TH1 = 256 - ((11059000 / 384) / 2400 )TH1 = 256 - ((28,799) /2400)TH1 = 256 – 11.99 = 244.00042=
=244d
![Page 101: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/101.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mRS232
TMOD = 00100000b (8-bit auto reload mode)
TH1= 244d (as per formula)
Remember to make 7th bit of PCON register to 0.
If it is set to 1 then speed will be doubled.
This bit is also called as SMOD.
![Page 102: 8051 Interfacings Presentation from basics to hobby robot by embeddedmarket.com](https://reader033.fdocuments.us/reader033/viewer/2022051012/5437a592219acdf4648b4ae6/html5/thumbnails/102.jpg)
ww
w.D
ecc
an
Ro
bo
ts.c
om
Microcontroller Kits Available at www.DeccanRobots.com
www.EmbeddedMarket.com
Microcontroller, Arduino & Embedded Kits available at EmbeddedMarket.com
ww
w.E
mb
ed
de
dM
ark
et.
co
mRS232
Refer Source Code