M&M 3160904 LabManual Latest
M&M 3160904 LabManual Latest
M&M 3160904 LabManual Latest
INDEX
Sr. Page CO
Description Remarks / Sign
No. No. conformity
Microprocessor Microcontroller
General purpose processor Specific application controller
Contains RAM, ROM, I/O ports on the chip
Does not contain RAM, ROM, I/O ports on the chip
itself
Cannot be used as stand alone Can be used as stand alone
Overall system is bulkier and costly Overall system is compact and cheap
Less bit handling instructions More bit handling instructions
Less number of pins are multiplexed More number of pins are multiplexed
More flexible for designing Less flexibility
More GPRs and addressing modes Less GPRs and addressing modes
Execution is faster Comparatively slower
Von Neumann model - data and instructions share Havard model - data and instructions have
memory separate memory
Inefficient for compact systems Suitable for compact systems
May or may not be Real time application oriented Real time application oriented
Accumulator
It is an 8-bit register used to perform arithmetic, logical, I/O & LOAD/STORE operations. It is
connected to internal data bus & ALU.
As the name suggests, it performs arithmetic and logical operations like Addition, Subtraction, AND,
OR, etc. on 8-bit data.
There are 6 general purpose registers in 8085 processor, i.e. B, C, D, E, H & L. Each register can
hold 8-bit data.
These registers can work in pair to hold 16-bit data and their pairing combination is like B-C, D-E &
H-L.
Program counter
It is a 16-bit register used to store the memory address location of the next instruction to be
executed. Microprocessor increments the program whenever an instruction is being executed, so
that the program counter points to the memory address of the next instruction that is going to be
executed.
Stack pointer
It is also a 16-bit register works like stack, which is always incremented/decremented by 2 during
push & pop operations.
Temporary register
It is an 8-bit register, which holds the temporary data of arithmetic and logical operations.
Flag register
It is an 8-bit register having five 1-bit flip-flops, which holds either 0 or 1 depending upon the result
stored in the accumulator.
These are the set of 5 flip-flops −
Sign (S)
Zero (Z)
Auxiliary Carry (AC)
Parity (P)
Carry (C)
Its bit position is shown in the following table −
D7 D6 D5 D4 D3 D2 D1 D0
It is an 8-bit register. When an instruction is fetched from memory then it is stored in the Instruction
register. Instruction decoder decodes the information present in the Instruction register.
It provides timing and control signal to the microprocessor to perform operations. Following are the
timing and control signals, which control external and internal circuits −
Interrupt control
As the name suggests it controls the interrupts during a process. When a microprocessor is
executing a main program and whenever an interrupt occurs, the microprocessor shifts the control
from the main program to process the incoming request. After the request is completed, the control
goes back to the main program.
There are 5 interrupt signals in 8085 microprocessor: INTR, RST 7.5, RST 6.5, RST 5.5, TRAP.
It controls the serial data communication by using these two instructions: SID (Serial input data) and
SOD (Serial output data).
The content stored in the stack pointer and program counter is loaded into the address buffer and
address-data buffer to communicate with the CPU. The memory and I/O chips are connected to
these buses; the CPU can exchange the desired data with the memory and I/O chips.
Data bus carries the data to be stored. It is bidirectional, whereas address bus carries the location to
where it should be stored and it is unidirectional. It is used to transfer the data & Address I/O
devices.
Address bus
Data bus
AD7-AD0, it carries the least significant 8-bit address and data bus.
These signals are used to identify the nature of operation. There are 3 control signal and 3 status
signals.
Three control signals are RD, WR & ALE.
RD − This signal indicates that the selected IO or memory device is to be read and is ready
for accepting data available on the data bus.
WR − This signal indicates that the data on the data bus is to be written into a selected
memory or IO location.
IO/M - This signal is used to differentiate between IO and Memory operations, i.e. when
it is high indicates IO operation and when it is low then it indicates memory operation.
S1 & S0 - These signals are used to identify the type of current operation.
Power supply
There are 2 power supply signals − VCC & VSS. VCC indicates +5v power supply and VSS
indicates ground signal.
Clock signals
Interrupts are the signals generated by external devices to request the microprocessor to perform a
task. There are 5 interrupt signals, i.e. TRAP, RST 7.5, RST 6.5, RST 5.5, and INTR. We will
discuss interrupts in detail in interrupts section.
INTA − It is an interrupt acknowledgment signal.
RESET IN − This signal is used to reset the microprocessor by setting the program counter
to zero.
RESET OUT − This signal is used to reset all the connected devices when the
microprocessor is reset.
READY − This signal indicates that the device is ready to send or receive data. If READY is
low, then the CPU has to wait for READY to go high.
HOLD − This signal indicates that another master is requesting the use of the address and
data buses.
HLDA (HOLD Acknowledge) − It indicates that the CPU has received the HOLD request
and it will relinquish the bus in the next clock cycle. HLDA is set to low after the HOLD signal
is removed.
There are 2 serial signals, i.e. SID and SOD and these signals are used for serial communication.
SOD (Serial output data line) − The output SOD is set/reset as specified by the SIM
instruction.
SID (Serial input data line) − The data on this line is loaded into accumulator whenever a
RIM instruction is executed.
8051 microcontroller is designed by Intel in 1981. It is an 8-bit microcontroller. It is built with 40 pins
DIP (dual inline package), 4kb of ROM storage and 128 bytes of RAM storage, 2 16-bit timers. It
consists of are four parallel 8-bit ports, which are programmable as well as addressable as per the
requirement. An on-chip crystal oscillator is integrated in the microcontroller having crystal
frequency of 12 MHz.
The system bus connects all the support devices to the CPU. The system bus consists of an 8-bit
data bus, a 16-bit address bus and bus control signals. All other devices like program memory, ports,
data memory, serial interface, interrupt control, timers, and the CPU are all interfaced together
through the system bus.
8051 has 8-bit ALU which can perform all the 8-bit arithmetic and logical operations in one
machine cycle. The ALU is associated with two registers A & B
A and B Registers : The A and B registers are special function registers which hold the results
of many arithmetic and logical operations of 8051. The A register is also called the
The R registers: The "R" registers are a set of eight registers that are named R0, R1, etc. up
to and including R7. These registers are used as auxiliary registers in many operations. The
"R" registers are also used to temporarily store values.
Program Counter(PC) : 8051 has a 16-bit program counter .The program counter always
points to the address of the next instruction to be executed. After execution of one instruction
the program counter is incremented to point to the address of the next instruction to be
executed.It is the contents of the PC that are placed on the address bus to find and fetch the
desired instruction.Since the PC is 16-bit width ,8051 can access program addresses from
0000H to FFFFH, a total of 6kB of code.
Stack Pointer Register (SP) : It is an 8-bit register which stores the address of the stack top.
i.e the Stack Pointer is used to indicate where the next value to be removed from the stack
should be taken from. When a value is pushed onto the stack, the 8051 first increments the
Data Pointer Register(DPTR) : It is a 16-bit register which is the only user-accessible. DPTR,
as the name suggests, is used to point to data. It is used by a number of commands which
allow the 8051 to access external memory. When the 8051 accesses external memory it will
access external memory at the address indicated by DPTR. This DPTR can also be used as
two 8-registers DPH and DPL.
Program Status Register (PSW) : The 8051 has a 8-bit PSW register which is also known as
Flag register. In the 8-bit register only 6-bits are used by 8051.The two unused bits are user
definable bits.In the 6-bits four of them are conditional flags. They are Carry –CY, Auxiliary
Carry-AC, Parity-P and Overflow-OV. These flag bits indicate some conditions that resulted
after an instruction was executed.
D7 D6 D5 D4 D3 D2 D1 D0
CY AC F0 RS1 RS0 OV -- P
The bits PSW3 and PSW4 are denoted as RS0 and RS1 and these bits are used th select the
bank registers of the RAM location. The meaning of various bits of PSW register is shown
below.
The selection of the register Banks and their addresses are given below.
RS1 RS0 Register Bank Address
0 0 0 00H-07H
0 1 1 08H-0FH
1 0 2 10H-17H
1 1 3 18H-1FH
Pins 18 & 19 − These pins are used for interfacing an external crystal to get the system
clock.
Pin 20 − This pin provides the power supply to the circuit.
Pins 21 to 28 − These pins are known as Port 2. It serves as I/O port. Higher order address
bus signals are also multiplexed using this port.
Pin 29 − This is PSEN pin which stands for Program Store Enable. It is used to read a signal
from the external program memory.
Pin 30 − This is EA pin which stands for External Access input. It is used to enable/disable
the external memory interfacing.
Input Configuration
If any pin of this port is configured as an input, then it acts as if it “floats”, i.e. the input has unlimited
input resistance and in-determined potential.
Output Configuration
When the pin is configured as an output, then it acts as an “open drain”. By applying logic 0 to a port
bit, the appropriate pin will be connected to ground (0V), and applying logic 1, the external output
will keep on “floating”.
In order to apply logic 1 (5V) on this output pin, it is necessary to build an external pullup resistor.
Port 1
P1 is a true I/O port as it doesn’t have any alternative functions as in P0, but this port can be
configured as general I/O only. It has a built-in pull-up resistor and is completely compatible with
TTL circuits.
Port 2
P2 is similar to P0 when the external memory is used. Pins of this port occupy addresses intended
for the external memory chip. This port can be used for higher address byte with addresses A8-A15.
When no memory is added then this port can be used as a general input/output port similar to Port
1.
In this port, functions are similar to other ports except that the logic 1 must be applied to appropriate
bit of the P3 register.
The 8051 code(program) memory is read-only, while the data memory is read/write
accessible. The program memory( in EPROM) can be rewritten by the special programmer
circuit.
The 8051 memory is organized in a Harvard Architecture. Both the code memory space and
data memory space begin at location 0x00 for internal or external memory which is different
from the Princeton Architecture where code and data share same memory space.
The advantage of the Harvard Architecture is not only doubling the memory capacity of the
microcontroller with same number of address lines but also increases the reliability of the
microcontroller, since there are no instructions to write to the code memory which is read only.
This Internal RAM is found on-chip on the 8051 .So it is the fastest RAM available, and it is also the
most flexible in terms of reading, writing, and modifying it’s contents. Internal RAM is volatile, so
when the 8051 is reset this memory is cleared. The 128 bytes of internal RAM is organized as
below.
Internal ROM (On –chip ROM): The 8051 microcontroller has 4kB of on chip ROM but it can be
extended up to 64kB.This ROM is also called program memory or code memory. The CODE
segment is accessed using the program counter (PC) for opcode fetches and by DPTR for data.
The external ROM is accessed when the EA (active low) pin is connected to ground or the contents
of program counter exceeds 0FFFH. When the Internal ROM address is exceeded the 8051
automatically fetches the code bytes from the external program memory.
SPECIAL FUNCTION REGISTERS (SFRs) : In 8051 microcontroller there certain registers which
uses the RAM addresses from 80h to FFh and they are meant for certain specific operations .These
registers are called Special function registers (SFRs). Some of these registers are bit addressable
also. The list of SFRs and their functional names are given below. In these SFRs some of them are
related to I/O ports (P0, P1, P2 and P3) and some of them are meant for control operations (TCON,
SCON, PCON..) and remaining are the auxilary SFRs, in the sense that they don't directly configure
the 8051.
2. Write and ALP to copy the contents of external data memory location pointed by DPTR to
internal data memory location pointed by R0
4. Write an ALP to add contents of A with the contents of R2 and store the result in A
5. Write an ALP to subtract contents of R2 from the contents of A and store the result in A
6. Write an ALP to multiply contents of register B with the contents of A and store the result in
locations 50H and 51H (LSB is stored in 50H)
7. Write an ALP to divide contents of register A by the contents of B and store the result in locations
60H and 61H
11. Write an ALP to swap the upper and lower nibble of 20H
14. Write an ALP to compare contents of A with contents of 20H. If contents are equal, store 00H
in 21H, else store FFH in 21H
1. Write an ALP to add two 8 bit numbers and store the 16 bit results in 20H and 21H
2. Write an ALP to add two 16 bit numbers stored in 51H-52H and 61H-62H and store the results in
20H, 21H and 22H
3. Write an ALP to subtract two 16 bit numbers stored in 51H-52H from 61H-62H and store the
results in 20H and 21H. If result is positive store 00H else store 01H in 25H
6. Write an ALP to add 1+2+3+……+N (say 10) and save the sum at 20H
7. Write an ALP to count the number of 1’s and 0’s of 8 bit data stored in A
8. N 8 bit numbers are stored in internal data memory. Write an ALP to arrange the numbers in
descending order
9. Write an ALP to create a delay of 1ms. Assume the oscillator frequency to be 12Mhz
To create a delay of 1ms, the program must be executed 125 times = 1ms/8μs = 1000μs/8μs =
125
Program to create a delay of 1ms is as follows:
Actual time is 2μs more than 1ms. This is the overhead fro setting up the delay loop.
10. Find the time delay for the following subroutine, assuming a crystal frequency of 11.0592MHz
C PROGRAM:
#include<reg51.h>
void main()
{
unsigned char a;
a = 0x0C; //initialize a variable hex value
P0 = a; //send hex number to port 0
}
2. Write a ‘C’ program to toggle bits of P1 continuously for 100 times with time delay of 1sec
#include<reg51.h>
void main()
{
int i=0, j=0;
while (j < 100)
{
P1=0xFF;
for(i=0; i<10000; ++i);
P1=0x00;
for(i=0; i<10000; ++i);
j++;
}
}
3. Write a ‘C’ program to generate a square wave of 3s on time, 50% duty cycle on P1.2
Ton
Duty Cycle D = Ton + Toff
= 50% = 0.5
3s
0.5 = 3s+Toff
3s + Toff = 6s
���� = 3�
#include<reg51.h>
void delay(unsigned int);
void main()
4. Write a ‘C’ program to toggle all pins of P0 for every 1 sec using NOT operation
#include<reg51.h>
void delay(unsigned int);
void main()
{
P0 = 0x55;
while(1)
{
P0=~P0;
delay(1000);
}
}
5. Write a ‘C’ program to convert packed BCD 0x29 to unpacked BCD 0x02 and 0x09
#include<Intel\8051.h>
void main()
{
unsigned char x, y;
unsigned char no;
x = no&0x0F;
P1 = x;
6. Write a ‘C’ program to get data from P1.2, invert it and send it to P2.0, 8 times
#include<reg51.h>
sbit inbit = P1^2;
sbit outbit = P2^7;
bit tempbit;
void main()
{
int i;
for(i=0; i<8; ++i)
{
tempbit = inbit;
outbit = ~tempbit;
}
}
7. Write a ‘C’ program to check P1.5. If P1.5 =1, send FFH to P0, else send 00H to P0
#include<reg51.h>
void main()
{
while(1)
{
if(P1^5==1)
P0=0xFF;
else
P0=0x00;
}
}
This language is a high level language. This language is a low level language.
Embedded ‘C’ is fixed.
If the controller is changed, it also changes.
If controller changes, it is not changed.
How many data will be used in How much memory will be used in
program will be known . program isnot known.
Assembly language produces smaller file Embedded ‘C’ produces larger file than
thanEmbedded ‘C’ . assembly.
Programming in assembly is more tedious & Programming in ‘C’ is less tedious & less time
more time consuming. consuming.
It is not easy to modify and update. It is easier to modify and update.
It is not portable to other micro controllers It is portable to other micro controllers
even with modification. with little modification.
Programming in assembly does not require Programming in ‘C’ requires a compiler
a compiler to convert it in to machine language. to convert it in to machine language.
Working as a “Timer”, the timer is incremented by one every machine cycle. A machine cycle
consists of 12 oscillator periods, so the count rate is 1/12 of the oscillator frequency.
Working as a “Counter”, the counter is incremented in response to a falling edge transition in the
external input pins.
The external input is sampled once every machine cycle. A “high” sample followed by a low
sample is counted once.
Timer 0 and Timer 1 have four operating modes.
D5 / D1 M1
Mode select bits
D4 / D0 M0
TF0/TF1: Timer0/1 overflow flag is set when the timer/ counter overflows, reset by program
TR0/TR1: Timer0/1 run control bit is set to start, reset to stop the timer0/1
IE0/IE1: External Interrupt 0/1 edge detected flag: 1 is set when a falling edge interrupt on the
external port 0/1, reset(cleared) by hardware itself for falling edge transition activated INT; Reset
by code for low level INT.
IT0/IT1External InterruptType (1:falling edge triggered,0 low level triggered)
-------------------------------------------------------------------------------------------------------------------------------
1. PROGRAM TO VERIFY TIMER-1 COUNTER MODE:
Solution:-
CLR A
MOV A, TMOD (TMOD=89)
ORL A,#50H
MOV TMOD,A
SETB TR1 (TR1=8E)
LOOP LCALL 68EAH
MOV DPTR,#0194H
MOV A,TL1 (TL1=8B)
MOVX @DPTR,A
INC DPTR
MOV A,TH1 (TH1=8D)
MOVX @DPTR,A
LCALL 6748H
SJMP LOOP
Solution:-
11.0592 1
= 921.6 ���; � = = 1.085μs
12 921.6
3. GENERATE A TIME DELAY OF 5μsec USING TIMER0 MODE 1 WITH XTAL = 22MHz
Solution:-
22 1
= 1.833 ���; � = = 0.546μs
12 1.833
Pulse period
Initial count value = Maximum value −
Clock period
5μs
= 65535 − 0.546μs
= 65535 - 9
= 65527 (in decimal)
= FFF7 (in Hex)
#include<reg51.h>
void main()
{
TMOD = 0x01;
while(1)
{
TL0 = 0xF7;
TH0 = 0XFF;
TR0 = 1;
while (TF0 = = 0);
TR0 = 0;
TF0 = 0;
}
}
Aim:- Serial Port Mode Operation and PCON register of Microcontroller 8051
Cheaper Costlier
SOLUTION:
k × Oscillator Frequency 1× 11.0592 ×106
TH1 = 256 − 384 × Baud Rate
= 256 − 384 × 9600
= 253 = FDH
2. WRITE AN 8051 ALP TO SERIALLY TRANSMIT LETTER “Y” AT 9600 BAUD RATE
CONTINUOUSLY
SOLUTION:
#include<reg51.h>
void main (void)
{
TMOD = 0x20;
TH1 = 0xFD;
SCON = 0x50;
TR1 = 1;
while(1)
{
SBUF = ‘Y’;
while(TI == 0);
TI = 0;
}
}
3. WRITE AN 8051 ALP TO SERIALLY TRANSMIT LETTER “HELLO” AT 9600 BAUD RATE
CONTINUOUSLY (8 bit data, 1 stop bit)
SOLUTION:
#include<reg51.h>
void stx (unsigned char);
void main ()
{
TMOD = 0x20;
TH1 = 0xFD;
SCON = 0x50;
TR1 = 1;
while(1)
{
stx(‘H’);
stx(‘E’);
stx(‘L’);
stx(‘L’);
stx(‘O’);
}
}
LCD display is an inevitable part in almost all embedded projects and this article is about interfacing
16×2 LCD with 8051 microcontroller. Many guys find it hard to interface LCD module with the 8051
but the fact is that if you learn it properly, its a very easy job and by knowing it you can easily design
embedded projects like digital voltmeter / ammeter, digital clock, home automation displays, status
indicator display, digital code locks, digital speedometer/ odometer, display for music players etc
etc. Thoroughly going through this article will make you able to display any text (including the
extended characters) on any part of the 16×2 display screen. In order to understand the interfacing
first you have to know about the 16×2 LCD module.
The JHD162A has two built in registers namely data register and command register. Data register
is for placing the data to be displayed , and the command register is to place the commands. The
16×2 LCD module has a set of commands each meant for doing a particular job with the display.
We will discuss in detail about the commands later. High logic at the RS pin will select the data
register and Low logic at the RS pin will select the command register. If we make the RS pin high
and the put a data in the 8 bit data line (DB0 to DB7) , the LCD module will recognize it as a data to be
displayed . If we make RS pin low and put a data on the data line, the module will recognize it as a
command.
R/W pin is meant for selecting between read and write modes. High level at this pin enables read mode
and low level at this pin enables write mode.
E pin is for enabling the module. A high to low transition at this pin will enable the module.
DB0 to DB7 are the data pins. The data to be displayed and the command instructions are placed on
these pins.
LED+ is the anode of the back light LED and this pin must be connected to VCC through a suitable
series current limiting resistor. LED- is the cathode of the back light LED and this pin must be
connected to ground.
Command Function
0F LCD ON, Cursor ON, Cursor blinking ON
01 Clear screen
02 Return home
04 Decrement cursor
06 Increment cursor
0E Display ON ,Cursor blinking OFF
LCD initialization
The steps that has to be done for initializing the LCD display is given below and these steps are common
for almost all applications.
The steps for sending data to the LCD module is given below. I have alreadysaid thattheLCD modulehas
pins namely RS, R/W and E. It is the logic state of these pins that make the module to determine
whether a given data input is a command or data to be displayed.
1. WRITE AN 8051 ALP TO MULTIPLEX THE NUMBER 1234 ON THE FOUR 7-SEGMENT
DISPLAYS
SOLUTION:
start:
SETB P3.3
SETB P3.4
MOV P1, #11111001B
CALL delay
CLR P3.3
MOV P1, #10100100B
CALL delay
CLR P3.4
SETB P3.3
MOV P1, #10110000B
CALL delay
CLR P3.3
MOV P1, #10011001B
CALL delay
JMP start
delay:
MOV R0, #20
here:DJNZ R0, here
RET
CLR P1.3
CLR P1.7
CLR P1.6
SETB P1.5
CLR P1.4
CALL delay
SETB P1.2
CLR P1.2
SETB P1.7
SETB P1.2
CLR P1.2
CALL delay
CLR P1.7
CLR P1.6
CLR P1.5
CLR P1.4
SETB P1.2
CLR P1.2
SETB P1.6
SETB P1.5
SETB P1.2
CLR P1.2
CALL delay
CLR P1.7
CLR P1.6
CLR P1.5
CLR P1.4
SETB P1.2
CLR P1.2
SETB P1.7
SETB P1.6
SETB P1.5
SETB P1.4
SETB P1.2
CLR P1.2
CALL delay
CALL sendCharacter
INC R1
JMP loop
finish:
ret
sendCharacter:
MOV C, ACC.7
MOV P1.7, C
MOV C, ACC.6
MOV P1.6, C
MOV C, ACC.5
MOV P1.5, C
MOV C, ACC.4
MOV P1.4, C
SETB P1.2
CLR P1.2
MOV C, ACC.3
MOV P1.7, C
MOV C, ACC.2
MOV P1.6, C
MOV C, ACC.1
MOV P1.5, C
MOV C, ACC.0
MOV P1.4, C
SETB P1.2
CLR P1.2
CALL delay
delay:
MOV R0, #20
here: DJNZ R0, here
RET
This program exercises the motor. The motor is rotated in a clockwise direction and the number
of revolutions is displayed on Display 0 (the 7-segment ; display). The display only shows up to
nine revolutions and then resets.
The motor sensor is connected to P3.5, which is the external clock source for timer 1. Therefore,
timer 1 is put into event counting mode. In this way, the timer increments once every motor
revolution is completed.
The value in timer 1 low byte is moved to A and this value together with the data pointer (DPH
and DPL) are used to get the 7-segment code from program memory. The code is then sent to
P1 to put the appropriate number on the Display 0.
The motor can be changed from clockwise to anti-clockwise by pressing SW0 (on P2.0). The
motor direction is stored in F0 (1 for clockwise, 0 for anti-clockwise). The value in F0 is sent to
Display 0's decimal point (P1.7). This indicates the motor's direction - if the decimal point is lit,
the motor is rotating anti-clockwise, while if it is not lit the motor is rotating clockwise.
The value in F0 is compared with the value of SW0. If they are the same the motor direction does
not need to be changed. If they are not the same it means the user has pressed SW0 and the
motor direction must be reversed. When this happens the new motor direction is then stored in
F0.
CLR P3.4
CLR P3.3
again:
CALL setDirection
MOV A, TL1
CJNE A, #10, skip
CALL clearTimer
skip:
MOVC A, @A+DPTR
MOV C, F0
MOV ACC.7, C
MOV P1, A
JMP again
setDirection:
PUSH ACC
PUSH 20H
CLR A
MOV 20H, #0
changeDir:
CLR P3.0
CLR P3.1
CALL clearTimer
MOV C, P2.0
MOV F0, C
MOV P3.0, C
CPL C
MOV P3.1, C
finish:
POP 20H
POP ACC
RET
clearTimer:
CLR A
CLR TR1
MOV TL1, #0
SETB TR1
RET
Note: The above program is a good illustration of what can go wrong if the sampling frequency is
too low. Try running the program with the motor at full speed (use the slider to the right of the motor
to increase the motor speed). You should notice the motor completes a number of revolutions
before the display updates. In other words, the motor's highest speed is too fast for the 8051
running at system clock of 12 MHz.
Since the program only shows up to nine revolutions (displayed on the 7-segment display) and
then starts counting again, it is best to run this program with an Update Freq. of 1. This allows the
user observe the display count up from 0 to 9 and back to 0 again. It also illustrates the delay
between the motor arm passing the sensor and the display update. Similarly, the delay between
pressing the switch for a direction change and the actual direction change occurring is
evident. The student will learn that, while in real time these delays are not noticeable, to the
microcontroller these operations take quite some time.