hardware lec2

Upload: hesham1216

Post on 10-Apr-2018

222 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/8/2019 Hardware Lec2

    1/40

    Hardware Design

    Amr Mokhtar

  • 8/8/2019 Hardware Lec2

    2/40

    Agenda

    Introduction

    I/O ports: LED, Switch and Relay

    Keypad

    7-Seg. Display

    LCD Display DC Motor

    Stepper Motor

    Sensors

    RS-232

    I2C

    Copyright 2009 Embedded

    Systems Committee

  • 8/8/2019 Hardware Lec2

    3/40

    Agenda

    Introduction

    I/O ports: LED, Switch and Relay

    Keypad

    7-Seg. Display

    LCD Display DC Motor

    Stepper Motor

    Sensors

    RS-232

    I2C

    Copyright 2009 Embedded

    Systems Committee

  • 8/8/2019 Hardware Lec2

    4/40

    Basic Control System

    Copyright 2009 Embedded

    Systems Committee

    Plant

    Process

    Sensor

    Actuator

    Controller

  • 8/8/2019 Hardware Lec2

    5/40

    Microcontroller Peripherals

    Power - Vcc, GND, AVcc, Aref, AGND

    Reset - RESET

    Crystal - XTAL1, XTAL2

    I/O Port - PA[7;0], PB[7:0], PC[7:0],

    External interrupts - INT0, INT1,

    Timer sources - T0, T1,

    Timer/Counters with Prescalers, Compare Modes and Capture Mode

    PWM Channels

    ADC

    Two-wire Serial Interface (TWI or I2C) - SDA, SCL

    Programmable Serial USART - RXD, TXD

    Master/Slave SPI Serial Interface - MISO, MOSI, SCK, CS Programmable Watchdog Timer

    On-chip Analog Comparator

    Copyright 2009 Embedded

    Systems Committee

  • 8/8/2019 Hardware Lec2

    6/40

    Power Supply Circuit

    Copyright 2009 Embedded

    Systems Committee

  • 8/8/2019 Hardware Lec2

    7/40

    Basic Circuit

    Copyright 2009 Embedded

    Systems Committee

    Reset Circuit

    Oscillator Circuit

  • 8/8/2019 Hardware Lec2

    8/40

    Agenda

    Introduction

    I/O ports: LED, Switch and Relay

    Keypad

    7-Seg. Display

    LCD Display

    DC Motor

    Stepper Motor

    Sensors

    RS-232

    I2C

    Copyright 2009 Embedded

    Systems Committee

  • 8/8/2019 Hardware Lec2

    9/40

    I/O PORTS: LED

    Copyright 2009 Embedded

    Systems Committee

    Switch Interfacing Power LED InterfacingLow power LED

  • 8/8/2019 Hardware Lec2

    10/40

    I/O PORTS: SWITCH

    Copyright 2009 Embedded

    Systems Committee

    Reading digital signal (using Opto-Isolation)

  • 8/8/2019 Hardware Lec2

    11/40

    I/O PORTS: RELAY

    Copyright 2009 Embedded

    Systems Committee

    RELAY ON I/O PORT USING ULN

    fly-back diode

  • 8/8/2019 Hardware Lec2

    12/40

    Agenda

    Introduction

    I/O ports: LED, Switch and Relay

    Keypad

    7-Seg. Display

    LCD Display

    DC Motor

    Stepper Motor

    Sensors

    RS-232

    I2C

    Copyright 2009 Embedded

    Systems Committee

  • 8/8/2019 Hardware Lec2

    13/40

    KEYPAD

    Copyright 2009 Embedded

    Systems Committee

    A switch cannot change state in less than 200 ms A periodic scan is performed, each row is enabled in turn, and the

    four buttons of a row are scanned Debouncing also must be carried out (software in 99% of the cases) The solution clearly saves 50% of I/O pins !

    Row outputs

    Row enables

  • 8/8/2019 Hardware Lec2

    14/40

    Switch Debouncing

    Could be done in software or hardware

    It relies on the fact that bouncing takes amaximum period of 20-30 ms

    The basic idea is to implement a delay after thefirst detected edge, during which no scanning forthe switch is done

    After the delay period is finished, scanning canproceed

    This way the bouncing can be avoided

    Copyright 2009 Embedded

    Systems Committee

  • 8/8/2019 Hardware Lec2

    15/40

    Switch Debouncing..

    Switch bouncing effect

    Charging eq. discharging eq.

    &

    MC14490 Hex Contact Bounce Eliminator ChipMAX6816-MAX6818 Switch Debouncers

    Copyright 2009 Embedded

    Systems Committee

  • 8/8/2019 Hardware Lec2

    16/40

    Agenda

    Introduction

    I/O ports: LED, Switch and Relay

    Keypad

    7-Seg. Display

    LCD Display

    DC Motor

    Stepper Motor

    Sensors

    RS-232

    I2C

    Copyright 2009 Embedded

    Systems Committee

  • 8/8/2019 Hardware Lec2

    17/40

    7-segment display

    LED displays are

    1. Power-hungry (10mA per LED)

    2. Pin-hungry (8 pins per 7-seg display)

    Copyright 2009 Embedded

    Systems Committee

  • 8/8/2019 Hardware Lec2

    18/40

    7-segment display..

    Segment number pin number

    a PA.0

    b PA.1

    c PA.2

    d PA.3

    e PA.4

    f PA.5

    g PA.6

    dp PA.7

    Copyright 2009 Embedded

    Systems Committee

    Digit Seg. h Seg. g Seg. f Seg. e Seg. d Seg. c Seg. b Seg. a HEX

    0 1 1 0 0 0 0 0 0 C0

    1 0 0 0 0 0 1 1 0 06

    2 1 0 1 0 0 1 0 0 A4

    3 1 0 1 1 0 0 0 0 B0

    4 1 0 0 1 1 0 0 1 99

    Using software

  • 8/8/2019 Hardware Lec2

    19/40

    7-segment display..

    Copyright 2009 Embedded

    Systems Committee

    Using 7-segment decoder

  • 8/8/2019 Hardware Lec2

    20/40

    Multiplexed 7-seg display

    Copyright 2009 Embedded

    Systems Committee

    A normal human eye recognizes about 25 images persecond

    A LED flashing at a faster rate (> 50) is recognized assteady and not flashing

    Instead, the eye recognizes the average light emittedas steady light

    7-seg current supply and number ofsegments.. Tradeoff & limited !

  • 8/8/2019 Hardware Lec2

    21/40

    Agenda

    Introduction

    I/O ports: LED, Switch and Relay

    Keypad

    7-Seg. Display

    LCD Display

    DC Motor

    Stepper Motor

    Sensors

    RS-232

    I2C

    Copyright 2009 Embedded

    Systems Committee

  • 8/8/2019 Hardware Lec2

    22/40

    LCD

    8 data pins D7:D0Bi-directional data/command pins.

    RS: Register SelectRS = 0 -> Command Register is selected

    RS = 1 -> Data Register is selected

    R/W: Read or Write0 -> Write, 1 -> Read

    E: Enable (Latch data)To latch the data present on the data pins.

    Vo : contrast control

    Copyright 2009 Embedded

    Systems Committee

  • 8/8/2019 Hardware Lec2

    23/40

    Agenda

    Introduction

    I/O ports: LED, Switch and Relay

    Keypad

    7-Seg. Display

    LCD Display

    DC Motor

    Stepper Motor

    Sensors

    RS-232

    I2C

    Copyright 2009 Embedded

    Systems Committee

  • 8/8/2019 Hardware Lec2

    24/40

  • 8/8/2019 Hardware Lec2

    25/40

    2. PWM Control of DC Motor

    Copyright 2009 Embedded

    Systems Committee

    PWM means how fast we turn the motor ON and OFF

    The motor will take the average current

    Lower frequency PWM gives better efficiency

    Using as high a frequency as possible is better for the

    motor

    BUT, too high frequency, the H-bridge efficiency starts to

    suffer

    Usually, 1 to 4 kilohertz is good even though the motorswill make an irritating whine

    Big capacitors across the motor terminals help a littlespecially for higher PWM frequencies

  • 8/8/2019 Hardware Lec2

    26/40

    2. PWM Control of DC Motor..

    Copyright 2009 Embedded

    Systems Committee

  • 8/8/2019 Hardware Lec2

    27/40

    Bidirectional DC Motor Control

    Copyright 2009 Embedded

    Systems Committee

    DUAL FULL-BRIDGE DRIVER (L298)

  • 8/8/2019 Hardware Lec2

    28/40

    Shaft Encoders

    Absolute encoder

    The encoder is 3-bits, meaning that it

    divides the circle into 8-sectors

    Differential encoder How to determine direction of rotation ?

    Copyright 2009 Embedded

    Systems Committee

    A pair of LEDs is used having a 90phase difference between them

  • 8/8/2019 Hardware Lec2

    29/40

    Agenda

    Introduction

    I/O ports: LED, Switch and Relay

    Keypad

    7-Seg. Display

    LCD Display

    DC Motor

    Stepper Motor

    Sensors

    RS-232

    I2C

    Copyright 2009 Embedded

    Systems Committee

  • 8/8/2019 Hardware Lec2

    30/40

    Stepper Motor

    Basic Sequence: 0001

    0010

    0100

    1000

    Half-Stepping sequence: 0001

    0011

    0010

    0110

    0100

    1100

    1000

    1001

    The frequency of the sequence determines the speed

    of the motor The order of the sequence determines the direction of

    rotation

    Copyright 2009 Embedded

    Systems Committee

  • 8/8/2019 Hardware Lec2

    31/40

    Stepper Motor..

    Copyright 2009 Embedded

    Systems Committee

  • 8/8/2019 Hardware Lec2

    32/40

    Agenda

    Introduction

    I/O ports: LED, Switch and Relay

    Keypad

    7-Seg. Display

    LCD Display

    DC Motor

    Stepper Motor

    Sensors

    RS-232

    I2C

    Copyright 2009 Embedded

    Systems Committee

  • 8/8/2019 Hardware Lec2

    33/40

    Sensors

    Copyright 2009 Embedded

    Systems Committee

    LM335 Vs. LM35as analog temperature sensors

  • 8/8/2019 Hardware Lec2

    34/40

    Agenda

    Introduction

    I/O ports: LED, Switch and Relay

    Keypad

    7-Seg. Display

    LCD Display

    DC Motor

    Stepper Motor

    Sensors

    RS-232

    I2C

    Copyright 2009 Embedded

    Systems Committee

  • 8/8/2019 Hardware Lec2

    35/40

    UART

    The tasks of serial communications needs a dedicated hardware

    circuit

    The circuit needs good synchronization between Tx and Rx so

    standard baud rates exist in order to standardize serialcommunications, as:

    100, 200, 300, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200bps

    Copyright 2009 Embedded

    Systems Committee

    MCU Device

    TX

    RX

    RX

    TX

  • 8/8/2019 Hardware Lec2

    36/40

    RS-232

    Copyright 2009 Embedded

    Systems Committee

    Standard serial interfacing of

    microcontroller (TTL) with PCor any RS232C Standarddevice , requires TTL to RS232

    Level converter

    RS-232 Voltage levels

    1. +3 to +25 volts to signify a"Space" (Logic 0)

    2. -3 to -25 volts for a "Mark"(logic 1)

    3. Any voltage in between theseregions (i.e. between +3 and-3 Volts) is undefined.

    MAX232 is used

  • 8/8/2019 Hardware Lec2

    37/40

    Agenda

    Introduction

    I/O ports: LED, Switch and Relay

    Keypad

    7-Seg. Display

    LCD Display

    DC Motor

    Stepper Motor

    Sensors

    RS-232

    I2C

    Copyright 2009 Embedded

    Systems Committee

  • 8/8/2019 Hardware Lec2

    38/40

    Inter Integrated Circuit I2C

    Copyright 2009 Embedded

    Systems Committee

  • 8/8/2019 Hardware Lec2

    39/40

    Thank you for coming, listening &

    pat ie nce . !

  • 8/8/2019 Hardware Lec2

    40/40

    info@ e scommit t e e . com

    e ducat ion@e scommit t e e . com

    mailto:[email protected]:[email protected]:[email protected]:[email protected]