Академический Документы
Профессиональный Документы
Культура Документы
E A, which stands for external access is pin no. 31 in the DI pacages. It is an input pin
and must be connected to either Vcc or ground. In other words, it cannot be left
unconnected in the 8051 family memers. The E A pin is connected to Vcc in our case.
5
This is an output pin. SE stands for program store enale. This is left unconnected in
8051 microcontroller. This pin remains connected in 8031 based systems.
2.5.8 ALE
Address latch enale is an output pin and is active high. This pin is not used in the 8051
microcontroller.
2.6 Application Concerned Programming
2.6.1 I/O Port Programming
The four ports P0, P1, P2 and P3 are the 8 bit ports. All the ports upon RESET have value
FFH on them and are configured as inputs. They are then ready to be used as input ports.
When the first 0 is written to a port, it becomes an output. To reconfigure it as an input, a
1 must be sent to the port. To use any of these ports as an input port, it must be
programmed by writing 1 to all the bits.
I/O ports and bit addressability
We can access either the entire 8 bits of an I/O port. Or we can access individually 1 bit at
a time. A powerful feature of 8051 I/O ports is their capability to access individual bits of
the port without altering the rest of the bits in that port. In this case we simply use the
syntax SETB .Y where is the port numer and Y is the desired it numer (0 to 7) for
data bits D0 to D7. Table 2.5 shows the single bit addressability of the I/O ports of 8051.
Switch Matrix Controller LRDE, DRDO
Tezpur University 15 June-July,2012
P0 P1 P2 P3 Port bit
P0.0 P1.0 P2.0 P3.0 D0
P0.1 P1.1 P2.1 P3.1 D1
P0.2 P1.2 P2.2 P3.2 D2
P0.3 P1.3 P2.3 P3.3 D3
P0.4 P1.4 P2.4 P3.4 D4
P0.5 P1.5 P2.5 P3.5 D5
P0.6 P1.6 P2.6 P3.6 D6
P0.7 P1.7 P2.7 P3.7 D7
Table 2.5 Single bit addressability of I/O ports
2.6.2 Timer Programming
The 8051 has two timers: timer 0 and timer 1. They can be used either as timer or as event
counters. Both timer 0 and timer 1 are 16 bits wide. Since the 8051 has an 8-bit
architecture, each 16-bit timer is accessed as two separate registers of low byte and high
byte.
Timer 0 registers
The 16-bit register of timer 0 is accessed as low byte and high byte. The low byte register is
called TL0 (timer 0 low byte) and the high byte register is referred to as TH0 (timer 0 high
byte). These registers accessed like any other registers, such as A, B, R0, R1, R2 etc. These
registers can also be read like any other registers.
Timer 1 registers
Timer 1 is also a 16 bit register, and it is split into two bytes, referred to as TL1 (Timer 1
low byte) and TH1 (Timer 1 high byte). These registers are accessible in the same way the
as the timer 0 registers.
Fig 2.9 and fig 2.10 show the timer 0 and timer 1 registers respectively.
Switch Matrix Controller LRDE, DRDO
Tezpur University 16 June-July,2012
Fig 2.9 Timer 0 register
Fig 2.10 Timer 1 register
TMOD (Timer mode) register
Both timer 0 and timer 1 use the same register, called TMOD, to set the various timer
operation modes. TMOD is an 8-bit register in which the lower 4 bits are set aside for
Timer 0 and upper 4bits for timer 1. In this case, the lower 2 bits are used to set the timer
mode and the upper 2 bits to specify the operation. Fig 2.8 shows the TMOD register.
Fig 1.11 TMOD register
GATE
In the TMOD register both the timer 0 and timer 1 have the GATE bit. Every timer has a
means of starting and stopping. Some timers do this by software, some by hardware and
some by both hardware and software controls. The timer in the 8051 has both. The start
and stop of the timer are controlled by way of software by the TR (timer start) bits TR0 and
TR1. The SETB instruction starts it, and it is stopped by the CLR instruction. These
instructions start the timers as long as GATE= 0 in the TMOD register. The hardware way of
Switch Matrix Controller LRDE, DRDO
Tezpur University 17 June-July,2012
starting and stopping the timer by an external source is achieved by making GATE= 1 in the
TMOD register.
C/T (Clock/timer)
This bit in the TMOD register is used to decide whether the timer is used as a delay
generator or an event counter. If C/T = 0, it is used as timer for time delay generation. If
the C/T = 1, the TMOD register is used as an event counter. The clock source for the time
delay is the crystal frequency of the 8051. The size of the crystal frequency attached to the
8051 also decides the speed at which the 8051 timer ticks. The frequency for the timer is
always 1/12
th
of the frequency of the crystal attached to the 8051.Although various 8051
based systems have an XTAL frequency in the range 10 MHz to 40 MHz, we will
concentrate on the XTAL frequency of 11.0592 MHz. The reason behind such an odd
number has to do with the baud rate for serial communication of the 8051.
M0, M1
The M0 and M1 select the timer mode. There are three modes: 0, 1 and 2. Table 2.6
describes the various timer modes. We will concentrate on mode 1 and mode 2 since they
are the ones used most widely. In our case the mode 2 has been used.
M1 M0 Mode Operating mode
0 0 0 13-bit timer mode
8-bit timer/counter THx with TLx as 5-bit
prescaler
0 1 1 16-bit timer mode
16-bit timer/counter THx and TLx are cascaded;
there is no prescaler
1 0 2 8 bit auto reload
8-bit timer/counter; THx holds a value that is to
be reloaded into TLx each time it overflows.
1 1 3 Split timer mode
Table 2.6 Timer modes
TCON register
Switch Matrix Controller LRDE, DRDO
Tezpur University 18 June-July,2012
While the TMOD register controls the timer mode, another register called the TCON
controls the timer/counter operations. The lower four bits of TCON is used for interrupt
functions, and the upper four bits are for timer operations. Fig 2.12 shows the details of
the TCON register.
Fig 2.12 TCON register
Mode 2 programming
The mode 2 operations of the timer are described below.
It is an 8-it timer; therefore it allows only alues of 00 to H to e loaded into the timers
register TH.
After TH is loaded with the 8-bit value, the 8051 gives a copy of it to TL. Then the timer is
started. This is done y the instruction SETB TR0 for timer 0 and SETB TR1 for timer 1.
After the timer is started, it starts to count up by incrementing the TL registers. It counts
up until it reaches its limit of FFH. When it rolls over from FFH to 00, it sets high the TF
(timer flag). If we are using timer 0, TF0 goes high. If we are using timer 1, TF1 is raised.
When the TL resister rolls from FFH to 00 and the TF is set to 1, TL is reloaded
automatically with the original value kept by the TH register. To repeat the process, we
have to simply clear the TF and let it go without any need by the programmer to reload the
original value. This makes mode 2 auto reload.
Switch Matrix Controller LRDE, DRDO
Tezpur University 19 June-July,2012
Fig 2.13 Mode 2 programming
2.6.3 Serial Port Programming
RxD and TxD pins in the 8051
The 8051 has 2 pins that are used specifically for transferring and receiving data serially.
These two pins are called TxD and RxD and part of the port 3 group (P3.0 and P3.1). Pin 11
of the 8051 (P3.0) is assigned to the TxD and pin 10 (P3.0) is designated as RxD. These pins
are TTL compatible. The serial communication is discussed in the next chapter in details.
In this section we discuss the serial communication registers of the 8051 and how to
program them to transmit and receive data serially. The IBM PC compatible computers are
widely used to communicate with 8051 based systems. To allow data transfer between the
COM port of the PC and an 8051 system without any error, we must make sure that the
baud rates of 8051 matches the aud rate of Cs COM port.
Baud rate in 8051
The 8051 transmit and receive data serially at different baud rates. The baud rate in the
8051 is programmable. This is done with the help of Timer 1.
As discussed in the above section, the 8051 divides the crystal frequency by 12 to get the
machine cycle frequency. In the case of XTAL= 11.0592 MHz, the machine cycle frequency
is 91.6 Hz. The 8051s serial communication UART circuitry diides the machine cycle
frequency of 921.6 kHz by 32 once more before it is used by the timer 1 to set the baud
rate. This gives 28800 Hz. When the Timer 1 is used to set the baud rate it must be
programmed in mode 2, i.e. 8-bit, auto reload. To get baud rate compatible with the PC,
we must load the TH1 with the values shown in table 2.7.
Switch Matrix Controller LRDE, DRDO
Tezpur University 20 June-July,2012
Baud rate TH1 (Decimal) TH1 (hex)
9600 -3 FD
4800 -6 FA
2400 -12 F4
1200 -24 E8
Table 2.7 The Timer 1 TH1 register values for different baud rates
Fig 2.14 setting the frequency
SBUF Register
SBUF is an 8-bit register used solely for serial communication in the 8051. For a byte of
data to be transferred via the TxD line, it must be placed in the SBUF register. The moment
a byte is written into the SBUF, it is framed with the start and stop bits and transferred
serially via the TxD pin. Similarly, SBUF holds the byte of data when it is received by the
8051s RxD line. The 8051 deframes the its y eliminating the stop and start its and then
placing it in the SBUF. The SBUF can be accessed like any other registers in the 8051.
SCON (Serial control) register
The SCON register is an 8-bit register used to program the start bit, stop bit and data bits
of data framing. Fig 2.12 shows the various bits of the SCON register.
Fig 2.15 SCON register
Switch Matrix Controller LRDE, DRDO
Tezpur University 21 June-July,2012
SM0, SM1
SM0 and SM1 are D7 and D6 of the SCON register, respectively. That is, SCON.7 and
SCON.6 (since SCON is bit addressable). These two bits determine the framing of data by
specifying the number of bits per character, and the start and stop bits. They take the
following combinations:
SM0 SM1 Modes
0 0 Serial mode 0
0 1 Serial mode 1, 8-bit data, 1 stop bit and 1 start bit
1 0 Serial mode 2
1 1 Serial mode 3
Table 2.8 serial communication modes
Of the 4 serial modes, only mode 1 is of interest of us. In the SCON register when serial
mode 1 is chosen, the data framing is 8 bits, 1 start bit and 1 stop bit. This makes it
compatible with the COM port of the PC. Most importantly, serial mode 1 allows the baud
rate to be variable and set by Timer 1 of 8051.
SM2
SM2 is the D5 of the SCON register (SCON.5). This bit enables the multiprocessing
capability of the 8051.
REN
The REN (receive enable) bit is D4 of the SCON register (SCON.4). When this bit is high, it
allows the 8051 to receive data on the RxD pin. As a result if we want the 8051 to both
transfer and receive data, the REN must be set to 1. By making REN= 0, the receiver is
disabled.
TB8
TB8 (transfer bit 8) is bit D3 of the SCON (SCON.3). It is used for serial modes 2 and 3.
RB8
Switch Matrix Controller LRDE, DRDO
Tezpur University 22 June-July,2012
RB8 (transfer bit 8) is the bit D2 of the SCON (SCON.2). In serial mode 1 this bit gets a copy
of the stop bit when an 8-bit data is received. In our application we will make RB8 = 0 as
this bit is rarely used anymore.
TI
TI (transmit interrupt) is the bit D1 (SCON.1) and an extremely important flag bit in the
SCON register. When the 8051 finishes the transfer of 8-bit character, it raises the TI flag to
indicate that it is ready to transfer another byte. The TI bit is raised at the beginning of the
stop bit.
RI
RI (receive interrupt) is the bit 0 (SCON.0) of the SCON register. When the 8051 receive
data serially via RxD, it places the byte in the SBUF register. Then it raises the RI flag bit to
indicate that a byte has been received and should be picked up before it is lost. The RI is
raised halfway through the stop bit.
Programming the 8051 to transfer data serially
In programming the 8051 to transfer character bytes serially, the following steps are
taken:
1. The TMOD register is loaded with the value 20H, indicating the use of Timer 1 in mode
2 (8-bit auto reload) to set baud rate.
2. The TH1 is loaded with one of the values in the table 2.7 to set the baud rate for serial
data transfer (assuming XTAL= 11.0592 MHz).
3. The SCON register is loaded with the value 50H, indicating serial mode 1, where an 8
bit data is framed with start and stop bit.
4. TR1 is set to 1 to start the timer 1.
5. TI bit is cleared.
6. The character byte to be transferred serially is written into the SBUF register.
7. The TI bit is monitored to see if the character has been transferred completely.
8. To transfer the next character, we go to step 5.
Switch Matrix Controller LRDE, DRDO
Tezpur University 23 June-July,2012
Programming the 8051 to receive data serially
The steps 1-4 given in the programming of 8051 to transfer data serially are followed.
1. The RI bit is cleared.
2. The RI flag is monitored to see if an entire character has been received yet.
3. When RI is raised, SBUF has the byte. Its contents are moved into a safe place.
4. To receive the next character we go to the step 2.
2.6.4 Interrupt Programming
Interrupts vs. Polling
A single microcontroller can serve several devices. There are two ways to do that:
interrupts and polling. In the interrupt method, whenever any device needs its service, the
device notifies the microcontroller by sending it an interrupt signal. Upon receiving the
interrupt signal, the microcontroller interrupts whatever it is doing and serves the device.
The program associated with the interrupt is called the interrupt service routine (ISR) or
the interrupt handler. When an interrupt is invoked, the microcontroller runs the ISR. In
polling, the microcontroller continuously monitors the status of a given device. When the
status condition is met, it performs the service. After that it moves on to monitor the next
device until each one is serviced. The interrupt method is preferable in case of the 8051
microcontroller.
Steps in executing an interrupt
Upon activating an interrupt, the microcontroller goes through the following steps:
1. It finishes the instruction it is executing and saves the address of the next
instruction (PC) on the stack.
2. It also saves the current status of all the interrupts internally (i.e., not on the stack).
3. It jumps to a fixed location in the memory called the interrupt vector table that
holds the address of the interrupt service routine.
Switch Matrix Controller LRDE, DRDO
Tezpur University 24 June-July,2012
4. The microcontroller gets the address of the ISR from the interrupt vector table and
jumps to it. It starts to execute the interrupt service subroutine until it reaches the
last instruction of the subroutine, which is the RETI (return from interrupt).
5. Upon executing the RETI instruction, the microcontroller returns to the place
where it was interrupted. First it gets the program counter (PC) address from the
stack by popping the top two bytes of the stack into the PC. Then it starts to
Execute from that address.
Enabling and disabling an interrupt
Upon reset all interrupts are disabled, meaning that none will be responded to by the
microcontroller to respond to them. There is a resister called IE (interrupt enable) that is
responsible for enabling (unmasking) and disabling (masking) the interrupts. It is a bit
address register. Fig 2.13 shows the IE register.
Fig 2.16 IE (interrupt enable) register
The bit D7 in the IE register is called EA (enable all). This must be set to 1 to allow the rest
of the register to take effect. If EA=1, interrupts are enabled and will be responded to if
their corresponding bits in IE are high. If EA=0, no interrupt will be responded to, even if
the associated bit in the IE register is high.
Six interrupts in the 8051
Reset: when the reset pin is activated, the 8051 jumps to the address 0000 (power up
reset).
Timer 0 (TF0) and timer 1 (TF1) interrupt: Memory location 000BH and 001BH in the
interrupt vector table belongs to these interrupts, respectively.
External hardware interrupt 0 (INT0) and External hardware interrupt (INT1): Pin
numbers 12 (P3.2) and 13 (P3.3) in port 3 are for INT0 (EX1) and INT1 (EX2) respectively.
Memory locations 0003H and 0013H in the interrupt vector are assigned to the INT0 and
INT1 respectively.
Switch Matrix Controller LRDE, DRDO
Tezpur University 25 June-July,2012
Serial COM interrupt: Serial communication has a single interrupt that belongs to both
receive and transmit. The interrupt vector table location 0023H belongs to this interrupt.
Interrupt priority in 8051
When the 8051 is powered up, the priorities are assigned according to the table 2.9.
Highest to lowest priority
Interrupt ROM location of ISR Pin
Reset 0000 9
External Interrupt 0 (INT0) 0003 P3.2 (12)
Timer interrupt 0 (TF0) 000B --
External interrupt 1 (INT1) 0013 P3.3 (13)
Timer interrupt 1 (TF1) 0013 --
Serial communication (RI+TI) 0023 --
Table 2.9 8051 Interrupt priorities
Programming the serial communication interrupt
As far as serial communication is concerned, the concept of transmitting and receiving
data as discussed in the above section applies equally when using either polling or
interrupt. The only difference is how the serial communication needs are served. In polling
method, we wait for the flag (TI or RI) to be raised; while we cannot do anything else. In
the interrupt method we are notified when the 8051 has received a byte or is ready to
send the next byte. We can do other things while the serial communication needs are
served.
In the vast majority of applications, the serial interrupt is used mainly for receiving data
and never used for sending data serially. Since there is only one interrupt for both receive
and transmit, the ISR clears the RI and TI flags before executing the RETI instruction.
Switch Matrix Controller LRDE, DRDO
Tezpur University 26 June-July,2012
3. Serial Communication
Microcontroller communicates with other peripheral devices or microcontroller in the
form of serial or parallel technique. In parallel procedure the entire byte of data is
transmitted at a time from transmitting device to receiving device. This technique is
favorable for short distance and requires separate lines for each bit to transmit. While
serial communication, a single bit is transmitted at a time and once eight bits are received
at the receiers end the data yte is reconstructed. Although it requires time to transmit
and receive data byte but it useful in long distance transmission.
3.1 Asynchronous versus synchronous serial transmission
In serial communication, the transmitting and receiving devices need to be in
synchronization to follow common protocol and data rate. Synchronization helps
transmitter and receiver to expect data transmission/reception at same time. There are
two ways to have synchronization between transmitter and receiver: Asynchronous and
Synchronous.
In an Asynchronous serial communication system, such as USART abroad ATmega16,
framing bits are used at the beginning and end of a data byte. These framing bits alert the
receiver that an incoming data byte has arrived and also signals the completion of the data
byte reception. The data rate for an asynchronous serial system is typically much slower
than the synchronous system, but it only requires a single wire between the transmitter
end the receiver.
A synchronous serial communication system maintains synchronize between the
transmitter and receiver by employing a common clock between the two devices. Data
byte are sent and received at the edge of the clock. This allows data transfer rates higher
than with asynchronous techniques but requires two lines: data and clock to connect
transmitter and receiver.
3.2 Baud rate
The transmission rates of data are typically specified as baud or bits per second rate. For
example, 9600 baud indicates data are being transferred at 9600 bits per second.
3.3 Duplex
Switch Matrix Controller LRDE, DRDO
Tezpur University 27 June-July,2012
Duplex is the term used for communication system that defines the hardware used for
transmission and reception.
In simplex the data transmitted to the receiver from transmitter. Whereas in half duplex
data is transmitted in one way at a time. While in full duplex data can move both ways at a
time.
Fig 3.1: Transmission of data using Duplex.
3.4 UART
Many manufacturers make special IC chips for serial communications: UART (Universal
Asynchronous Receiver-Transmitter) & USART (Universal Synchronous-Asynchronous
Receiver-Transmitter).
UARTs are used for serial communication between systems; they can be either half duplex
(send or receive) or full duplex (send and receive at the same time). Also known as an
RS232 connection the microcontroller UART can provide the connection with a PC or
another microcontroller-based system. Figure 3.2 illustrates possible connection
arrangements. In a minimum connection there could be only two transmission lines,
transmit (Tx) and receive (Rx) as shown in Figure 3.3. The data is conveyed as a bit stream,
either transmit or receive, and the speed is defined by the baud rate i.e. the bits per
second.
The UART has four mode of operation, 0 to 3. Modes 0 and 2 have fixed baud rates, mode
0 is one-sixth of the oscillator frequency, and mode 2 is 1/16 or 1/32 of the oscillator
frequency. For modes 1 and 3 the baud rate can be selected, a typical range is:
Switch Matrix Controller LRDE, DRDO
Tezpur University 28 June-July,2012
75, 150, 300, 600, 1200, 2400, 4800, 9600, 19200, 38400
Modes 0 and 1 are used for connection between two devices. Modes 2 and 3 are used for
master slave multiprocessor systems, in principle there could be one master
microcontroller and up to 255 slave microcontrollers.
Fig 3.2: Use of RS-232 interface between PC and microcontroller or between two
microcontrollers.
Fig 3.3: RS-232 transmits (Tx) and receives (Rx) connections between a PC and
Microcontroller.
3.5 RS-232
Switch Matrix Controller LRDE, DRDO
Tezpur University 29 June-July,2012
RS-232 is the traditional name for a series of standards for serial binary single-ended data
and control signals connecting between a DTE (Data Terminal Equipment) and a DCE (Data
Circuit-terminating Equipment). It is commonly used in computer serial ports. The
standard defines the electrical characteristics and timing of signals, the meaning of signals,
and the physical size and pin out of the connectors. RS-232 establishes two-way (Full
duplex) communications, with signals represented by voltage levels measured with respect
to a system common ground. The idle state (MARK) is negatie with respect to common
ground and the actie state (SACE) is positie with respect to common ground.
Fig 3.4: Format of data byte transmission.
The transmission of the data byte starts with start bit which is always low (0) and ends
with stop bit(s) which always high (1). The LSB follow the start bit and MSB is followed by
stop bit as shown in fig 3.4. In order to maintain data integrity, the parity bit is introduced
in the data frame.
The standard output signal level of RS-232 usually varies between -12V and +12V, with a
dead region etween +3 and -3V designed to absorb line noise. The TTL signal voltage
from UART is between 0 and 5 volts, but after being transformed by the RS-232
transceiver, the signal voltage is changed to +12V to -12V.
3.6 Max-232
Max 232 is an integrated circuit that converts signals from a RS-232 serial port to signals
suitable for use in TTL compatible digital logic circuits. Max 232 is a dual driver/receiver
and typically converts the Rx, Tx, CTS and RTS signals.
Switch Matrix Controller LRDE, DRDO
Tezpur University 30 June-July,2012
The drivers provide RS-232 voltage level outputs (approx. 7.5 V) from a single +5 V supply
via on-chip charge pumps and external capacitors. This makes it useful for implementing
RS-232 in devices that otherwise do not need any voltages outside the 0 V to +5 V range,
as power supply design does not need to be made more complicated just for driving the
RS-232 in this case.
The receivers reduce RS-232 inputs (which may be high as 25V), to standard 5 V TTL
levels. These receivers have a typical threshold of 1.3 V, and a typically hysteresis of 0.5 V.
Fig 3.5: Block diagram of Max-232 and its connection.
3.7 Conclusion
The serial communication emerges as an important protocol in the arena of
communication with hit and misses. It is favourable for long distance and cost effective
with less number of connecting wires and one of the commonly used forms of
communication.
Switch Matrix Controller LRDE, DRDO
Tezpur University 31 June-July,2012
4. RF Switch
A switch is an electrical component that can break an electrical circuit, interrupting the current or
diverting it from one conductor to another. The most familiar form of switch is manually operated
electromechanical device with one or more sets of electrical contacts, which are connected to
external circuits.
Switches are classified according to the arrangement of their contacts in electronics. A pair of
contacts is said to e closed when current can flow from one to the other. hen the contacts are
separated y an insulating air gap, they are said to e open, and no current can flow etween
them at normal oltages. The terms mae for closure of contacts and rea for opening of
contacts are also widely used.
In a push button type switch, in which the contacts remain in one state unless actuated, the
contacts can either be normally open until closed by operation of the switch, or normally closed
and opened by the switch action. A switch with both types of contact is called changeover switch.
These may e mae-before-rea which momentarily connect oth circuits, or maye rea-
before-mae which interrupts one circuits efore closing the other.
4.1 Pole and Throw
The terms pole and throw are also used to descrie switch contact ariations. The numer of
poles is the numer of separate circuits which are controlled y a switch. or example, a -
pole switch has two separate identical sets of contacts controlled y the same knob. The number
of throws is the numer of separate position that the switch can adopt. A single throw switch
has one pair of contacts that can either be closed or open. A double throw switch has a contact
that can be connected to either of two other contacts; a triple throw has a contact which can be
connected to one of three other contacts, etc. These term gives rise to abbreviation for the types
of switch which are used in the electronics industry such as single-pole, single-throw (SST) (the
simplest type, on or off) or single-pole, double-throw (SDT), connecting either of two
terminals to the common terminal. Switches with large numbers of poles or throws can be
descrie y replacing the S or D with a numer (e.g. 3ST, 4ST, etc.) or in some cases the
letter T (for triple).
Fig 4.1: Representation of SPST, SPDT, DPST, DPDT
Switch Matrix Controller LRDE, DRDO
Tezpur University 32 June-July,2012
4.2 Switch Matrix
The Switch Matrix is made up of switches and signal conditioners that are mounted
together in a mechanical infrastructure or housing. It is used in test systems, in both
design verification and manufacturing test, to route high frequency signals between the
device under test (DUT) and the test and measurement equipment. Besides signal routing,
the switch matrix may also contain signal conditioning including passive signal devices
such as attenuators, filters, and directional couplers, as well as active signal conditioning,
such as amplification and frequency converters. Since the signal routing and conditioning
needs of a test system differ from design to design, switch matrices need to be custom
designed by the custom test engineer for each new system.
Fig 4.2: Application of switch matrix.
4.3 ZASW-2-50DR
It is a SPDT in which we apply control signal through TTL IN to select either of the RF OUT 1 or RF
OUT 2. The control signal can be in high (logic 1) or low (logic 0) depending on which one of the RF
out line will be selected. Moreover it is also a TTL driver.
Switch Matrix Controller LRDE, DRDO
Tezpur University 33 June-July,2012
Fig 4.3: Block representation of ZASW-2-50 DR switch matrix.
Fig 4.4: Truth table of control signal for selection of RF OUT(s).
4.4 ZSWA-4-30-DR
It is a SP4T switch in which a single signal is routed to as many four ways with the help of four
control signals. It is a TTL driver.
Switch Matrix Controller LRDE, DRDO
Tezpur University 34 June-July,2012
Fig 4.5: Block representation of ZSWA-4-30 DR switch.
Fig 4.6: Truth table of ZSWA-4-30 DR switch.
4.5 Switch Matrix
We used a switch matrix constructed with ZASW-2-50 DR and ZSWA-4-30 DR switch. The
control signals to the switches are generated by the microcontroller that enables selection
of antenna connected at the end of switches.
4.6 Conclusion
The switch plays an important role in the routing of signal from one end to other. It acts as a
medium for efficient and better signal transmission and helps to maintain signal integrity.
Switch Matrix Controller LRDE, DRDO
Tezpur University 35 June-July,2012
5. Design of the control Circuit
5.1 The schematic
The schematic of the control circuit is designed using OrCAD capture and is provided in
appendix A. The OrCAD project file is included along with the soft copy the report.
5.2 Description of the circuit blocks
5.2.1 The 8051 microcontroller
It is the heart of the control circuit. The microcontroller is pre-programmed to receive
control word from PC via its serial ports and then manipulate the word and sending the
control signals to the switch matrix from its parallel I/O ports. The microcontroller is
equipped with 11.0592 MHz crystal, reset switch (push button), Pull up resistors for P0.
5.2.2 The Max3232 chip
As mentioned earlier in microcontroller 8051 uses TTL logic levels, but PC port uses RS232
standard. To overcome this mismatch the max3232 chip is used in the serial
communication path. It takes rs232 standard as input from PC and generates a TTL level
output for the microcontroller and vice versa in the alternate path (TTL to RS232).
5.2.3 The 7408 chips
It is the buffer block of the circuit used for driving LED. The I/O ports of 8051
microcontroller can sink current upto 1.6 mA (3.2 mA for port0). This current cannot drive
LEDs. Therefore 7408 chips are installed in etween the ports and the LEDs. It sinks
current upto 0 mA which is recommended for LEDs to glow with full rightness.
A 7408 chips comprises of four 2-input and gates, here we are connecting one port output
line to one input of a logic gate; the other input is predefined to be high. Thus the port pin
status appears at the output. Following figure shows 7408 pin configuration and logic
table.
Switch Matrix Controller LRDE, DRDO
Tezpur University 36 June-July,2012
Fig 5.1 7408 pin configuration
Fig 5.2 7408 truth table
Another important role of these chips is to act as protection circuit for the switch
matrix. The control signals should not be fed to the switches unless Vcc supply is
provided to them. This can be achieved by connecting the +5v supply to the predefined
logic inputs of the 7408 gates through a switch.
5.2.4 The LED arrays
There are 3 arrays of LED each consisting of 8 LEDs is connected to port 0, port1, and
port2 of the microcontroller. These arrays work as display device and permit us to
chec weather proper control signal is eing generated or not. The LEDs are in
common cathode connection and a current limiting resistor of 330 Ohms is connected
to each.
5.2.5 The DB9 connectors
There are four 9 pin D type connector in the circuit, one of them is used to connect
with the PC whereas the other three corresponds to the three ports (P0, P1, P2) of the
microcontroller and used to drive the control signal to the switch matrix.
Switch Matrix Controller LRDE, DRDO
Tezpur University 37 June-July,2012
5.2.6 Other components
All the other components especially capacitor are inserted within the board as
required by the different chips for proper operation. Also for each IC a de-coupling
capacitor is used to avoid damaging of the IC.
5.2.7 Test points
The test points TP1 & TP2 is installed to provide +5V Vcc and ground supply
respectively.
5.3 The Final Design
The final SWITCH MATRIX CONTROLLER board after installing all the components is
provided in fig 5.3 below.
Fig 5.3 the final circuit board in PCB
Switch Matrix Controller LRDE, DRDO
Tezpur University 38 June-July,2012
6. Programming the Microcontroller
6.1 Introduction
A microcontroller is useless without a program burned to it. It must know the
executable instructions to perform after startup. The executable hex file is to be fused
to a microcontroller before installing it to the circuitry. Keil uVision is the software tool
that is used to create the fusable hex file of our required program.
The program needed for the switch matrix controller is written in C code and compiled
using keil. The hex file is created and is fused to the 8051 chip with an IC programmer.
6.2 The flowchart
Fig 6.1 the programming flowchart
Switch Matrix Controller LRDE, DRDO
Tezpur University 39 June-July,2012
6.3 Programming steps
The microcontroller is required to program so that it can generate control signal for a
switch matrix that is controlling eight antennas among which four are transceiver and
other four are dedicated receiver. The programming steps are explained below.
6.3.1 Programming the serial port
To enable the microcontroller for serial communication with required baud rate (9600)
the SCON, TMOD, TH registers are initialized. A table for the initial values is shown below.
Register SCON TMOD TH
Value 50h 20h FDh
Table6.1 registers values for serial port programming
6.3.2 Decoding control word
To decode the 8 control word we must know its format. As mentioned earlier it is a 8 bit
word upper nibble comprising of Txr code and lower nibble comprising of Rxr code. From
the received value Txr/Rxr codes are achieved with shifting and masking operations as
follows.
Txcode=conword && 0xF0;
Txcode=Txcode>>4;
Rxcode=conword && 0x0F;
6.3.3 Generating control signals
After decoding Txr and Rxr code the control signal is to be generated by making certain
bits of the I/O ports high/low accordingly. A configuration for port bits to switch matrix is
made as shown in fig 6.2
Switch Matrix Controller LRDE, DRDO
Tezpur University 40 June-July,2012
Fig 6.2 Arrangement of switch antenna along with port bit connection to the control
lines
The next step in control signal generation is to determine the control bits to be cleared
according to Txr/Rxr code. Following tables are provided for this.
TABLE: Transmitter selection
Code Antenna to be
selected
Bits status
0000 A0 P0.0=0; P0.4=0; others 1
0001 A1 P0.1=0; P0.5=0;others 1
0010 A2 P0.2=0; P0.6=0;others 1
0011 A3 P0.3=0;P0.7=0;others 1
Table 6.2 Port bit status for Transmitter selection
Switch Matrix Controller LRDE, DRDO
Tezpur University 41 June-July,2012
TABLE: Receiver selection
Code Antenna to be
selected
Bits status
0000 A0 P1.0=0; P2.0=0; others 1
0001 A1 P1.1=0; P2.0=0;others 1
0010 A2 P1.2=0; P2.0=0;others 1
0011 A3 P1.3=0; P2.0=0;others 1
0100 A4 P1.4=0; others 1
0101 A5 P1.5=0; others 1
0110 A6 P1.6=0; others 1
0111 A7 P1.7=0; others 1
Table 6.3 port bit status for Receiver selection
6.4 The complete code
The C code written in keil environment is provided below.
/* C code for switch matrix controller */
#include<regx51.h>
#include<stdio.h>
unsigned char conword;
void receive();
void transmit();
void main()
{
unsigned char txcode;
unsigned char rxcode;
TMOD=0x20;
TH1=0xFD;
SCON=0x50;
TR1=1;
while(1)
{
Switch Matrix Controller LRDE, DRDO
Tezpur University 42 June-July,2012
receive();
P0=0xff;
P1=0xff;
P2=0xff;
rxcode=conword & 0x0f;
txcode=conword & 0xf0;
txcode=txcode>>4;
switch(txcode)
{
case 0:
P0_0=0;
P0_4=0;
break;
case 1:
P0_1=0;
P0_5=0;
break;
case 2:
P0_2=0;
P0_6=0;
break;
case 3:
P0_3=0;
P0_7=0;
break;
default:
P0=0xff;
P1=0xff;
P2=0xff;
}
switch(rxcode)
{
case 0:
P1_0=0;
P2_0=0;
break;
case 1:
P1_1=0;
P2_0=0;
break;
case 2:
P1_2=0;
P2_0=0;
break;
case 3:
P1_3=0;
P2_0=0;
Switch Matrix Controller LRDE, DRDO
Tezpur University 43 June-July,2012
break;
case 4:
P1_4=0;
P2_0=1;
break;
case 5:
P1_5=0;
P2_0=1;
break;
case 6:
P1_6=0;
P2_0=1;
break;
case 7:
P1_7=0;
P2_0=1;
break;
default:
P0=0xff;
P1=0xff;
P2=0xff;
}
transmit();
}
}
void receive()
{
while(RI==0);
conword=SBUF;
RI=0;
}
void transmit()
{
SBUF=conword;
while(TI==0);
TI=0;
}
/*End of File*/
Switch Matrix Controller LRDE, DRDO
Tezpur University 44 June-July,2012
6. Conclusion
The project wor switch matrix controller is used for experimental use of the radar system.
In case of real field application, for switching of antennas the controller is designed through
FPGA (field programmable gate arrays). The features of the microcontroller based control
circuit designed throughout the project is listed below.
1. Serial communication
The control circuit is can communicate with PC via its serial UART. Thus the control word
from PC is received serially and it can send acknowledgement to the PC in the same
manner
2. Fast decoding
Microcontroller being a fast device decodes the control word and generates the control
signals within a few milliseconds.
3. On board LED
The control circuit comprise of LED arrays corresponding to each output line. Thus we can
check whether the controller is working properly or not by means of the status of the
LEDs.
4. Number of output lines
The circuit provides a maximum of 24 output lines that can be used as control signals to
the switch matrix.
5. Driver cum protection circuit
The buffer block in the controller comprises of 7408 ICs. This loc acts as LED drier as
well as a protection circuit for the switch matrix.
The circuit however cannot work independently. It must receive a control byte from PC to
generate control signals for the switch matrix. Therefore we need a control word generator in
our PC that will send the control words in the format specified to the microcontroller. A
matlab GUI can be used for this purpose.
Switch Matrix Controller LRDE, DRDO
Tezpur University 45 June-July,2012
Switch Matrix Controller LRDE, DRDO
Tezpur University 46 June-July,2012
Appendix B
THE ORCAD
Overview
OrCAD is a proprietary software tool suite used primarily for electronic design automation.
The software is used mainly to create electronic schematics and electronic prints for
manufacturing printed circuit oards (CBs).
The name OrCAD reflects the company and its software's origins: Oregon + CAD; Founded in
1985 y John Duretai, Ken and Keith Seymour as OrCAD Systems Corporation in Hillsoro,
Oregon. The company became a leading worldwide supplier of desktop electronic design
automation (EDA) software. The companys first product was SDT (schematic design tools). It
passes through several stages of development and upgradation and finally OrCAD product line
has been fully owned by Cadence Design Systems in 1999.
OrCAD Capture provides fast and intuitive schematic design entry for PCB development or
analog simulation using PSpice. The component information system (CIS) integrates with it to
automatically synchronize and validate externally sourced part data. OrCAD Capture CIS
integrates the OrCAD Capture schematic design application with the added capabilities of a
component information system (CIS) and the Cadence ActiveParts Portal.
CIS allows designers to search, identify, and populate the design with preferred parts. With
easy access to company component databases and part information, designers can reduce the
amount of time spent researching needed parts.
The PSpice allows simulation environment for the designs.
Products
Capture CIS
OrCAD PCB Editor
PSpice
Layout Plus
Features/Benefits
Boosts schematic editing efficiency of complex designs through hierarchical and variant
design capabilities
Integrates with a robust CIS that promotes the use of preferred, current parts to
accelerate the design process and reduce project costs
Provides access to more than two million parts with Cadence ActiveParts, offering
greater flexibility when choosing design components.
Switch Matrix Controller LRDE, DRDO
Tezpur University 47 June-July,2012
Appendix C
The Keil uVision
Overview
Keil was founded in 1982 by Gnter und Reinhard Keil, initially as a German GbR. In April 1985
the company was converted to Keil Elektronik GmbH to market add-on products for the
development tools provided by many of the silicon vendors. Keil implemented the first C
compiler designed from the ground-up specifically for the 8051 microcontroller.
Keil provides a broad range of development tools like ANSI C compiler, macro assemblers,
debuggers and simulators, linkers, IDE, library managers, real-time operating systems and
evaluation boards for 8051, 251, ARM, and XC16x C16x ST10 families.
Popular Products
8051 Development Tools
Keil C51 is the industry-standard tool chain for all 8051-compatible devices, it supports classic
8051, Dallas 390, NXP MX, extended 8051 variants, and C251 devices. The Vision
IDE/Debugger integrates complete device simulation, interfaces to many target debug
adapters, and provides various monitor debug solutions.
C166 Development Tools
Keil C166 development tools support the Infineon C166, XC166, XE166, XC2000 and ST10
microcontroller families. The Vision IDE/Debugger interfaces to the Infineon DAVE code
generation tool and various debug solutions including the ULINK2.
Evaluation Boards
Keil offer an extensive range of evaluation boards and starter kits to quick start your
development. Boards are available for ARM, 8051, and 166 processor-based devices.
Vision IDE and Debugger
The Keil Vision4 IDE is common to all Keil software development tools.
The uVision IDE
The Vision IDE from Keil combines project management, make facilities, source code editing,
program debugging, and complete simulation in one powerful environment. The Vision
Switch Matrix Controller LRDE, DRDO
Tezpur University 48 June-July,2012
development platform is easy-to-use and helping you quickly create embedded programs that
work. The Vision editor and debugger are integrated in a single application that provides a
seamless embedded project development environment.
Project Concerned Use
In our project keil uvision IDE 4 is used to write the C code for the controller. Debug the code
and create the hex file to fuse into the microcontroller.
Switch Matrix Controller LRDE, DRDO
Tezpur University 49 June-July,2012
Appendix D
About the organization:
LRDE is one of the R&D Establishments set up under the Defence of Research & Development
Organization to address the Services needs in the field of RADAR, Communication Systems and
related technologies. In 1962, Electronics Research and Development Establishment was
renamed as Electronics & Radar Development Establishment (LRDE). The scope of the
laboratory was changed to emphasize the greater importance for indigenous development of
RADAR and Communication Systems. LRDE has made very significant contributions towards
Design and development of complex Military Electronic Systems, Communication and RADARs,
which are serving our Armed Forces. LRDE has the Core Competence and Expertise to build
world class RADAR systems and Software driven electronic Systems.
Vision of LRDE
To create a centre of excellence in design and development of RADARs and related
Technologies.
Mission of LRDE
1. To design and develop Radar systems and related technologies to cater to the Needs of
Services.
2. To contribute towards the enhancement of the infrastructure, knowledge Base and
technologies for achieving self-reliance.
3. To promote research and competence building activities in the field of RADAR Within the
laboratory and in the academic institutions and continuously evolve as the centre of
excellence in RADAR technology.
Quality Policy
LRDE is committed to the indigenous development of modern RADAR systems through an
effective quality management system.
Quality Objectives
1. Develop modern RADAR systems to meet user requirements.
2. Enhance capabilities in technologies and systems engineering.
3. Implement quality management system and enhance quality through continual
improvement.
Organization Areas of Work & Achievements
Design and Development of Radar Systems
Army
- Multifunction Phased Array Radar and 3D Surveillance Radar for Akash Missile Weapon
System
- Low Level 2D Radar for Fire Control and Air Defence
- Short Range Battle Field Surveillance Radar
- Weapon Locating Radar
Switch Matrix Controller LRDE, DRDO
Tezpur University 50 June-July,2012
-3D Tactical Control Radar
Air Force
- Multifunction Phased Array Radar and 3D Surveillance Radar for Akash Missile Weapon
System
- Active Phased Array Radar for AEW&C
- Low level 2D radar and 3D Short & Medium Range Surveillance Radar
For Air Defence
- Medium Power Radar (MPR)
- Low Level Transportable Radar (LLTR)
- Active Electronically Scanned Array Radar (AESA)
Navy
- Maritime Patrol Radar for fixed and Rotary Wing Aircraft
- Maritime Patrol Radar with SAR & ISAR
- 3D Medium Range Surveillance Radar for ASW Corvettes
Development of Radar Technologies
- Antennae: Slotted Waveguide, Patch Array & Multibeam Antenna
- T/R Modules and Active Aperture Arrays
- Programmable DSP
- Radar Data Processors
- High Average Power TWT based Transmitters
- High purity sources
- Multi-channel double heterodyne receivers
Switch Matrix Controller LRDE, DRDO
Tezpur University 51 June-July,2012
BIBLIOGRAPHY
BOOKS:
Introduction to RADAR systems, 3
rd
edition, Merril L. Skolink
The 8051 Microcontroller and Embedded systems using assembly and C, 2
nd
edition;
Mazidi, Mazidi & McKinlay
ONLINE REFERENCES
http://en.wikipedia.org/wiki/Radar
http://en.wikipedia.org/wiki/RS-232
http://en.wikipedia.org/wiki/MAX232
http://en.wikipedia.org/wiki/Intel_MCS-51
HTTP://NPTEL.IITM.AC.IN/COURSES/WEBCOURSE-CONTENTS/IIT-KANPUR/MICROCONTROLLERS
http://en.wikipedia.org/wiki/RF_switch_matrix
http://en.wikipedia.org/wiki/Serial_communication
http://en.wikipedia.org/wiki/OrCAD
http://en.wikipedia.org/wiki/Keil_%28company%29
http://www.keil.com/products
www.cadence.com/products/orcad/orcad_capture
DATASHEETS AND USER GUIDES
AT89C51 datasheet by ATMEL
MAX3232 datasheet by MAXIM
7408 datasheet by PHILIPS
ZSWA-4-30DR
ZASWA-2-50DR/DR+
OrCAD Capture USER GUIDE by Cadence Design Systems
Vision4 Getting Started Guide by keil