Download as pdf or txt
Download as pdf or txt
You are on page 1of 22

Review Questions

1. Who provides the clock pulses to 8051 timers ifC/T =0?


2. Indicate the selection made in the statement "TMOD = 0x20".
3. In mode 1, the counter rolls over when it goes from to.
4. In mode 2, the counter rolls over when it goes from to
5. In the statement "TH1 = -200", find the hex value for the TH register.
6. TF0 and TF1 are part ofregister
7. In Question 6, is the register bit-addressable?
8. Show how to monitor the TF1 flag for high in 8051 C.

SUMMARY
The 8051 has two timers/counters. When used as timers they can generate time delays. When used as counters th
can serve as event counters. This chapter showed how to program the timers/counters for various modes. they
The two timers are accessed as two 8-bit registers: TL0 and THO for Timer 0, and TL1 and TH1 for Timer1 R
th
timers
use
the set timer operation modes. The lower 4 bits of TMOD are used for Timer 0
TMOD register to
upper 4 bits are used for Timer1.
andte
There are different modes that can be used for each timer. Mode 0 sets the timer as a 13-bit timer, mode 1
sets it as
a 16-bit timer, and mode 2 sets it as an 8-bit timer.
When the timer/counter is used as a timer, the 8051's crystal is used as the source of the frequency; when it is used
as a counter, however, it is a pulse outside the 8051 that increments the TH, TL registers.

PROBLEMS
SECTION 9.1: PROGRAMMING 8051 TIMERS
1. What is the difference between the operation of a timer and a counter?
2. The timers of the 8051 are -bit and are designated as. and
3. The registers of Timer 0 are accessed as and
4. The registers of Timer 1 are accessed as .
and
5. In Questions 3 and 4, are the registers bit-addressable?
6. The TMOD register is a(n) -bit register.
7. What is the function of the TMOD register?
8. True or false. TMOD is a bit-addressable register.
9. Find the TMOD value for both Timer 0 and Timer 1, mode 2, software start /
from the 8051's crystal.
stop (gate =
0), with the clock comirg
10. Find the frequency and period used by the timer if the crystal attached to the 8051 has the following values.
(a) XTAL = 11.0592 MHz (b) XTAL = 20 MHz
(c) XTAL = 24 MHz (d) XTAL = 30 MHz
is
11. What the difference in the timer lengths in modes 0, 1, and 22
12. Indicate the rollover value (in hex and decimal) of the timer for each of the following modes.
(a) mode 0 (b) mode 1 (c) mode 2
13. Indicate when the TF1 flag is raised for each of the following modes.
(a) mode 0 (b) mode 1 c) mode 2
14. In which register do we find the timer start bits and timer rollover flags?
15. True or false. Both Timer 0 and Timer 1 have their own timer start (TR).
16. Find the delay for XTAL = 22 MHz, if the program segment for timing is
MOV TMOD, #01
MOV THO, #0FFH
MOV TLO, #00
SETB TRO
17. Assuming that XTAL 16
=
MHz, indicate when the TF0 flag is raised for the following program.
MOV TMOD, #01
MOV TLO, #12H

232 THE 8051


TEMS

MICROcONTROLLER AND EMBEDDED SYSTE


MOV THO, #1CH
SETB TRO
18. For the rolowing program, and XTAL =22 MHz. after how much time will the timer 0 tlag De Set
t?
MOV TMOD, #01
MOV TLO, #00
MOV THO, #FOH
SETB TRO
19. Assuming that XTAL =
20 MHz, indicate when
the TFO flag is raised for the following program.
MOV TMOD, #01
MOV TLO, #12H
MOV THO, #1CH
SETB TRO
20. Assume that XTAL =11.0592 MHz. Find the
grammed in mode 1. TH1,TLI value to generate a time delay of 2 ms. Timer I is pro
21. Assume that XTAL 16 MHz. Find the
=

mode 1.
TH1,TL1 value to generate a time delay of 5 ms. Timer 1 is programned n

22. Assuming that XTAL 11.0592 MHz, =

program Timer 0 to generate a time delay of 2.5 ms.


23. Write a program to create a
delay of 1 ms, with XTAL 22 MHz. =

24. Assuming that XTAL 20 MHz, =

program Timer 1 to generate a time delay of 100 ms.


25. With XTAL =22 MHz, write a
program to generate the lowest possible frequency on pin PO.1.
26. Assuming that XTAL 11.0592 MHz, and we are
=

wave frequency that we can generating a square wave on pin P1.2, find the highest square
generate using mode 1.
27. Assuming that XTAL 16 MHz, and we are =

frequency that we can generate using mode 1.generating square


a wave on pin P1.2, find the lowest
square wave
28. Assuming that XTAL 16 MHz, and we are
= generating a square wave on pin P1.2, find the highest square wave
frequency that we can generate using mode 1.
29. Using Timer 1 in mode 2
generatea ,
delay of 92 us.
30. In what way is mode 2 programming different from mode 0 and mode 1?
31. What is mode 0 ? What does it do?
32. Program Timer 0 to generate a square wave of 0.5 kHz. Assume that XTAL = 20 MHz.
33. Program Timer 1 to generate a square wave of 10 kHz. Assume that XTAL = 20 MHz.
34. With XTAL 22 MHz, find the delay obtained
=
using the following program.
MOV TMOD, #10H
MOV TLO, #33H
MOV THO, #05
SETB TR1
35. Assuming that XTAL =16 MHz, show a program to generate a 0.25-second time delay. Use any timer you want.
36. Assuming that XTAL =11.0592 MHz and that we are generating a square wave on pin P1.3, find the lowest square
wave frequency that we can generate using mode2.
37. Assuming that XTAL = 11.0592 MHz and that we are generating a square wave on pin P1.3, find the highest square
wave frequency that we can generate using mode 2.
38. Assuming that XTAL = 16 MHz and that we are generating a square wave on pin Pl.3, find the lowest square wave
frequency that we can generate using mode2
39. Speciy what exactly is being done by the following program.
MOV TMOD, #10H
REPT: MOV RO,#10
CPL .4
BACK; MOV TL1,#05
MOV TH1, #5OH
SETB TR1

AGAIN: JNB TF1,AGAIN


CLR TR1
CLR TF1
DJNZ RO, BACK
SJMP REPT

40. Find the value (in hex) loaded into TH in each of the folowing.

8051 TIMER PROGRAMMING IN ASSEMBLY AND C


23
(a) MOV THO, #-12 (b) MOV THO, #-22
(c) MOV THO, #-34 (d) MOV THO, #-92
(e) MOV TH1, #-120 (f MOV TH1, #-104
MOV TH1, #-222 (h) MOV TH1, #-67
41. (g)
In Problem 40, indicate by what number the machine cycle frequency of 921.6 kHz (XTAL = 11.0592 ML.
Hz)
divided.
42. InProblem 41, find the time delay for each case from the time the timer starts to the time the TF flag is raised

SECTION 9.2: COUNTER PROGRAMMING


43. How is the TMOD register modified to make each of the timers operate as counters?
44. Which pins are used as external count inputs?
45. Which of the timers can be used as event counters?
46. For counter 1, which pin is used to input clocks?
47. Program Timer 1 to be an event counter. Use mode 1 and display the binary count on P1 and P2 continuously. Se
the initial count to 20,000.
48. Program Timer 0 to be an event counter. Use mode 2 and display the binary count on P2 continuously. Set the initial
count to 20.
49. Program Timer 1 to be an event counter. Use mode 2 and display the decimal count on P2, P1, and P0 continuously
Set the initial count to 99.
50. Which bits of the TCON register function as start bits of the timer?
51. Which bits of the TCON register are the timer rollover flags?
52. How can an external frequency be counted using the 8051?

SECTION 9.3: PROGRAMMING TIMERS 0 AND 1 IN 8051 C


53. Program Timer 0 in C to generate a square wave of 3 kHz. Assume that XTAL = 11.0592 MHz.
54. Program Timer 1 in C to generate a square wave of 3 kHz. Assume that XTAL = 11.0592 MHz.
55. Program Timer 0 in C to generate a square wave of 0.5 kHz. Assume that XTAL = 11.0592 MHz.
56. Program Timer 1 in C to generate a square wave of 0.5 kHz. Assume that XTAL = 11.0592 MHz.
57. Program Timer 1 in C to be an event counter. Use mode 1 and display the binary count on Pl and P2 continuously.
Set the initial count to 20,000.
58. Program Timer 0 in C to be an event counter. Use mode 2 and display the binary count on P2 continuously. Set the
initial count to 20.

ANSWERS TO REVIEW QUESTIONS


SECTION 9.1: PROGRAMMING 8051 TIMERS
1. Two
2. 2,8
3 8
4. False
5. 0010 0000 indicates Timer 1, mode 2, software start and stop, and using XTAL for frequency.
6. FFFFH to 0000
7. FFH to 00
8. -200 is 38H; therefore, TH1 = 38H
9. 2 ms/1.085 ms = 1843 0733H where TH =07H and TL = 33H
10. 100 ms/1.085 ms = 92 or 5CH; therefore, TH = 5CH

SECTION 9.2: COUNTER PROGRAMMING


1. The crystal attached to the 8051
2. The clock source for the timers comes from pins TO and T1.
3. Yes

TEMS

234 THE 8051 MICROCONTROLLER AND EMBEDDED SYS1E


4. We must use the instruction "sETB P3.4" to contigure the T1 pin as input, which allows the clocks to come from
anexternal source. This is because all ports are configured as output upon reset.
5 SETB TR1

SECTION 9.3: PROGRAMMING TIMERSO AND 1 IN 8051 C


1. The crystal attached to the 8051
2. Timer 2, mode 2, 8-bit auto
reload
3. FFFFH to 0
FFH to 0
38H
b. TMOD
7 Yes
S. while (TF1==0);

8051 TIMER PROGRAMMING IN ASSEMBLY AND C


See www.MicroDigitalEd.com on how to use Timer 2 to set
the baud rate of Serial #0.

SUMMARY
This chapter began with an introduction to the fundamentals of serial communication. Serial communication
which data is sent one bit a time, is used when data is sent over significant distances since in parallel communication
where data is sent a byte or more a time, great distances can cause distortion of the data. Serial communication has tha
additional advantage of allowing transmission over phone lines. Serial communication uses two methods: synchrono
and asynchronous. In synchronous communication, data is sent in blocks of bytes; in asynchronous, data is sent in bytes
Data communication can be simplex (can send but cannot receive), half duplex (can send and receive, but not at the same
time), or full duplex (can send and receive at the same time). R$232 is a standard for serial communication connectors
The 8051's UART was discussed. We showed how to interface the 8051 with an RS232 connector and change the
baud rate of the 8051. In addition, we described the serial communication features of the 8051, and programmed the
8051 for serial data communication. We also showed how to program the second serial port of the DS89C4x0 chip in
Assembly and C.

PROBLEMS
SECTION 10.1: BASICS OF SERIAL COMMUNICATION
1 What is the advantage of serial communications over parallel communications?
2.
Distinguish between half duplex and full duplex mode of communications.
3. of the letter ASCII "Z" (0101 1010), no parity, 1 stop bit.
4.
Show the framing
If there is no data transfer and the line is high, it is
5.
called
True or false. The stop bit can be 1, 2, or none at all.
(mark, space).
6. Distinguish between synchronous and asynchronous data transfer.
Which are the voltage levels used in R$232C?
8. What is the function of the MAX 232 chip?
9 True or false. DB-25 and DB-9 are pin compatible for the first 9 pins.
10. How many pins of the R$232 are used by the IBM serial cable, and why?
11. Which are the minimum signals required in serial data transmission?
12. State the absolute minimum number of signals needed to transfer data between two PCs connected serially. What
are those signals?
13. If two PCs are connected through the R$232 without the modem, they are both configured as a (DTE,
DCE) -to (DTE, DCE) connection.
14. State the nine most important signals of the R$232.
15. Calculate the total number of bits trarnsferred if 200 pages of ASCII data are sent using asynchronous serial data
transfer. Assume a data size of 8 bits, 1 stop bit, and no parity. Assume each page has 80x25 of text characters.
16. In Problem 15, how long will the data transfer take if the baud rate is 9,600?

SECTION 10.2: 8051 CONNECTION TO RS232


17. What is the function of the chip MAX232?
18. Which pins of the 8051 are connected to MAX232?
19. The MAX233 DIP package has
20.
.

pins.
For the MAX233, indicate the
21.
Vcc and GND pins.
What is the advantage of
using the MAX233 from Maxim?
22. State the
advantages and disadvantages of the MAX232 and MAX233.
23. MAX232/233 has line driver(s) for the RxD wire.

266 1S
THE 8051 MICROCONTROLLER AND EMBEDDED SYSTEM>
24. MAX232/233 has line
25. Show the connection
driver(s)
of pins TxD for the TxD wire.
and RxD of the 8051 to a DB-9 RS232 connector via the second set of line drivers
of MAX232.

ak drivers
Show theof connection
MAX233, of the TxD and RxD pins of the 8051 to a DB-9 RS232 connector via the second set of line
26

a7 Show the connectionof the TxD and RxD pins of the 8051 to DB-25 RS232 via
connector via
Show the connection of the TxD and RxD pins of the 8051 to aa DB-25 RS232 connector MADD. MANLO
28.

crCTION 10.3: 8051 SERIAL PORT PROGRAMMING IN ASSEMBLY


0Which of the following baud rates are supported by the BIOS of 486/Pentium PCs?
(a) 4,800 (b) 3,600 (c)9,600
(d) 1,800 (e) 1,200 (f)19,200
a0 What is the role played by Timer 1 in serial communication?
21 Which mode of the timer is used for baud rate programming?
22 What is the role of the SBUF register in serial data transfer?
23 What is the function of the SBUF register ?
24 What is the role of the SCON register in serial data transfer?
35. Which are the important functions specified in the SCON register?
36. For XTAL = 11.0592 MHz, find the TH1 value (in both decimal and hex) for each of the following baud rates.
(a) 9,600 (b) 4,800 (c)1,200 (d) 300 (e) 150
37. What is thebaud rate if we use "MOV TH1, #-1" to program the baud rate?
38. Write an 8051 program to transfer serially the letter "Z" continuously at a 1,200 baud rate.
39. Write an 8051 program to transfer serially the message "The earth is but one country and mankind its citizens"
continuously at a 57,600 baud rate.
40. Under what conditions are the TI and RI bits raised?
41. Write a program to transfer the numbers 1 to 9 serially.
42. To which register do RI and TI belong? Is that register bit-addressable?
43. What is indicated by the REN bit ofthe SCON register?
44. In a given situation we cannot accept reception of any serial data. How do you block such a reception with a single

instruction?
the rate of data transfer.
45. To which register does the SMOD bit belong? State its role in
46. Is the SMOD bit high or low when the 8051 is powered up?
compatible
not with the COM ports of the PC (x86 IBM/compatible).
following questions the baud rates
are
In the
16 MHz and SMOD 0.
Find the baud rate for the following if XTAL =
=

47.
(a) MOV TH1,#-10 (b) MOV TH1, #-25
() MOV TH1, #-200 (d) MOV TH1, #-180 loaded with -10?
TH1
the baud rate if is
8. For XTAL of frequency 22 MHz, what is
a
=1.
16 MHz and SMOD
Find the baud rate for the following if XTAL
=

49.
(b) MOV TH1,#-25
(a) MOV TH1, #-100
(d) MOV TH1,#-180
(c) MOV TH1, #-200
transfer be doubled?
. How can the baud rate of data

PORT
PROGRAMMING THE SECOND SERIAL
SECTION 10.4:
with a second serial port.
which comes

Name o n e version of 8051 to set the baud rate for


the second serial port?
DS89C4x0 is used
52. Which timer of the rate programming of the
second serial port?
is used for baud
53. Which mode of the timer SBUF of the second serial port of DS89C4x0?
54. What are the addresses
of the SCON and
55. SBUF1 is a(n). -bit register. serial data transfer?
SCON1 register in
What is the role of the
6. serial port, how are the
SFRs designated?
57. For using the second
find the THl value (in both decimal and hex) for each of the following baud rates.
58. For XTAL=11.0592 MHz,
1,200 (d) 300 (e) 150
(a) 9,600 (b) 4,800 (c)

ASSEMBLY AND C 267


8051 SERIAL PORT PROGRAMMING IN
. Write a
program for DS89C4x0 to transfer serially the letter "Z" continuously at a 1,200 baud rate. Use the sSecond
serial port. nd
DU. Write
program for DS89C4x0 to transfer serially the message "The earth is but
a
one country and
citizens" continuously at a 57,600 baud rate. Use the second serial mankind it
61. When is the TI1 port.
flag bit raised?

SECTION 10.5: SERIAL PORT PROGRAMMING IN C


62. Write 8051 C program to transfer
an
63. Write 8051 C program to transfer
an
serially the letter "Z" continuously at a 1,200 baud rate.
continuously at a 57,600 baud rate.
serially the message "The earth is but one country and mankind its citizens"
64. Write aC
program for DS89C4z0 to transfer serially the letter "Z" continuously at a 1,200 baud rate. Use the
serial port. second
65. Write a
Cprogram for the DS89CAx0 to transfer serially the
citizens" continuously at a 57,600 baud rate. message "The earth is but one country and mankind its
Use the second serial
port.

ANSWERs TO REVIEW QUESTIONS


SECTION 10.1: BASICS OF SERIAL
COMMUNICATION
1 Faster, more expensive
2 False; it is simplex.
3. True
4 Asynchronous
5. With 0100 0101
binary the bits are transmitted in the
(a) 0 (start bit) (b) 1 (c)0 (d) 1 (e)0 ()0 (g) 0 (h) 1 (i) 0sequence:
6. 2 bits (one for the start bit and one for the G) 1 (stop bit)
transferred. stop bit). Therefore, for each 8-bit
7. 10000x 10 character, a total of 10 bits is
8. True
100000 bits total bits transmitted. 100000/9600 =
10.4 seconds;
2/10 20%.
9 +3 to+25 V
10. True
11. 2
12. COM 1 and COM12
SECTION 10.2: 8051 CONNECTION TO RS232
1. True
2. Pins 10 and 11. Pin 10 is for TxD and
pin 11
B They are used for converting from RS232 voltageRxD
for
levels to TTL
4 2,2 voltage levels and vice versa.
5. It does not need the four
capacitors that MAX232 must have.
SECTION 10.3: 8051 SERIAL PORT
1
PROGRAMMING IN ASSEMBLY
Timer1
28 800 Hz
Mode 2
3 or FDH since
SBUF 28800/3 9600
Serial control, 8
7.
SCON
False
9 During
10. PCON; transfer
it is lovw
of
stop bit
upon RESET.
268
SERIAL PORT
SECTION 10.4: PROGRAMMING THE SECOND

1. Timer 1
2 Pins P1.2 and P1.3
3. -1 of FFH
SBUF1
Serial Control 1, 8
5.
6. SCON1
SECTION 10.5: SERIAL PORT PROGRAMMING INC KT

1 By using the reg51.h file


2. False
3. sfr

NIRRI PTS IRO


EMB
D

D
O (D .

(D
P CO
Whatare the
contents of the IE
1 wthe instruction
to enable
register upon reset, and what do these values mean?
Show
the EX1 and Timer 1
Show the instruction to enable every interrupt of theinterrupts.
12

8051. interrupts INTO and INT1?


Which pin of the 8U5l 1s assigned to the external hardware
15 How many bytes of addres ress
15w Many bytes of addre space in the interrupt table are assigned to the INTO and INT1 interrupts?
vector
space in the interrupt vector table are assigned to the Timer 0 and Timer 1 interrupts
To Dut the entire interrupt service routine in the bytes in
SIze.
interrupt vector table, it must be no more than
When an interrupt is activated, what is the first step taken the
ith a single instruction, show how to disable all
19. Wi by 8051?
the interrupts.
nstruction, show how to disable EX1
With a single inst;
AWhat does the 8051 do on encountering the RETItheinstruction?
interrupt.
lnthe 8051, how many bytes of ROM space are
assigned
to the reset
interrupt, and why
ccCTION 11.2: PROGRAMMING TIMER INTERRUPTS
3 false. For both Timer 0 and Timer 1, there is an
True or
What address in the interrupt vector table is assigned tointerrupt
Timer 1?
assigned to it in the interrupt vector table.
6 Which bits of the IE register are allocated for the timers?
hWhatis the effect of clearing the EA bit of the IE register?
97. Assume that Timer 0 1s programmed in mode 2, TH1 =FOH, and the IE bit for Timer 0 is enabled. Explain how the
interrupt for the timer works.
278. Can the 8051 generate two square waves simultaneously?
99. Assume that Timer 1 is programmed for mode 1, THO = FFH, TL1 = F8H, and the IE bit for Timer 1 is enabled.
Explain how the interrupt is activated.
30. If Timer 1 is programmed for interrupts in mode 2, explain when the interrupt is activated.
31. Write a program to create a square wave of T 160 ms on pin P2.2 while at the same time the 8051 is sending out
55H and AAH to P1 continuously.
32. Write a program in which every 2 seconds, the LED connected to P2.7 is turned on and off four times, while at the
same time the 8051 is getting data from Pl and sending it to PO continuously. Make sure the on and off states are
50 ms in duration.

SECTION 11.3: PROGRAMMING EXTERNAL HARDWARE INTERRUPTS


3. How many hardware interrupts has the 8051? How are they activated?
34. What address in the interrupt vector table is assigned to INTO and INT1? How about the pin numbers on port 3?
35. Which bits of the IE register are used to set/reset the external hardware interrupts?
enabled and to transfer 00H if EX1 is enabled2
36. Write a
program to transfera data FFH through port 1 when EX0 is
37. Show how to enable both external hardware interrupts.
38. Assume that the IE bit for external hardware interrupt EX0 is enabled
and is low-level triggered. Explain how this
interrupt works when it is activated. How can we make sure that a single interrupt is not interpreted as multiple
interrupts? hardware interrupt is edge-triggered.
9. True or false. Upon reset, the external that a single interrupt is not recognized multiple
as interrupts?
In Question 39, how do we make sure

41. Which bits of TCON belong to EX0?


2. Which bits of TCON belong to EX1?
minimum time period of the high-to-low pulse used
for an edge-triggered interrupt?
. What should be theTCON.0 and TCON.2 in the execution of external
interrupt 0.
Explain the role of 1.
TCON.3 in the execution of external interrupt
Explain the role of TCON.1 and enabled and is edge-triggered. Explain how
this
external hardware interrupt EX1 is
bit for as multiple
*.
ASsume that the IE can we make sure that
a single interrupt is not interpreted
when it is activated. How
interrupt works

interrupts? interrupts to get data from Pl and


send it to P2 while Timer 0 is generating a square
wave

Write program
a using
of 3 kHz. P2 while Timer 1 is turning on and off the LED
data from Pl and send it to
48 Write a program using interrupts get
to
second.
Connected to P0.4 every

IN 295
TERRUPTs PROGRAMMING IN ASSEMBLY AND C
49. Write a program to generate a rising edge once, when a high-to-low transition is reveived on INTO
50. What is the method to disable all interrupts?
51. Which interrupts are latched, low-level or edge-triggered?
52. Which register keeps the latched interrupt for INT and INTI?

SECTION 114: PROGRAMMING THE SERIAL COMMUNICATION INTERRUPT


53. How many serial interrupts has the 8051?
54. What address in theinterruptvector table isassigned totheserial interrupt? How many bytes ane assignesd taas
55. Which bit of the IE register belongs to the serial interrupt? Show how it is enabled.
56. Assume that the IE bit for the serial interrupt is enabled. Explain how this interrupt gets activated and also
eplao
its working upon activation. plain
57. True or False? On making EA =0 of the lIE register, the serial interrupt is still enabled.
58. True or false. The last two instructions ot the ISR or the receive interrupt are:
CLR TI
RETI
59. Answer Question 58 for the receive interrupt.
60. Assuming that the interrupt bit in the IE register is enabled, when Tl is raised, what happens subsequently?
61. If RI is kept enabled, can data be received on RxD line?
62. Write a program using interrupts to get data
a square wave of 5 kHz.
serially and send it to P2 while at the same time Timer 0 is generating
63. Write a program using
interrupts to get data serially and send it to P2 while Timer 0 is turning the LED connected
to P1.6 on and off every second.

SECTION 11.5: INTERRUPT PRIORITY IN THE 8051/52


64. Which is the highest
priority interrupt of 8051?
65. Which register caters to the function of
66. Which bit of IP belongs to the EX2
changing interrupt priorities?
67. Which bit of IP
interrupt priority? Show how to assign it the highest priority.
belongs to the Timer 1 interrupt priority? Show how to assign it the highest priority.
68. True or False? Interrupts can be enabled
by software.
69. Assume that the IP
register has all 0s. Explain what happens if both INTO and INT1 are activated at the same
time.
70. Assume that the IP
register has all 0s. Explain what happens if both TFO and TF1 are activated at the same time
71. If both TFO and TF1 in the IP are set to
high, what happens if both are activated at the same time?
72. If both INTO and INT1 in the IP are set to
73. Explain what happens if a
high, what happens if both are activated at the same time?
low-priority interrupt is activated while the S051 is serving a higher-priority interrupt
ANSWERS TO REVIEW QUESTIONS
SECTION 11.1: 8051 INTERRUPTS
1. Interrupts
5
Address locations 0000 to 25H. No.
All 0s
They are set when the processor is designed.
means that all
interrupts are masked, and asa result no
5. MOV IE, #10000011B interrupts will be responded to by the S051.
6. P3.3, which is pin 13 on the 40-pin DIP package
7. 0013H for INT1 and 001BH for Timer 1

SECTION 11.2: PROGRAMMING TIMER INTERRUPTS


1. False. There is an
2. 000BH
interrupt for each of the timers, Timer 0 and Timer 1
3. Bits D1 and D3 and "MOV IE,
#10001010B" will enable both of the timer
4. After Timer 1 is started with instruction
"SETB TR1", the timer will count
interrupts.
from F5H to FFH on its own ile
the 8051 is
executing other tasks. Upon rolling over from FFH to 00, the TF1 up
flag is raised, which will interrupr
296 THE 8051 MICROCONTROLLER AND EMBEDDED SYSTEM
SO51 in whatever it is doin
a n d force it to jump to memory location 001BH to execute the ISR belonging to this
interrupt.

alse. There is no need


False tor "CLR TF0"
since the RETI instruction does that for us.

TION 11.3:PROGRAMMING EXTERNAL HARDWARE


INTERRUPTS
alse. There 1san interrupt for each of the external
003H and 0013H. The pins numbered 12 (P3.2) andhardware
13
interrupts of INTO and INTl.
Rits D0 and D2 and "MOV IE, #10000101B" will enable(P3.3) both
on the DIP
package.
of the external hardware
Upon application of a low pulse (4 machine cycles wide) to pin interrupts
P3.3, the 8051 is interrupted in whatever it is doing
nd jumps to ROM location 0013H to
execute the ISR
True

Make sure that the low pulse applied to pin INT1 is no wider than 4 machine cvcles. Or, make sure that the NTI
in is brought back to high by the time the
pin. 8051 executes the RETI instruction in the ISR.
False. There is no need tor the "CLR TCON. 0" since the RETI instruction does that for us.
S. TCON.0 is set to high to make INTO an edge-triggered interrupt. If INTO is edge-triggered (that is, TCON.O
whenevera high-to-low pulse is applied to the INTO pin it is captured (latched) and kept by the TCON.21sDitSet),
Dy
making TCON.2 high. While the ISR for INTO is being serviced, TCON.2 stays high no matter how many
H-to-L pulse is applied to pin INTO. Upon the execution of the last instruction times an
of the ISR, which is RETI, the TCON.2
bit is cleared, indicating that the INTO pin can respond
to another interrupt.
SECTION 11.4: PROGRAMMING THE SERIAL COMMUNICATION INTERRUPT
1 True. here is only one interrupt for both the transfer and receive.
2 23H
3 Bit D4 (E.4) and "MOV IE, #10010000B" will enable the serial interrupt.
4 The RI (received interrupt) flag is raised when the entire frame of data, including the stop bit, is received. As a result
the received byte is delivered to the SBUF register and the 8051 jumps to memory location 0023H to execute the ISR
belonging to this interrupt. In the serial cOM interrupt service routine, we must save the SBUF contents before it is
lost by the incoming data.
5. False
6. True. We must do it since the RETI instruction will not do it for the serial interrupt.

7 CLR TI
RETI

SECTION 11.5: INTERRUPT PRIORITY IN THE 8051/52


to Table 11-3.
1. They are assigned priority according
False.
is bit-addressable.
2.P (interrupt priority) register. Yes, it
#0001000OB" will do it.
"MOV IP, After INT0 is serviced,
. Bit D4 (P.4) and the instruction is serviced first since it has a higher priority.
activated at the same time, INTO transitions are latched. In the
t both are and H-to-L
are edge-triggered
INI1 is serviced, assuming that
the external interrupts INTO is serviced first;
then after the
activated at the same time, the it will
if both
if the INT1 pin is still high,
are
case of low-level triggered interrupts, and INT1 pins again, and
it the INTO
8051 has finished servicing the INTO,
scans

is put on hold and the higher


be serviced. that the lower-priority interrupt
interrupt, meaning the lower-priority ISR.
inside the 8051 r e s u m e s servicing
an
We have a n interrupt this higher-priority interrupt,
one is serviced. After servicing

297
INTERRUPTS PROGRAMMINGIN ASSEMBLY ANDC
Review Questions
1. True or false. To see if any key is pressed, all rows are grounded.
2. IfD3 DO 0111 is the data read from the columns, which column does the pressed key belong to?
3. True or false. Key press detection and key identification require two different processes.
4. In Figure 12-6,if the rowsare D3 - D0 = 1110 and the columns are D3 DO = 1110, which key is pressed?
5. True or false. To identify the pressed key, one row at a time is grounded.

SUMMARRY
This chapter showed how to interface real-world devices such as LCDs and
the
keypads to the 8051. First, we de a
operation modes of LCDs, then described how to program the LCD by sending data or commands to it via ite
face to the 8051. inter.
Keyboards are one of the most widely used input devices for 8051 projects. This chapter also described tho .
ation of keyboards, including key press and detection mechanisms. Then the 8051 was shown
board. 8051 progranms were written to return the ASCII code for the interfacing with
pressed key. key.
PROBLEMS
SECTION 12.1: LCD INTERFACING
1. Which are the two
registers in the LCD module?
2. How can data be transferred to the LCD from a port using only 4 port lines?
3. To display letters and numbers, we send data
in_ code.
4. "Clear LCD" is a (command code, data item) and its value is
5. What is the hex value of the command code for
hex.
6.
"display on, cursor on"?
Which are the control pins of the LCD? What are their functions?
7.Give the state of RS, E, and R/W when
8.Which of the following is needed on the E
sending data character Z" to the LCD.
pin in order for a command code (or data) to be latched in by the LCD?
(a) H-to-L pulse (b) L-to-H pulse
9. How does the LCD
10. How does the
distinguish between data and command?
busy flag aid in making the LCD program more efficient?
11. For a 16x2 LCD, the location of the last character of
line 1 is 8FH (its command code). Show how this value was
calculated.
12. For a 16x2 LCD, the location of the first
character of line 2 is COH (its command code). Show how this value was
calculated.
13. For a 20x2 LCD, the location of the last character of line 2 is
93H (its command code). Show how this value was
calculated.
14. For a 20x2 LCD, the location of the third character of line 2 is C2H
(its command code). Show how this value was
calculated.
15. For a 40x2 LCD, the location of the last character of line 1 is A7H (its command code). Show how this value was
calculated.
16. For a 40x2 LCD, the location of the last character of line 2 is E7H (its command code). Show how this value was
calculated.
17. Show the value (in hex) for the command code for the 10th location, line 1 on a 20x2 LCD. Show how you got your
value.
18. Show the value (in hex) for the command code for the 20th location, ine 2 on a 40x2 LCD. Show how you got your
value.
19. Rewrite the COMNWRT subroutine. Assume connections P1.4 = RS, P1.5 = R/W, P1.6 = E.
20. Repeat Problem 19 for the data write subroutine. Send the string "Hello" to the LCD by checking the busy flag Use
the instruction MOVC.

SECTION 12.2: KEYBOARD INTERFACING


21. In reading the columns of a keyboard matrix, if no key is pressed we should get all . (1s, 0s).
22. In Figure 12-6, to detect the key
press, which of the following is grounded?
(a) all rows (b) one row at timne (c) both (a) and (b)

MS
318 THE 8051 MICROCONTROLLER AND EMBEDDED SYSTEM
23. In Figure
(a) all rowws
l2-6,
t identify
the key presned, whieh of the following le groundecdr
(b) one row at timee (c) both (a) and (b)
4, For Figure 12-6, indicate the
(a) D3 - DO =0111 column and row for each of thhe following
(b) D3 D0 = 1110
a Indicate the steps to detect the key press.
26. Indicate the steps to identify the key pressed.
27. We need to operate a key in the interrupt mode. How should the key be
28. Ifa switch is connected to pin P3.2, what happens when the switch connected?
is pressed and a low Is recelved on the pin

ANSWERS TO REVIEw QUESTIONS


SECTION 12.1: LCD INTERFACINCG

1. Input
2. Input
3. H-to-L
4. High
5. 80H and COH

SECTION 12.2: KEYBOARD INTERFACING


True
2. Column 3
3. True
4. 0
5. True

319
ROARRINTERFACING
for (y=0; y<1275;Y++)
++)

Review Questions
1. True or false.
2. The
The LM35 provides
3.
transducer must be
4.
The LM34 provides connected to signal
mV for
5.
Why do we set
the
each
mV for each degree of conditioning circuitry
ircuitry before it is sent to the
4, whatV,.of
In
Question is the ADCO848 to 2.56 V ifdegree
the
of .
to
(Fahrenheit, Celsius) temperature
te sADC.
temperature if the ADC analog (Fahrenheit, Celsius) temperature.
input is connected to the
output is 0011 1001? LM35?
SUMMARY
This
First, we chapter showed how to
discussed interface real-world
in both both parallel and devices such as DAC
we Assembly and C. serial ADC
studied sensors. We Next we explored the DAC chips, then described how tochips, ADC chips, and sensors to
also discussed chip, and showed how tointerface them to the 8051 and the 51.
conditioning, an essential feature of datathe relation between the interface it to the 8051. In program it
acquisition systems. analog world and digital device, and described
a the last section
signal
PROBLEMS
SECTION 13.1: PARALLEL
AND SERIAL ADC
1. Write a
program segment to
2. To access the chip, what generate the start conversion
3. The logic level should be pulse for ADC0804. Use
4.
ADC0804 is
What is
a evel
bit should
ADC.
given on
on tthe CS line of
ADC0804?
pin P1.0.
the function of the
5. Write a EOC pulse?
program segment to check if the ADC
6. Give a more
7. In the
efficient way of using the EOC has finished conversion.
ADC0804, what should be the output line of the ADC.
8. In the
ADC0804, what should be the V/2 value for a step size of 20
mV?
9. In the V,/2
ADC0804, what is the role of pins value for a step size of 5 mV?
step size of 19.53 mV, what is the V,+)
10. With a and V, (-?
11. With
V,/2= 0.64 V, find the Vn for the analog input voltage if all outputs are 1?
(a) D7 -DO 11111111= following outputs.
(b) D7 -D0 10011001
=

(c) D7 - DO = 1101100
12. Assume that the EOC
to the 8051?
pin of the ADC 0804 is connected to pin P3.2 of the
8051. How is the ADC
output transferred

352
THE 8051 MICROCONTROLLER AND EMBEDDED SYSTEMS
hich of the tollowin8 ADC sizes provide the best resolution?
(a)8-bit (b) 10-bit (c) 12-bit
(d) 16-bit (e) They are all the same.
4 estion 13, which provides the smallest step size?
In Ques.

Calculate the step size for the following ADCs, if Vis 5V.
(a)8-bit (b) 10-bit (c) 12-bit (d) 16-bit
rue or talse. ADCO8O08/0809 is an:8-bit ADC.
Indicate the out) for each of the following ADC0808/0809
direction (in, pins.
(a)SC (b) EOC (c) A, B, C
(d) ALE (e) OE () INO - IN7

(g) DO- D7
to select channel analoE pu
5
ENplain the role of the ALE pin in the ADCO808/0809 and show how value if we want the following sizes:
the ADCUSUB70809, assume V,-) Gnd. Give the V(+) voltage
=

In
(a) 20 mV b)5 mV (c) 10 mV
(d) 15 mV (e) 2 mV (f) 25 mV
following values of V,+)
In the ADCOSOS/0809, assume V-)= Gnd. Find the step size for the
(a) 1.28 V b) 1 V (c)0.64 V
different from ADCO804?
1 In what way is the ADCO808channel selected?
2. How is a particular analog
need of ALE on this chip? of the ADC0808. What
should
23 What is the
thatpins PO.0 to PO.2 of the 8051 is connected to pins A, B and C, respectively
4 Assume
be the values on the port pins to select.
(b)IN4 (c) IN7?
(a) INO
the importance of the OE pin? function in the ADC0848?
5 What isADCO848, INTR is an_ -(input, output) signal. Whatis its
26. In the size for each of the following Ver
ADCO848 chip, find the step
27. For an ()Ve1.9V
(a)V1.28 V (b) VPe1V 20 mV?
value if we want a step size of
ADCO848, what should be the V size of 5 mV?
28. In the if we want a step
ADC0848, what should be the Vvalue
29. In the channel selected?
how is the analog are 1?
30. In the ADC0848, what is the analog input voltage if all outputs
size of 19.53 mV,
31. With a step for the following outputs.
1.28V, find the V
1101100
(c) D7- D0
=

32. With V =

11111111 b) D7- D0
= 10011001

(a) D7- DO
=

ADC.
MAX1112 is a n 8-bit MAX1112 pins.
33. True or false.
direction (in, out) for each of the following
34. Indicate the (c) COM
b) DOUT
(a) CS CHANO - CHAN7

(d) DIN
(e) SCLK (
MAX1112 ADC?
(g) SSTRB has the
inputs digital outputs
and
5. How many analog does a serial
ADC offer?
36. What advantage inbuilt ADC. externally.
members with REFIN provided
Name two 8051 family each of the following
37. find the step size
for
(c) REFIN
=1.9 V
38. For MAX1112 chip, (b) REFIN =1V
V
(a) REFIN 1.28 =
channel selected? size of 5 mV?
MAX1112, how is the analog value if w e want
a step
In the the REFIN
9. what should be outputs. 1101100
In the MAX1112, for the following D7 D0
0.
=

V (c)
-

find the
W i t h REFIN
1.28 V, =
D7 D0
10011001
of the SCLK signal.
edge/negative edge)
=

(b)
-

of the SCLK signal.


edge/negative edge)
11111111 -(positive
(a) D7- D0 the, (positive
is sent in
o n

The control byte data is brought out o n the.


5. Converted digital
lowest
REFIN value? control byte. conversion is completed.
.What is the send in the channel after the
SCLKs to data for o n e
45. It takes . out digital
SCLKs to bring M A X 1 1 1 2 ?
46. It takes. the
startin
the
conversion
in theMAX1112?
When does
e n d - o f - c o n v e r s i o n

REFOUT?
recognize c o n n e c t e d to
AGND with
How do we -CHAN7?
size if REFINis reference for CHANO
is the step is used for ground
What which pin
mode,
30. In single-ended

INTERFACING
SENSOR
ADC, DAC, AND
SECTION 13.2: DAC INTERFACING

51. Write a program to generate a saw tooth waveform using a DAC.


52. Write a program to generate a triangular waveform using a DAC.
53. Some microcontrollers have inbuilt PWM circuitry. Why is this considered as an inbuilt DAC for these chips?
54. Find the I for the following inputs. Assume I, = 2 mA for DACOB08.
(a) 10011001 (b) 11001100 (c) 11101110
(d) 00100010 (e) 00001001 () 10001000
55. To get a smaller step, we need a DAC with. (more, fewer) digital inputs.
56. To get full-scale output what should be the inputs for DAC?

SECTION 13.3: SENSOR INTERFACING AND SIGNAL CONDITIONING


57. What does it mean when it is said that a given sensor has a linear output?
58. The LM34 sensor produces mV for each degree of temperature.
59. What is signal conditioning?
60. What is the purpose of the LM336 Zener diode around the pot setting the Vrin Figure 13-21?

ANSWERS TO REVIEW QUESTIONS


SECTION 13.1: PARALLEL AND SERIAL ADC
1. Output
2. L-to-H, WR
3. INTR
4. 8
5. (a) all in (b) in (c) out
6. Output
7. L-to-H, WR
8. INTR
9 8
10. True
11. (a) 1 (b)8 (c) 88
12. We send the control byte to the DIN pin one bit at a time.

SECTION 13.2: DACINTERFACING


1. Digital, analog. In ADC the input is analog, the output is digital.
2. 8
3. (a) current (b) true

SIGNAL CONDITIONING
SECTION 13.3: SENSOR INTERFACING AND

1. True
2. 10, Celsius.
3. 10, Fahrenheit. 10 mV. LM35 10 mV for eac
256 steps, and 2.56 V/256
=
produces
4 Since ADC0848 is an 8-bit ADC, it gives us
ADC's step size.
degree of temperature which matches the
5. 00111001 = 57, which indicates it is 57 degrees.

EMBEDDED SYSTEM
THE 8051 MICROcONTROLLER AND
354
With the
(e) DRAM A0 nll,1, D0
DO D7 --
(6)
UV-EPROM
EPROM Ao. A1 following
lowing pins.
A10, DO A0 A12, D0 -D7 pins.
-

(d) SRAM
(g)EEPROM
-

A0 A0 - A12, DO D7
A11, DO -D07 ()
)DRAM (h)SRAMA
-
-

A0 A12, DO
A8,
-

.Find the address DO D3


-

(a) 64 K x 8 RAM and data lines for ()theDRAM A0 A7, DO


UV-EPROM -
AO A10, DO
-

A10, DO--D7
D7
D7
following
-

(c) 64 Kx 16 ROM
7
17 Find the checksum (b) 32K x 8 ROMmemory chips.
(d) 256
For each of the byte for these bytes: 34H,4 RAM x

yerify if the data is following


sets of data
(the
54H, 7FH, 11H,
E6H, 99H
(a) 29H, 1CH, 16H, corrupted. last byte is the
38H, and 6DH checksum byte) 07-DO
(b) 29H, 1CH,
cECTION 14.2: MEMORY 16H, 30H, and 6DH A0
14 Find the address
ADDRESS DECODING A0
A13
0 For a 8K RAM, range of the memory
21 Find the addressexplain for
an
address design in the diagram. A14 16Kxs

range Y0, Y3, and decoding scheme using


A15 d
design.
22 Using
Y6 of the
74LS138 for simple
the
gates.
the 74138, diagrammed
controlled by Y0 isdesign
in the
the
memory decoding circuitry in which the
range 0000H to
Diagram for Problem 19
controlled by each Y. 1FFFH. Indicate the
size of the memory block
23. Find the address range for memory block
94. Using the 74138, design Y3, Y6, and Y7 in Problem 22.
memory decoding circuitry in
trolled by Y0 is in the 0000H 74LS138
to 3FFFH which the A12
space. Indicate the size ofmemory block con- A
controlled by each Y. the A13- B
25. Thechip select line of a memory memory block A14
chip is usually active. GND G2A
LA
SECTION 14.3: 8031/51 INTERFACING GND G2B
WITH EXTERNAL ROM A15 G1
26.For an 8031 with external
last address is program memory of 4K, if the
starting address is 0000, the iagram for Problem 21
27. What is the role of the
28. Can data be stored in
chip 74LS373 in Figures 14-9 and 14-10?
29. The 8051
program ROM?
supports maximum of Kbytes of program memory space.
a
.

any member of the 8051 family, if EA Gnd the microcontroller fetches program code TOm
external ROM. r
=

385
8051 INTERFACING TO EXTERNAL MEMORY
be changed, if external program ROM is to be added ,
31. Which pin connection of the 8051 has to
liu

have external memory for program code?


32. For which of the following must we

(a) 8751 (b) 89C51 (c) 8031 (d) 8052


33. For which of the following is external memory for program code optional
8O52
(a) 8751 (b) 89C51 () 8031 (d)
34. In the 8051, which port provides the A0 A7 address bits?
-

In the 8051, which port provides


the A8 - A15 address bits?
35.
the DO D7 data bits?
In the 8051, which port provides
-

36.
between ALE 0 and ALE 1.
= =

37. Explain the difference


38. RD is pin of P3, and WR is pin_of P3. What about PSEN? external ROM?
used in fetching program code from
39. Which of the following signals must be
(a) RD (b) WR (¢) PSEN how are they accessed?
40. If a
system has on-chip and off-chip ROM, ROM and data ROM?
what is the difference in the connection to the program
41. In an 8051-based system, In other words, the memory code spary
8051-the program code must be read-only memory,
42. True or false. For the
of the 8051 is read-only menmory. ROM external (off-chip) code ROM?
accessing on-chip code
or
PSEN is used. Is it used in
43. Indicate when
MEMORY SPACE
SECTION 14.4: 8051 DATA
data memory?
are used. Are they
used in açcessing external
when RD and WR connected to the 8051?
44. Indicate
of a data RAM that can be directly
45. What is the maximum capacity data from external data
ROM?
must be used in fetching
46. Which of the following signals
PSEN (d) both (a) and (b)
(a) RD (b) WR (¢) indicate if it is active low
or active high.
47. For each of the following, the three
differentiate between
PSEN (b) RD (c) WR which pins are used to
(a) and program ROM,
data RAM, data ROM used.
48. Ifa system u s e s MOVX and MOVC are The external data
KO
show how the instructions data ROM to internal RAM.
49 With a n example, external
of data from
to transfer 20 bytes location sta
50. Write a program at 60H. data RAM
and internal RAM starts 40H onwards to external
address is 2000H, from internal RAM
to transfer 20 bytes of data
data RAM.The
ext
51. Write a program data ROM to external
ing from A000H. from external
transfer 50 bytes of data 8000H.
Write a program
in Assembly to external data RAM
starts at
SRAM of DS89C4x
52. and the external data
ROM to 1KB
address is 300OH, from
nal data ROM to transfer 50 bytes of
data 0000H.
Assembly data starts at Pl o n e byte at
a
in
53. Write a program
is 3000H, and the SRAM
1KB SRAM of DS89C4x0 to
ROM address from
external data to transfer
50 bytes of data
program
in Assembly 0200H.
54. Write a starts at
The SRAM data reset.
second. c o n t e n t s upon
every PMR and its DS89C4x0?
available in
address of the SRAM reset.
the the blocked) upon
55. Give used to a c c e s s (available,
i n s t r u c t i o n is
0 and DME1 =
0?
56. Which the 1KB SRAM is if DME0 =

DS89C4x0, = 0?

57. For the a v a i l a b l e for


expansion
DME0 = 1
and DME1
space
is if
What m e m o r y available for expansion
S8. is
IN 8051 C
space dat=
What m e m o r y
59. MEMORY
RAM. The e x t e r n a l
DATA internal
to
data ROM
EXTERNAL

external
dat.
ACCESSING
from
S E C T I O N 14.5: of data The e x t e r n a l
transfer 20 bytes to
external
RAM.
in C to at 60H. data RAM
Write a program RAM starts internal
60. and internal
data from The exter
is 2000H, bytes of external
data RAM.
address t r a n s f e r 30 ROM to
m in S to arts at 40H. l data
ANSWERS TO REvIEW
QUESTIONS
SECTION 14.1: SEMIcONDUCTOR
C MEMORY
(a) 16Kx8, 128K bits
3. (a) 2Kx1, 21 bits (b) 64Kx8, 512K
(b) 8Kx4, 32K (c) 4Kx8, 32K
(d) 64Kx4, 256K (c) 128Kx8, 1M
(a) 64K bits, 14 address, (e) 256Kx1, 256K
and () 256Kx4, 1M
(c) 1M, 10 address, and 1 4 data (b) 256K, 15 address, and 8 data
(e) 512K, 16 address, and data
8 (d) 1M, 18 address, and 4 data
data
5. b, c () 4M, 10 address, and 4 data

GECTION 14.2: MEMORY ADDRESS DECODING


1. 16K bytes
2. 3,8
3. Both must be low.
4. Gl must be high.
5 5000H- 5FFFHH

GECTION 14.3: 8031 /51 INTERFACING WITH EXTERNAL ROM


1, From external ROM (that is off-chip)
2 From internal ROM (that is orn-chip)
3 PO

4 PO

5 PO
b. P2
7. True
DATA MEMORY SPACE
SECTION 14.4: 8051
1. 128K
External
3. True external data memory
we

but when accessing


program code,
used
4 True and are n e v e r
extermal ROM containing for external data memory
5. Only PSEN is
used to a c c e s s RD and WR are only
In other words,
must use RD and WR signals.
ROM.
for external program
False
7. True
Ity of the motor
or.

PROBLEMS
SECTION 17.1: RELAYS AND OPTOISOLATORS
1. Can a relay have normally open (NO) as well as normally closed (NC) contacts?
2. How does a reed switch work?

3 Give the advantages of a solid-state relay over an EM


relay.
4. In circuits with relays and microcontrollers, why are driver ICs used?
5. Find the current needed to energize a relay if the coil resistance is 1200 ohms and the coil voltage is 5 V.
6. Give two applications for an optoisolator.
7 Give the advantages of an optoisolator over an EM relay.
8. Of the EM relay and solid-state relay, which has the problem of back EMF?
9. True or false. The greater the coil resistance, the worse the back EMF voltage.
10. True or false. We should use the same voltage sources for both the coil voltage and contactvoltage

SECTION 17.2: STEPPER MOTOR INTERFACING


motor?
11. If a motor takes 90 steps to make one complete revolution, what is the step angle for this
12. Calculate the number of steps per revolution fora step angle of7.5 degrees.
motors popular?
13. For what kinds of applications are stepper
transistors in the Darlington configuration?
14. In Figure 17-11, is it mandatory to use
counterclockwise if the first step is 1001 (binary).
15. Finish the normal four-step sequence
counterclockwise if the first step is 0110 (binary).
16. Finish the normal four-step sequence motor? Can we use that for 3A
ULN2003 placed between the 8051 and the stepper
17. What is the purpose of the
motors? for a stepper motor?
18. Which of the following cannot be a sequence in the normal 4-step sequence
99H (d) 33H
(a) CCH (b) DDH (c)
between issuing each step?
19. What is the effect of a time delay
used?
20. In Figure 17-11, why are diodes

INTERFACING AND PWM


SECTION 17.3: DC MOTOR

21. Which motor is best for moving a wheel exactly 90 degrees? motor?
and current of a DC
between the load, torque,
2. What is the relationship for no-load and loaded.
of a DC motor is the same
3 True or false. The
in
rpm
data sheets is for
(no-load, loaded).
The rpm given motors over AC
motors?
45.What is the advantage of DC
over DC motors? fixed.
of stepper motors to the motor are
b. What is the advantage
motor slows it down if
the current and voltage supplied
DC
7. True or false. Higher load
on a
control automatically the speed
of a DC motor?
microcontroller be used to
26. How can a
451
AND STEPPER MOTORS
MOTOR CONTROL: RELAY, PWM, DC,
29. Name two microcontrollers with in-built PWM circuitry.
30. What is the
advantage of placing an optoisolator between the motor and the microcontroller?

ANSWERS TO REVIEW QUESTIONS


SECTION 17.1: RELAYS AND OPTOISOLATORS
1. Witha relay we can use a 5 V digital system to control 12 V-120 V devices such as horns and appliances
2. Since
3.
microcontroller/digital outputs lack sufficient current to energize the relay, we need a driver.
When the coil is not energized, the contact is closed.
4. When current flows through the coil, a
magnetic field is created around the coil, which causes the armature ta t
attracted to the coil. to be
5. It is faster and needs less current to
6.
get energized.
It is smaller and can be connected to the
microcontroller directly without a driver.
SECTION 17.2: STEPPER MOTOR INTERFACING
1. 0110, 0011, 1001, 1100 for clockwise; and 0110, 1100, 1001, 0011 for counterclockwise
2. 72
3. Because the microcontroller pins do not provide sufficient current to drive the stepper motor
SECTION 17.3: DC MOTOR INTERFACING AND PWM
1 True
2. False
3. Since microcontroller/digital
outputs lack sufficient current to drive the DC motor, we need a driver.
4. By reversing the
polarity voltages connected to the leads
of
5. The DC motor is stalled if the load is
beyond what it can handle
6. False
7. No-load

You might also like