Sie sind auf Seite 1von 40

Hardware Design

Amr Mokhtar
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
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
Basic Control System

• Plant
• Process
• Sensor
• Actuator
• Controller
Copyright © 2009 Embedded ٤
Systems Committee
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
Power Supply Circuit

Copyright © 2009 Embedded ٦


Systems Committee
Basic Circuit

Reset Circuit

Oscillator Circuit

Copyright © 2009 Embedded ٧


Systems Committee
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
I/O PORTS: LED

Switch Interfacing Low power LED Power LED Interfacing

Copyright © 2009 Embedded ٩


Systems Committee
I/O PORTS: SWITCH
• Reading digital signal (using Opto-Isolation)

Copyright © 2009 Embedded ١٠


Systems Committee
I/O PORTS: RELAY

RELAY ON I/O PORT USING ULN

fly-back diode

Copyright © 2009 Embedded ١١


Systems Committee
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
KEYPAD

Row outputs

Row enables

• 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 !

Copyright © 2009 Embedded ١٣


Systems Committee
Switch Debouncing
• Could be done in software or hardware
• It relies on the fact that bouncing takes a
maximum period of 20-30 ms
• The basic idea is to implement a delay after the
first detected edge, during which no scanning for
the switch is done
• After the delay period is finished, scanning can
proceed
• This way the bouncing can be avoided

Copyright © 2009 Embedded ١٤


Systems Committee
Switch Debouncing..

Switch bouncing effect

&
Charging eq. discharging eq.
MC14490 Hex Contact Bounce Eliminator Chip
MAX6816-MAX6818 Switch Debouncers

Copyright © 2009 Embedded ١٥


Systems Committee
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
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
7-segment display..
Segment number pin number

• Using software a
b
PA.0
PA.1
c PA.2
d PA.3
e PA.4
f PA.5
g PA.6
dp PA.7
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

Copyright © 2009 Embedded ١٨


Systems Committee
7-segment display..
• Using 7-segment decoder

Copyright © 2009 Embedded ١٩


Systems Committee
Multiplexed 7-seg display
• A normal human eye recognizes about 25 images per
second
• A LED flashing at a faster rate (> 50) is recognized as
steady and not flashing
• Instead, the eye recognizes the average light emitted
as steady light

• 7-seg current supply and number of


segments.. Tradeoff & limited !

Copyright © 2009 Embedded ٢٠


Systems Committee
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
LCD
• 8 data pins D7:D0
Bi-directional data/command pins.
• RS: Register Select
RS = 0 -> Command Register is selected
RS = 1 -> Data Register is selected
• R/W: Read or Write
0 -> Write, 1 -> Read
• E: Enable (Latch data)
To latch the data present on the data pins.
• Vo : contrast control

Copyright © 2009 Embedded ٢٢


Systems Committee
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
1. On/off Control of DC Motor

motor

Copyright © 2009 Embedded ٢٤


Systems Committee
2. PWM Control of DC Motor

• 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 motors
will make an irritating whine
• Big capacitors across the motor terminals help a little
specially for higher PWM frequencies
Copyright © 2009 Embedded ٢٥
Systems Committee
2. PWM Control of DC Motor..

Copyright © 2009 Embedded ٢٦


Systems Committee
Bidirectional DC Motor Control

DUAL FULL-BRIDGE DRIVER (L298)

Copyright © 2009 Embedded ٢٧


Systems Committee
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 ?
§ A pair of LEDs is used having a 90°
phase difference between them

Copyright © 2009 Embedded ٢٨


Systems Committee
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
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
Stepper Motor..

Copyright © 2009 Embedded ٣١


Systems Committee
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
Sensors

LM335 Vs. LM35


as analog temperature sensors

Copyright © 2009 Embedded ٣٣


Systems Committee
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
UART

TX RX

MCU Device

RX TX

• 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 serial
communications, as:
– 100, 200, 300, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200
bps
Copyright © 2009 Embedded ٣٥
Systems Committee
RS-232
• Standard serial interfacing of
microcontroller (TTL) with PC
or any RS232C Standard
device , 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 these
regions (i.e. between +3 and
-3 Volts) is undefined.

• MAX232 is used

Copyright © 2009 Embedded ٣٦


Systems Committee
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
Inter Integrated Circuit I2C

Copyright © 2009 Embedded ٣٨


Systems Committee
Thank you for coming, listening &
patience….!
info@escommittee.com

education@escommittee.com

Das könnte Ihnen auch gefallen