8/2/2019 The Human and Physical Interfaces
1/56
The human and
physical interfaces
Chapter Eight
8.1 8.9
Dr. Gheith Abandah 1
8/2/2019 The Human and Physical Interfaces
2/56
Outline
Introduction
Keypads
Seven-segment displays LCDs
Sensors
Actuators Summary
Dr. Gheith Abandah 2
8/2/2019 The Human and Physical Interfaces
3/56
Introduction
A human interface is an important partof most embedded systems.
Users need to conveniently get
information from the embedded system. They also need to conveniently control
the operation of this system.
Examples: Domestic fridge
Photocopier
Car dashboard
Dr. Gheith Abandah 3
8/2/2019 The Human and Physical Interfaces
4/56
Human Interface - Examples
Dr. Gheith Abandah 4
8/2/2019 The Human and Physical Interfaces
5/56
8/2/2019 The Human and Physical Interfaces
6/56
Human interface types
Input:
Switch
Push button
Keypad
Output:
light-emittingdiode (LED)
Seven-segmentLED
Liquid crystal
display (LCD)
Dr. Gheith Abandah 6
8/2/2019 The Human and Physical Interfaces
7/56
The LED version of theDerbot AGV
Dr. Gheith Abandah 7
8/2/2019 The Human and Physical Interfaces
8/56
The LCD version of theDerbot AGV
Dr. Gheith Abandah 8
8/2/2019 The Human and Physical Interfaces
9/56
The Keypad
Dr. Gheith Abandah 9
8/2/2019 The Human and Physical Interfaces
10/56
Flowdiagram
Reading akeypad witha
microcontroller port
Dr. Gheith Abandah 10
8/2/2019 The Human and Physical Interfaces
11/56
Outputs for the keypad
Port Bit Function
7 Row 1
6 Row 2
5 Row 34 Row 4
3 Column 1
2 Column 2
1 Column 3
0 Unused
Dr. Gheith Abandah 11
8/2/2019 The Human and Physical Interfaces
12/56
Flow diagram of programexample
Dr. Gheith Abandah 12
8/2/2019 The Human and Physical Interfaces
13/56
Keypad Example Initialization
;Initialize
bsf status,rp0 ;select memory bank 1
movlw B'11110000' ;Port B initially Row bits
;are input, column output
movwf trisb
bcf status,rp0 ;select bank 0
...
clrf portb ;initialize keypad value
bcf intcon,rbif ;enable interrupt bsf intcon,rbie
bsf intcon,gie
loop
goto loop ;await keypad entriesDr. Gheith Abandah 13
8/2/2019 The Human and Physical Interfaces
14/56
8/2/2019 The Human and Physical Interfaces
15/56
Keypad Example Readkeypad
kpad_rd
movf portb,w ;read portb value, row pattern
andlw B'11110000' ;suppress unwanted bits
movwf kpad_pat
bsf status,rp0 ;set row to op, column to ip
movlw B'00001110'
movwf trisb
bcf status,rp0
movlw 00 movwf portb ;ensure output values still 0
movf portb,w ;read portb value, col. pattern
andlw B'00001110' ;suppress unwanted bits
iorwf kpad_pat,1 ;OR results into the patternDr. Gheith Abandah 15
8/2/2019 The Human and Physical Interfaces
16/56
Keypad Example Readkeypad 2
;reset keypad interface
bsf status,rp0 ;set row to ip, column to op
movlw B'11110000'
movwf trisb
bcf status,rp0
clrf portb ;ensure output values still 0
return
Dr. Gheith Abandah 16
8/2/2019 The Human and Physical Interfaces
17/56
Seven-segment displays
Dr. Gheith Abandah 17
Common
Anode
CommonCathode
8/2/2019 The Human and Physical Interfaces
18/56
Connecting multiple digits
Dr. Gheith Abandah 18
Need 1.2 k
line resistors
8/2/2019 The Human and Physical Interfaces
19/56
Timing diagram
Dr. Gheith Abandah 19
8/2/2019 The Human and Physical Interfaces
20/56
7-seg. display example page 1
Dr. Gheith Abandah 20
8/2/2019 The Human and Physical Interfaces
21/56
7-seg. display example page 2
;Initialise
bcf status,rp1
bsf status,rp0;bank 1
movlw B00000000 ;out
movwf trisa
movwf trisb
movwf trisc
bcf status,rp0;bank 0
;
loop
;set digit 1
movlw B'00011101' ;H
movwf porta
bcf portc,6 ;seg a
bsf portc,7 ;seg b
bsf portc,1 ;dig 1
call delay5
bcf portc,1;set digit 2
goto loop
Dr. Gheith Abandah 21
8/2/2019 The Human and Physical Interfaces
22/56
Liquid crystal displays(LCDs)
Liquid crystal responds to an appliedelectric field by changing the alignment ofits molecules, and in so doing changing
the direction of the light polarization thatit introduces.
Liquid crystal can be trapped between twoparallel sheets of glass, with a matching
pattern of transparent electrode on eachsheet.
When a voltage is applied to the
electrodes, the optical character of theDr. Gheith Abandah 22
8/2/2019 The Human and Physical Interfaces
23/56
Interfacing with LCDs
Hitachi developed a specialmicrocontroller (HD44780) forinterfacing LCDs.
This microcontroller is usuallyintegrated with LCDs.
Features:
8- or 4-bit data transfer
Simple instruction set to initialize, clear,display, and position cursor
Has instruction register and dataDr. Gheith Abandah 23
8/2/2019 The Human and Physical Interfaces
24/56
HD44780 timing diagram
Dr. Gheith Abandah 24
8/2/2019 The Human and Physical Interfaces
25/56
Derbots LCD
Dr. Gheith Abandah 25
Each digit
is a liquidcrystal dot
matrix
8/2/2019 The Human and Physical Interfaces
26/56
LCD Drive Example Page 1
lcd_write
call busy_check
bcf portc,lcd_rw
bcf status,crrf lcd_op,1
bcf portc,6
btfsc status,c
bsf portc,6
bcf status,c
rrf lcd_op,1
bcf portc,7
btfsc status,c bsf portc,7
movf lcd_op,0
movwf porta
bsf portc,lcd_E
bcf portc,lcd_E
return
Dr. Gheith Abandah 26
8/2/2019 The Human and Physical Interfaces
27/56
LCD Drive Example Page 2
busy_check
bsf status,rp0 ;bank 1
movlw B'00111111' ;set port A all ip
movwf trisa bcf status,rp0
bcf flags,0
btfsc portc,lcd_RS ;save RS in flags, 0
bsf flags,0
bcf portc,lcd_RS ;access instr register
bsf portc,lcd_RW ;set to read
Dr. Gheith Abandah 27
8/2/2019 The Human and Physical Interfaces
28/56
LCD Drive Example Page 3
busy_loop
bcf portc,lcd_E
bsf portc,lcd_E
btfsc porta,lcd_busy ;test the busy flag
goto busy_loop
bcf portc,lcd_E
bsf status,rp0 ;select memory bank 1
movlw B'00000000 ;set port A all op
movwf trisa bcf status,rp0
bcf portc,lcd_RS
btfsc flags,0 ;reinstate RS bit
bsf portc,lcd_RS
return Dr. Gheith Abandah 28
8/2/2019 The Human and Physical Interfaces
29/56
Sensors
Convert physical variables toelectrical.
Examples:
The microswitch
Light-dependent resistor
Ultrasonic object sensor
Dr. Gheith Abandah 29
8/2/2019 The Human and Physical Interfaces
30/56
The Microswitch
Dr. Gheith Abandah 30
8/2/2019 The Human and Physical Interfaces
31/56
Light-dependent resistors
A light-dependentresistor (LDR) ismade from a pieceof exposedsemiconductormaterial. When lightfalls on it, it createsholeelectron pairsin the material,which improve theconductivity.
20M to a fewhundred ohms
Dr. Gheith Abandah 31
8/2/2019 The Human and Physical Interfaces
32/56
Optical object sensingInfrared LED and phototransistor
Dr. Gheith Abandah 32
8/2/2019 The Human and Physical Interfaces
33/56
The opto-sensor applied asa shaft encoder
Dr. Gheith Abandah 33
8/2/2019 The Human and Physical Interfaces
34/56
Ultrasonic object sensor
Dr. Gheith Abandah 34
8/2/2019 The Human and Physical Interfaces
35/56
Digitalinput
If amicrocontrolleris to receivelogic signals,
then it isessential thatthose signals
are at voltagelevels whichare recognizedby it as being
either Logic 0 Dr. Gheith Abandah 35
8/2/2019 The Human and Physical Interfaces
36/56
Forms of signal corruption
Dr. Gheith Abandah 36
(a) Spikes in signal, potentially harmful to device input. (b) Spikes in
signal.
(c) Excessively slow edges. (d) DC offset in signal.
8/2/2019 The Human and Physical Interfaces
37/56
Input protection
For Rprot = 1K and
max. diode current=20 mA
What is themaximum voltagespike?
Vmax =
[(20mA 1 k ) +5.3]
= 25VDr. Gheith Abandah 37
8/2/2019 The Human and Physical Interfaces
38/56
Ensuring legal logic levels
Can use Schmitttrigger forspeeding up slow
logic edges. Schmitt trigger
with RC filter canbe used to filter
voltage spikes. Digital filtering:
sample the input
three times and Dr. Gheith Abandah 38
8/2/2019 The Human and Physical Interfaces
39/56
8/2/2019 The Human and Physical Interfaces
40/56
Switch bouncing
Dr. Gheith Abandah 40
H d i h
8/2/2019 The Human and Physical Interfaces
41/56
Hardware switchdebouncing
Dr. Gheith Abandah 41
8/2/2019 The Human and Physical Interfaces
42/56
Software switch debouncing
Dr. Gheith Abandah 42
Typically
10 ms
A t t t d
8/2/2019 The Human and Physical Interfaces
43/56
Actuators: motors andservos
Often need tocause physicalmovement
For linearmovement usesolenoids
For angular
movement, useservos
For angular or
rotary, use DC orDr. Gheith Abandah 43
8/2/2019 The Human and Physical Interfaces
44/56
Comparison
DC Motors
Range from theextremely powerful to
the very small Wide speed range
Controllable speed
Good efficiency
Can provide accurateangular positioningwith angular shafts
Only the armature
winding needs to be
Stepper Motors
Simple interface withdigital systems
Can control speed andposition
Awkward start-upcharacteristics
Lose torque at highspeed
Limited top speed
Less efficient
More complex to driveDr. Gheith Abandah 44
8/2/2019 The Human and Physical Interfaces
45/56
Derbot DC Motor
Dr. Gheith Abandah 45
S i t d t t
8/2/2019 The Human and Physical Interfaces
46/56
Servo input and outputcharacteristics
Dr. Gheith Abandah 46
8/2/2019 The Human and Physical Interfaces
47/56
Interfacing to actuators
Simple DC switching
Bipolar transistors
MOSFET transistors
Reversible switching
The H-bridge
Dr. Gheith Abandah 47
Bi l t i t it hi
8/2/2019 The Human and Physical Interfaces
48/56
Bipolar transistor switchingof DC resistive loads
Dr. Gheith Abandah 48
MOSFET t i t it hi
8/2/2019 The Human and Physical Interfaces
49/56
MOSFET transistor switchingof DC resistive loads
Dr. Gheith Abandah 49
MOSFET t i t it hi
8/2/2019 The Human and Physical Interfaces
50/56
MOSFET transistor switchingof DC inductive loads
Dr. Gheith Abandah 50
aracter st cs o two
8/2/2019 The Human and Physical Interfaces
51/56
aracter st cs o twopopular logic-compatible
MOSFETs
Dr. Gheith Abandah 51
Dri ing pie o so nder and
8/2/2019 The Human and Physical Interfaces
52/56
Driving piezo sounder andopto-sensors
Dr. Gheith Abandah 52
I = (5 3.4)/91I = 17.6 mA
Reversible switching the H
8/2/2019 The Human and Physical Interfaces
53/56
Reversible switching: the H-bridge
Dr. Gheith Abandah 53
8/2/2019 The Human and Physical Interfaces
54/56
The L293D dual H-bridge
Dr. Gheith Abandah 54
The L293D applied in the
8/2/2019 The Human and Physical Interfaces
55/56
The L293D applied in theDerbot motor drive circuit
Dr. Gheith Abandah 55
8/2/2019 The Human and Physical Interfaces
56/56
Summary An embedded microcontroller must be able to
interface with the physical world and possiblythe human world as well.
Much human interfacing can be done withswitches, keypads and displays.
To interface with the physical world, themicrocontroller must be able to interface with arange of transducers. The designer needs anunderstanding of the main sensors andactuators available.
Interfacing with sensors requires a reasonableknowledge of signal conditioning techniques.
Top Related