Top Banner

of 98

354 33 Powerpoint-slides CH12

Jun 03, 2018

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • 8/12/2019 354 33 Powerpoint-slides CH12

    1/98

    N. Senthil Kumar,M. Saravanan &

    S. Jeevananthan

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    2/98

    8051 Interface Examples

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    3/98

    Learning Outcomes

    After studying this chapter, you will be able to understandthe following:

    Interfacing of the programmable interface IC 8255 and

    switches and LEDs with the 8051 Interfacing of analog-to-digital and digital-to-analog

    converters Interfacing of LCD interface, Matrix keyboard and motors

    8051 application examples

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    4/98

    Interfacing 8255 to 8051

    When the 8051 is connected to external memory, port 0 (P0) is usedfor the lower-order address and data bus and port 2 (P2) is used forthe higher-order address bus.

    Since the port 3 pins have an alternative function, the net result isthat only P1 is left for input and output operation.

    One way to expand the number of I/O ports is to connect the 8255programmable peripheral interface with the 8051.

    The interfacing of the 8255 with the 8051 is done assuming the 8255as a memory location, because the 8051 supports only memory-mapped I/O.

    For accessing the external memory in the 8051, the MOVX instructionis used.

    The lower-order address bus and the data bus are multiplexed and areavailable in the port 0 pins.

    This is de-multiplexed using a latch and the ALE signal.

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    5/98

    Interfacing 8255 with 8051

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    6/98

    Interfacing 8255 to 8051 The first step in the general interfacing method is to decide the

    addresses for the port. The 8051 uses 16-bit addresses and the most significant address

    lines are used for decoding and selecting the device. Here, the higher-order address bus from port 2 is given to a

    decoder logic circuit. From the decoder, the 8255 chip select signal is generated. The 8255 needs four addresses for interfacing with any

    processor three for the ports A, B, and C and one for the controlregister.

    The lower-order address lines A0 and A1 are connected to selectone of these four registers. The read and write control signals areavailable from the port 3 pins P3.7 and P3.6.

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    7/98

    Interfacing of Push button switches

    and LEDs The simplest input and output device that can be interfaced to

    any microprocessor is the push button switches and LightEmitting Diodes (LEDs).

    The example here is considering 4 push button switchesinterfaced to one port of 8051 and four LEDs connected toanother port.

    The switches are connected in such a way that when it is open,

    it connects a logic 0 i.e. 0Volts to the port and when it isclosed, it connects logic 1 i.e. 5Volts to the port pins.

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    8/98

    Interfacing of switches to port pins

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    9/98

    Interfacing of Push button switchesand LEDs

    The circuit connections are shown in Figure are such that theport is not damaged and also the port is not sourcing overcurrent. This ensures safe operation of the ports and switches.

    An LED gives out light illuminating when it is forward biasedand has enough current flowing through it. LED indicators areeasy to interface with the microcontrollers as output device.

    LEDs can be driven with a minimum current of about 10mA. Adriver IC can be used for illuminating LEDs.

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    10/98

    Interfacing LED with driver to port

    pins

    Oxford University Press 2013

    Figure shows a method of using an inverter driver forconnecting ports to LEDs.

  • 8/12/2019 354 33 Powerpoint-slides CH12

    11/98

    Description

    When logic 1 is given out on the port pin, it will be invertedby the inverter and will connect ground (logic 0) to thecathode of LED. This will forward bias the LED and light will

    be given by LED.

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    12/98

    Interfacing of 4 switches and 4 LEDs

    Oxford University Press 2013

    Figure shows the interfacing of 4 Switches to port 3 pins and 4 LEDsto Port1 pins of 8051.

    The inverter driver IC 74240 is used to drive the LEDs. Even thoughonly 4 LEDs are shown connected in Figure 12.4, we can connect 8LEDs as 74240 has eight inverter drivers.

    The program to display the contents of 4 switches on to the LEDs isas followed.

  • 8/12/2019 354 33 Powerpoint-slides CH12

    13/98

    Description

    Start: MOV A, P3 MOV P1, A

    When logic 1 is sensed on port 3 line, the same data is givenas output on port 1 lines. When logic 0 is sensed, the same isgiven on port 1lines. The LEDs will not be illuminated now asthe LEDs are not forward biased.

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    14/98

    Interfacing of Seven SegmentDisplays

    Seven segment displays consist of seven LED segments. The sevensegments are arranged in the form as shown in figure and thedisplay of various digits is also shown in the same figure.

    Seven segment displays are available in a single dual line in

    package. There are each pin for each segment and these pins are named

    from a to f and another LED is available for decimal point. In addition to these eight pins, the seven segment displays have

    one more pin for power supply. Seven segment displays come in two types either in common

    anode or common cathode.

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    15/98

    Interfacing of Seven SegmentDisplays

    In common anode display, the anode of all segment LEDs aretied together and taken out.

    So, to illuminate a segment, the common anode isconnected to the supply and then the segment input i.e. a tof is connected to a low level logic 0.

    In common cathode display, the cathodes of all the LEDs areconnected together and taken out.

    So, to illuminate a segment, the corresponding segment

    input is connected to the high level voltage or logic 1 and thecommon cathode is connected to the ground. This willforward bias the LEDs and illuminate them.

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    16/98

    Seven Segment Display

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    17/98

    Interfacing Description Interfacing of Seven segment displays to 8051

    microcontroller needs a driver as shown in Figure. Here74240 TTL inverter driver IC is used for driving the sevensegment displays.

    Also the seven segment display is assumed to be commonanode type. The common anode is connected to the supply+5V.

    The interfacing diagram for displaying the BCD code

    obtained from key connected to port3 and displaying thesame in seven segment display connected to port 1

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    18/98

    Interfacing Switches and sevensegment display to 8051

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    19/98

    Interfacing Description The segments can be illuminated

    if the segments pins areconnected to the low level ofsupply or to ground.

    This is done by connecting the

    segment inputs of logic 0 through74240. The 74240 IC will invert theinputs applied to it. So, if we wantto illuminate a particular segment,the corresponding output for that

    segment has to be logic 1. The data output for displaying

    decimal digits 0 to 9

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    20/98

    Interfacing ADC chip

    The Analog to digital converter are essential in any microprocessoror microcontroller system for interfacing analog inputs to thesystem.

    The specifications of the ADC are the range of analog inputvoltage, the number of digital bits at the output, resolution, theconversion time and the number of analog input channels.

    The analog input voltage can be either unipolar or bipolar.Unipolar means the input voltage can have only one polarity like(0 to +5V) or (0 to +10V).

    Bipolar means the input voltage can range from one polarity to

    the other like (-5V to +5V) or (-10V to +10V). Most of the ADCchips come with an option of selecting one of these voltageranges using Vref input pins.

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    21/98

    ADC chip - Description

    The ADC chips are available for different number of outputbinary bits. ADCs are available with 8 bits or 10 bits or 12 bitsor 16 bits digital outputs.

    The number of bits will decide the number of voltage levelssensed. For example an eight bit ADC will have 28 possiblelevels i.e., 256 levels.

    The number of bits and the input voltage range will decide theresolution. The resolution of an ADC is defined as the smallestchange in the input voltage that can be sensed or detected atthe output.

    The resolution can be mathematically defined as the range ofinput voltage divided by the number of levels at the output.

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    22/98

    ADC chip - Description

    For example, an ADC with the input voltage range of (0to+5V) with 8 bits at the output will have a resolution of(5/256) i.e., approximately 19.5mV. The conversion time ofADCs will be decided by the type of the ADC, and the clockfrequency used in the converter circuits.

    Some ADC chips come with an option of having more thanone analog input. One of these analog input channels areselected using select lines and an analog multiplexer circuit.

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    23/98

    Interfacing ADC chip - Introduction The ADC chips also have a sample and hold circuit. The

    sample and hold circuit is used to maintain the analoginput voltage constant when the conversion is in progress.

    For interfacing of ADC chips with 8051, there are two

    possible ways. One is to directly interface ADC chip withthe 8051 parallel ports.

    In complex systems, involving many external chipsincluding memory, an 8255 PPI chip may be interfaced

    with the 8051 and the ADC chip can be interfaced with8051 through 8255.

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    24/98

    Interfacing ADC chip directly to 8051

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    25/98

    Interfacing ADC Description

    Figure shows the interfacing of ADC 0808/0809 with 8051directly. ADC 0808/0809 is a commonly used ADC chip with 8analog input channels and with 8 bit digital output.

    The 8 analog inputs are multiplexed and selected using thethree select lines A, B and C. The select lines are connected to the port 0 LSB three bits.

    To the ADC chip, additional inputs +Vref, -Vref, CLK and

    supply inputs must be given.

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    26/98

    Interfacing ADC Description The ALE and SC pins are tied together and connected to port

    pin P0.3. The OE pin is connected to another port 0 pin P0.4and the end of conversion signal EOC is sensed through P0.5.

    The software part follows the flowchart shown in figure The

    channel selection signal is first issued to the ADC chipfollowed by the ALE/SC signal.

    Then the conversion starts within the chip and we get EOCsignal. When EOC signal is received, the program issues OE

    signal and the reads the data from the data lines connectedto Port 1.

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    27/98

    Flowchart

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    28/98

    Program

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    29/98

    Interfacing DAC chip Digital to analog converters are used to get a proportional

    analog voltage or current for the digital data given out by themicroprocessor.

    The common digital to analog converter chip DAC 0800 isconsidered in this interface example. This section will describe

    the interfacing of DAC 0800 with the 8051 microcontroller. Anyone port is enough to interface an 8-bit DAC with 8051. The data lines of the DAC chip is connected to the Port 1 lines

    of the microcontroller 8051.

    The Port 1 lines should now be made as output lines. The output from the DAC chip is in the current variation and

    this is converted in to voltage variation using a current tovoltage converter.

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    30/98

    Interfacing DAC 0800 to 8051

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    31/98

    Interfacing Matrix keypad

    Matrix keypad is organised as matrix connection of switches.Mechanical switches have a problem called Contact Bouncebecause of their construction.

    Pressing a mechanical switch must produce a single pulseoutput.

    Practically, instead of producing a single clean pulse output,the switches generate a series of pulses because the switchcontacts do not come to rest immediately.

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    32/98

    Key debouncing

    As the microprocessor is faster than manual key pressing,the single key pressed will be registered as multiple keypresses. This is the main disadvantage of key bouncing.

    The signal from keys falls and rises a few times within aperiod of about 5ms as the contact bounces.

    So, the signal from the key must be must be made free fromkey bouncing transients. This technique is called asDebouncing of key.

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    33/98

    Solution Key debouncing

    Key board debouncing can be accomplished in hardware orsoftware. The bouncing of key signals occur within 5ms.

    A human cannot press and release a switch in less than20ms. A debouncing logic will check the signal after 20msand then recognize whether a key is pressed or not.

    This logic can be implemented in hardware or software.

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    34/98

    Solution Key debouncing

    The hardware techniques employ SET-RESET flip flops orNon-inverting CMOS gates or integrating debouncer.

    The software technique uses the wait and see method.

    When signal from a switch is sensed, the program will waitfor 10ms and look at the same key again.

    If the signal form the switch still indicates the key press,then the program decides that the user has pressed the key.

    Otherwise the signal received is rejected as noise.

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    35/98

    Matrix keyboard interfaced to 8051

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    36/98

    Description The software for this application does a column scan with

    zero level from P1.0 to P1.3 pins of PORT1 and detects whichkey was stroke checking in which row (P2.0 to P2.3 of PORT2) the zero level appear.

    Scanning a row is achieved by applying 0 V to the port 1 pinand 5 V to the other three port 1 pins, then scanning eachindividual port 2 pins to see if one of them is LOW.

    If it is, then the key at the junction between the row andcolumn being scanned is the pressed key.

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    37/98

    Description

    An ASCII code corresponding to each key (0, 1, 2, 3, ... , 9, A,B, C, D, E, F) can be assigned to each key. The SCANprogram given below uses the look up table concept to getthe ASCII value for the key pressed and returns the same in

    R2 register. The routine includes the software delay routine of 20ms in

    order to solve the keyboard debouncing problems. The procedure for finding a key pressed follows the steps

    given below.

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    38/98

    Steps Key Pressed

    Clear P1.0, set other 3 Scan P2.0 Scan P2.1 Scan P2.2

    Scan P2.3 Clear P1.1, set other 3

    Scan P2.0 Scan P2.1

    Scan P2.2 Scan P2.3

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    39/98

    Steps Key Pressed

    Clear P1.2, set other 3 Scan P2.0 Scan P2.1 Scan P2.2

    Scan P2.3 Clear P1.3, set other 3

    Scan P2.0 Scan P2.1

    Scan P2.2 Scan P2.3

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    40/98

    Program

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    41/98

    Program

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    42/98

    Program

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    43/98

    Description This software can also be modified and written using SETB

    bit and CLR bit instructions. A set of 16 flag bits, in the bit addressable internal RAM

    region can be used to store the bit information of which key

    was pressed, and this can be used by main software routine.

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    44/98

    Interfacing Stepper motor

    Stepper motors are used for position control applications,such as for the control of the disk drives and in robotics.

    The most common stepper motors have four stator windingsthat are paired with a center tapped common shown in

    Figure 12.13. While the conventional motor shaft runs freely, the stepper

    motor shaft moves in a fixed repeatable increment, whichallows one to move it to a precise position.

    The typical stepper motor considered here has 50 teeth onthe rotor and 8 poles on the stator for a 1.8 step angle.

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    45/98

    Switching Sequence

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    46/98

    Interfacing Stepper Motor The interfacing of four phase stepper motor to 8051 is given

    in figure 12.13. The figure shows the four terminals ABCD ofthe motor connected to Port 0 pins through the transistordrivers.

    The common terminal of the motor is connected to thesupply. The excitation sequence for the stepper motor isgiven in Tables 12.2 and 12.3.

    The single phase excitation results in low current throughthe motor windings and it is also called wave mode.

    In two phase excitation, the excitation current through themotor winding is high and so it is called as high torqueexcitation.

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    47/98

    Stepper motor connections to 8051

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    48/98

    LCD Interface to 8051

    Modern LCD devices are becoming popular with more andmore number of applications. The main advantage of LCDover seven segment displays is the ability of LCD to displaynumbers, characters and graphics, when LED can display

    only numbers and limited characters. The LCD comes with an internal controller and refreshing

    circuit and so the CPU is relieved from the work of refreshingthe display.

    The programming of LCD devices is also easier withpredefined control words and addresses. The cost of the LCDis also declining.

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    49/98

    LCD Interface to 8051

    The general LCD devices have 14 pins .Eight data lines areused for interfacing LCD with the processor.

    The three control signals are RS, R/W and E. RS is used toselect a control register or a data register.

    R/W indicates the direction of data flow between theprocessor and the display. E signal is used to enable the datatransfer.

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    50/98

    LCD Display PIN Configuration

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    51/98

    LCD Interfaced with 8051 The three control signals and eight data lines are interfaced

    with the two ports if 8051. In the interfacing diagram, Port 1 lines are used to transfer

    the data and Port 2 lines are used to issue the control signalsfrom the microcontroller to LCD.

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    52/98

    LCD Command Codes The LCD interface can take up many commands or

    instructions regarding the display. These commands have been interpreted which gives all

    display commands.

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    53/98

    LCD Command words

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    54/98

    LCD Command words

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    55/98

    LCD Command words

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    56/98

    LCD Programming

    The programming of LCD is done with proper initialization andwriting command words for the initialization.

    Every time when a control or command word is written intothe LCD, the RS signal input must be made 0 and R/W must be

    made 0 for write operation. After setting these two signals, the Enable E signal must be

    applied as a pulse for the duration of not less than 450ns. Similarly, when data is written into the LCD device, the RS

    signal must be made 1 and R/W must be made 0. To display characters and numbers, the corresponding ASCII

    code is sent to the data registers of LCD display.

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    57/98

    Interfacing DC motors / Servomotors

    An interfacing method for turning on and off a DC motor viaa microcontroller is shown

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    58/98

    Interfacing DC motors/Servomotors The above circuit will only work for a 5 V motor. When the

    output on port pin is logic 1 i.e. 5V, the p-n-p transistor is off.This means that the current through the motor is made iszero.

    So, the motor is off. If the port pin output is at logic 0, then

    pnp transistor is on. So, the transistor allows the currentthrough the motor and the motor is on. If the motor supply voltage is higher, then the circuit shown

    is used. This circuit uses two transistors one pnp and the other npn.

    In the circuit, a 12 V DC motor is interfaced to amicrocontroller pin.

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    59/98

    Circuit diagram for interfacing 12V DCmotor

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    60/98

    Interfacing DC motors When the port pin is set i.e. at 5 V, the p-n-p transistor is off

    which means the n-p-n transistor is also off. Therefore there is no path for current through the motor

    and the motor is off. When the port pin is cleared, the p-n-p transistor is on. This

    turns on the n-p-n transistor which allows current to flowthrough the motor to ground; the motor is on.

    The value of R2 needs to be chosen such that it will not be

    too high or too low.

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    61/98

    Interfacing DC motors

    High value of R2 will make the current into the base of the n-p-n transistor to be low so that it will not be enough to turnon the npn transistor. Too low value of R2 will result toomuch current through the motor.

    Bi-directional DC Motor control: A circuit diagram forinterfacing a 12V DC motor to a microcontroller in a way thatallows the controller to not only turn on and off the motorbut also to set the direction in which the motor runs when itis on

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    62/98

    Circuit diagram for driving 12V DCmotor bidirectional

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    63/98

    Interfacing DC motors The circuit is made up of a four transistor H-bridge. To run

    the motor in one direction, the transistors T1 and T4 areturned on and T2 and T3 are turned off.

    The left side of the motor is at 12 V and the right side is at

    ground and the motor runs in one direction. To reverse the direction, the transistors T2 and T3 are

    turned on and the other two transistors in the H bridge areoff.

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    64/98

    Interfacing DC motors

    If T3 and T2 are on, then the left side of the motor is atground and the right side is at 12 V, therefore the motor runsin the opposite direction.

    If both terminals of the motor are at the same voltage, themotor is off. So, if T1 and T3 are on, both sides of the motorare connected to 12 V and the motor is off.

    If T2 and T4 are on, both sides of the motor are connected to

    ground and the motor is off.

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    65/98

    Interfacing DC motors The circuit is designed so that T1 and T2 cannot be on at the

    same time and T3 and T4 cannot be on at the same time. This is very important; if T1 and T2 were on at the same time

    there would be a short circuit between 12 V and ground andthe transistors would burn out.

    The same is true for T3 and T4. The truth table for the circuitwith its two inputs, A and B, is given below.

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    66/98

    Bidirectional motor control modes

    An explanation of the four entries in the table is given below: Mode 0:

    With A at 0 (i.e. ground) T5 is on, which turns on T2; left side ofmotor is at ground. A at 0 also means T6 is off. Since there is no

    path for current through R3 and R4 there is no voltage dropacross them which in turn mean the base of T1 is at 12 V, henceit is off.

    The right-hand side of the circuit is a mirror image of the left,therefore with B at 0, T4 is on and T3 is off - hence the rightside of the motor is also at ground; the motor is off.

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    67/98

    Bidirectional motor control modes Mode 1:

    A is still at 0 which means T1 is still off and T2 is still on; the leftside of the motor is at ground.

    With B at 5 V (ie; logic 1 on the port pin which is being used forB) T7 is off which means T4 is off. But T8 is on, which generates

    a path for current through T8 to ground and also through R9 tothe base of T3. There is a certain amount of voltage droppedacross R9, but the base of T3 is close enough to ground for T3to turn on; the right side of the motor is at 12 V.

    The motor is therefore on and we stated above that ground onthe left of the motor and 12 V on the right would be calledreverse.

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    68/98

    Bidirectional motor control modes

    Mode 2: This is the mirror image of mode 1, resulting in T1 on, T2 off, T3

    off and T4 on; hence the left side of the motor is at 12 V andthe right side is at ground - the motor runs forward.

    Mode 3: As in mode 2, with A at 5 V the left side of the motor is at 12 V. As in mode 1, with B at 5 V the right side of the motor is at 12

    V. Therefore the motor is off.

    Oxford University Press 2013

    Mi t ll A li ti

  • 8/12/2019 354 33 Powerpoint-slides CH12

    69/98

    Microcontroller ApplicationExample - Stopwatch

    Figure shows the complete circuit diagram for a stop watch. The circuit basically consists of 4 sets of seven segment LEDs

    connected through the BCD to seven segment display codeconverter. This code converter IC 7448 can also act as a driver for

    display segments. The other circuit arrangements are forpower ON reset and clock signals.

    Oxford University Press 2013

    Ci it di g f Ti / St t h

  • 8/12/2019 354 33 Powerpoint-slides CH12

    70/98

    Circuit diagram for Timer/ Stopwatch

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    71/98

    Circuit - Description The circuit with R and C will have zero volts when the power is

    OFF. When the power is switched ON, the capacitor will startcharging and will gradually rise towards the supply voltage of5V.

    This will apply a logic high voltage of 5V and gradually

    decreasing towards 0V at the RST pin. The RST is the active high reset signal and has to be applied for

    at least 24 clock periods. The RC combination and the timeconstant will ensure that the active high reset signal is appliedfor at least 24 clock periods.

    The microcontroller chip has in built clock oscillator and it isenough to connect the crystal to the XTAL1 and XTAL2 pins.

    Oxford University Press 2013

    Ci i D i i

  • 8/12/2019 354 33 Powerpoint-slides CH12

    72/98

    Circuit - Description

    The circuit consists of 4 seven segment displays. Fordisplaying numerals in the 4 displays, we have to connect thepins of two ports to the display code converter.

    Here, the port pins of P0 and P1 are used. The BCD data ofthe display is given to the port pins.

    For the stop watch operation, an additional switch is neededto switch on and off counting in the stopwatch.

    A separate push to on switch is connected to the LSB ofPort2.

    The voltage on this pin can be sensed to control the countingand displaying in the seven segment displays

    Oxford University Press 2013

    Ci i D i i

  • 8/12/2019 354 33 Powerpoint-slides CH12

    73/98

    Circuit - Description

    The software part of the stopwatch consists of having atimer register incremented at regular intervals. The intervalcan be programmed to be either (1/10)th of a second oreven 1 second.

    With the interval of (1/10)th of a second and 4 digit display,the hardware arrangement can be used to count up to 999seconds with another digit for (1/10)th of second.

    With the interval of 1 second, the hardware arrangementscan count up to 9999 seconds.

    The timer register can be programmed to generate aninterrupt after every interval.

    Oxford University Press 2013

    Ci i D i i

  • 8/12/2019 354 33 Powerpoint-slides CH12

    74/98

    Circuit - Description

    The flowchart for the stopwatch example is given in thefigure . The programming part consists of first initialising atimer for the required time interval.

    The display is also initialized to display all zeros. Then, thestatus of the switch is sensed from the port 2 LSB.

    If the switch is pressed, then the program moves to the nextstep of starting the timer and giving data output to the

    displays.

    Oxford University Press 2013

  • 8/12/2019 354 33 Powerpoint-slides CH12

    75/98

    Flowchart for the stopwatch

    Oxford University Press 2013

    Fl h D i i

  • 8/12/2019 354 33 Powerpoint-slides CH12

    76/98

    Flowchart - Description

    Otherwise, the program keeps looping in the status check onP2.0. After every timer overflow, the data for display isincremented and the data is converted in to the BCD data.

    The new data is given to the port pins by writing them to the

    port registers. The increment of data in the display occursuntil the switch on the P2.0 is pressed. The hardware, flowchart and the program can be improved

    further to have more additional features like resetting thedisplay, separate switches for start and stop of stopwatch,using press to on and press to off of stopwatch, etc,.

    Oxford University Press 2013

    Microcontroller Application

  • 8/12/2019 354 33 Powerpoint-slides CH12

    77/98

    Microcontroller Application -Traffic light control

    Oxford University Press 2013

    Figure shows the basic traffic control signals at a four road junction. The following assumptions are made for designingthe traffic light control.

    There are free left turns in all the four directions.. Each sequence will again will have two combinations of

    traffic signals - one for red and Green combination and otherfor red, green and yellow combination.

    Traffic light controls at four road

  • 8/12/2019 354 33 Powerpoint-slides CH12

    78/98

    Traffic light controls at four roadjunction

    Oxford University Press 2013

    T ffi li ht t l 1

  • 8/12/2019 354 33 Powerpoint-slides CH12

    79/98

    Traffic light control sequence 1

    Oxford University Press 2013

    T ffi li ht t l 2

  • 8/12/2019 354 33 Powerpoint-slides CH12

    80/98

    Traffic light control sequence 2

    Oxford University Press 2013

    T ffi light t l 3

  • 8/12/2019 354 33 Powerpoint-slides CH12

    81/98

    Traffic light control sequence 3

    Oxford University Press 2013

    T ffi light t l 4

  • 8/12/2019 354 33 Powerpoint-slides CH12

    82/98

    Traffic light control sequence 4

    Oxford University Press 2013

    Hardware connection diagram for

  • 8/12/2019 354 33 Powerpoint-slides CH12

    83/98

    Hardware connection diagram forTraffic lights

    Oxford University Press 2013

    Description

  • 8/12/2019 354 33 Powerpoint-slides CH12

    84/98

    Description

    The traffic light control using microcontroller can be doneeasily by using parallel ports. The port pins can be connectedto each light or LED or group of LEDs through a proper drivercircuit.

    The data in the parallel port can be changed using theprogram for turning ON and OFF of the proper lights.

    Figure shows the connection diagram for all the lights -assumed here as LEDs. The port pins of Port 0 and port 1 areused. Port 0 LSB three bits are used for West direction. Port0 pins 3, 4, 5 are used North direction.

    Oxford University Press 2013

    Description

  • 8/12/2019 354 33 Powerpoint-slides CH12

    85/98

    Description Similarly, Port 1 LSB 3 bits are used for lights in East direction

    and pins 3, 4, 5 are used for south direction. The reset pins and clock inputs are connected to the

    corresponding circuit.

    Oxford University Press 2013

    Data for Port Pins for Traffic Light

  • 8/12/2019 354 33 Powerpoint-slides CH12

    86/98

    Data for Port Pins for Traffic LightControl

    Oxford University Press 2013

    Microcontroller Application

  • 8/12/2019 354 33 Powerpoint-slides CH12

    87/98

    Microcontroller Application -Thermometer

    Temperature measurement is one of the most common tasksin the industries.

    The thermistor (temperature-sensitive resistors) is anelectrical component capable of measuring temperature

    variations, relying on the change in its resistance withchanging temperature.

    Once calibrated against the thermistor equation, it ispossible to electronically determine the temperature around

    the thermistor, by measuring the change in voltage across itas its resistance changes.

    Oxford University Press 2013

    Thermometer Introduction

  • 8/12/2019 354 33 Powerpoint-slides CH12

    88/98

    Thermometer - Introduction

    The thermistors operate in the limited temperature range(typically -80 to 150C). The significant advantages ofthermistor as a tool for temperature measurement are

    A large output signal that results in better precision Greater stability, providing accurate performance for longer

    periods of time Higher accuracy than thermocouples in mid-range

    temperatures

    Oxford University Press 2013

    Thermometer Introduction

  • 8/12/2019 354 33 Powerpoint-slides CH12

    89/98

    Thermometer - Introduction Most thermistors have a negative temperature coefficient

    (NTC), meaning the resistance goes up as temperature goesdown.

    Of all passive temperature measurement sensors,thermistors have the highest sensitivity (resistance change

    per degree of temperature change). Thermistors do not have a linear temperature/resistance

    curve. The nonlinear curve of resistance against temperatureis given in figure.

    The figure shows the normalized resistance variation withreference to resistance at 25C.

    Oxford University Press 2013

    Resistance variation of Thermistor

  • 8/12/2019 354 33 Powerpoint-slides CH12

    90/98

    Resistance variation of Thermistorwith Temperature

    Oxford University Press 2013

    Thermometer Introduction

  • 8/12/2019 354 33 Powerpoint-slides CH12

    91/98

    Thermometer - Introduction

    Oxford University Press 2013

    The Steinhart-Hart equation is widely used to approximate the

    temperature, T , of a thermistor as a cubic function of thelogarithm of its resistance, RT . It is written as

    where a, b, and c are physical constants depending on the system.Within the small temperature range of 30 to 100 degree Celsius, thefurther linear approximation as followed can be done.

    Circuit Description

  • 8/12/2019 354 33 Powerpoint-slides CH12

    92/98

    Circuit - Description

    Figure shows a simple circuit that could be used to allow amicroprocessor to measure temperature using a thermistor.

    A resistor (R1) pulls the thermistor up to a reference voltage.This is typically the same as the ADC reference, so Vref

    would be 5V if the ADC reference were 5V. This thermistor circuit has a nominal resistance value of 10

    k at 25 C, and varies from 330 k at 40C down to 200 at 150C, a range of 1650:1. Such a huge dynamic range in

    output resistance can make measurement difficult.

    Oxford University Press 2013

    Simple circuit to measure

  • 8/12/2019 354 33 Powerpoint-slides CH12

    93/98

    Simple circuit to measuretemperature using thermistor

    Oxford University Press 2013

    Circuit Description

  • 8/12/2019 354 33 Powerpoint-slides CH12

    94/98

    Circuit - Description

    It's possible to perform a "good enough" linearization byadding some very inexpensive circuitry.

    One way is to incorporate the thermistor into a Wheatstonebridge

    But this arrangement provides an essentially linear outputvoltage in response to small changes in resistance.

    The linearity in the desired range of temperature can beachieved by changing the value of R in the bridge circuit.

    Oxford University Press 2013

    Circuit diagram for temperature

  • 8/12/2019 354 33 Powerpoint-slides CH12

    95/98

    g pmeasurement using Microcontroller

    Oxford University Press 2013

    Description

  • 8/12/2019 354 33 Powerpoint-slides CH12

    96/98

    Description Figure shows the complete interfacing arrangement for the

    temperature measurement using the thermistor and an ADCwith 8051 microcontroller.

    The ADC 0804 is used in this circuit. This is an ADC chip withsingle analog input.

    The commonly used pins alone are shown in the figure. The

    analog input can be converted into digital equivalent byproviding a Start Conversion (SC) signal to the ADC chip.

    The end of Conversion can be sensed on a separate port pin.After the end of conversion, the data on the DB0- DB7 linescan be read by applying a Read signal to the RD pin of ADCchip.

    The digital data received can be properly converted into thedisplay data and can be given to the LCD screen.

    Oxford University Press 2013

    Algorithm

  • 8/12/2019 354 33 Powerpoint-slides CH12

    97/98

    Algorithm

    The software part of this temperature measurement routinewill have the following steps. Clear Display Give start Conversion signal Check for End of Conversion Read data from ADC (temperature) Convert to corresponding display data of temperature using

    the look-up table concept Display temperature

    Oxford University Press 2013

    Algorithm

  • 8/12/2019 354 33 Powerpoint-slides CH12

    98/98

    Algorithm The algorithm explained above uses the simple I/O interface.

    The program can be made more efficient by using Interrupts. The End of Conversion (EOC) signal can be connected to an

    interrupt input of the processor. At every end of conversion, the program can read and

    display temperature and once again initiate the conversionprocess.

    The circuit arrangement shown in figure can be used for anymeasurement.

    Instead of thermistor and bridge arrangement, proper circuitmust be provided for the measurement of the physicalquantities.