8051_Parallel Sequence Detector
This project shows a parallel sequence detector using 8051. To simulate circuit
in this project, initially activate Mixed Mode simulator from the Schematic
Editor window. Simulation can be performed by selecting Run Transient analysis
(Oscillograph) from Simulation menu.
The circuit contains an 8051 chip, Parallel Pattern Generator with Interrupt,
Binary to 7-segment decoder and 7-Segment LED Displays. In this circuit, Port P0
and P1 of 8051 are assigned as input ports while Port P2 is assigned as output
port.
The
Parallel Pattern Generator with Interrupt
generates a parallel pattern when
Start Pattern button is enabled. This parallel pattern includes a data byte
along with an interrupt pulse. This interrupt pulse is given to the ‘INT0’ pin
of 8051.
On receiving the interrupt pulse at INT0 pin, the parallel pattern data at Port
P1 is compared with the data given at Port P0. The data given at Port P0 can be
edited as required. If the data bytes at P0 and P1are equal, then the byte at
Port P0 will be displayed in
7-segment form
at the output. Once a match is
identified and displayed, further matches will not be shown in the display.
The program is as shown:
#include <8051.h>
void myint_t0 () interrupt 0;
void main ()
{
EA = 1; // EA is set to enable all interrupts
EX0 = 1; // EX0 is set to enable external interrupt 0
P2 = 0x00; // Port 2 is assigned as output port
for( ; ; ) // Infinite loop
{
}
}
void myint_t0 () interrupt 0
{
int i; // Declaring a variable ‘i’
i = P1; // Data at P1 is assigned to the declared variable
if (P0 == i) // Checks whether ‘i’ is equal to the data at P0
{
P2 = i; // If both the bytes are equal, the data in ‘i’ is copied to P2
}
}
The source code in the
code editor window
has to be
compiled
after making any modifications
(editing).
Also the code can be
debugged
during
simulation.