Top Banner
The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah 1
56

The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

Dec 19, 2015

Download

Documents

Harry James
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
Page 1: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

The human and physical interfaces

Chapter Eight8.1 – 8.9

Dr. Gheith Abandah 1

Page 2: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

Outline

• Introduction• Keypads• Seven-segment displays• LCDs• Sensors• Actuators• Summary

Dr. Gheith Abandah 2

Page 3: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

Introduction

• A human interface is an important part of 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

Page 4: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

Human Interface - Examples

Dr. Gheith Abandah 4

Page 5: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

Human Interface - Examples

Dr. Gheith Abandah 5

Page 6: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

Human interface types

• Input:– Switch– Push button– Keypad

• Output:– light-emitting diode

(LED)– Seven-segment LED– Liquid crystal display

(LCD)

Dr. Gheith Abandah 6

Page 7: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

The LED version of the Derbot AGV

Dr. Gheith Abandah 7

Page 8: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

The LCD version of the Derbot AGV

Dr. Gheith Abandah 8

Page 9: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

The Keypad

Dr. Gheith Abandah 9

Page 10: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

Flow diagramReading a keypad with a microcontroller port

Dr. Gheith Abandah 10

Page 11: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

Outputs for the keypad

Port Bit Function7 Row 16 Row 25 Row 34 Row 43 Column 12 Column 21 Column 30 Unused

Dr. Gheith Abandah 11

Page 12: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

Flow diagram of program example

Dr. Gheith Abandah 12

Page 13: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

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

Page 14: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

Keypad Example – ISRkpad_to_lcd

call kpad_rd

call kp_code_conv

bsf portc,lcd_RS ;set for character op

movwf lcd_op

call lcd_write

rel_test ;test now for keypad release

call kpad_rd

movf kpad_pat,0

andlw 0fe ;suppress lsb, not used

sublw 0fe ;test if inactive

btfss status,z

goto rel_test

bcf intcon,rbif ;clear interrupt flag

retfieDr. Gheith Abandah 14

Page 15: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

Keypad Example – Read keypadkpad_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 pattern

Dr. Gheith Abandah 15

Page 16: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

Keypad Example – Read keypad 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

Page 17: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

Seven-segment displays

Dr. Gheith Abandah 17

Common Anode

Common Cathode

Page 18: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

Connecting multiple digits

Dr. Gheith Abandah 18

Need 1.2 kΩ line resistors

Page 19: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

Timing diagram

Dr. Gheith Abandah 19

Page 20: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

7-seg. display example – page 1

Dr. Gheith Abandah 20

Page 21: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

7-seg. display example – page 2;Initialise

bcf status,rp1

bsf status,rp0;bank 1

movlw B’00000000’ ;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

Page 22: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

Liquid crystal displays (LCDs)

• Liquid crystal responds to an applied electric field by changing the alignment of its molecules, and in so doing changing the direction of the light polarization that it introduces.

• Liquid crystal can be trapped between two parallel sheets of glass, with a matching pattern of transparent electrode on each sheet.

• When a voltage is applied to the electrodes, the optical character of the crystal changes and the electrode pattern appears in the crystal.

Dr. Gheith Abandah 22

Page 23: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

Interfacing with LCDs

• Hitachi developed a special microcontroller (HD44780) for interfacing LCDs.

• This microcontroller is usually integrated with LCDs.

• Features:– 8- or 4-bit data transfer– Simple instruction set to initialize, clear, display,

and position cursor– Has instruction register and data register

Dr. Gheith Abandah 23

Page 24: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

HD44780 timing diagram

Dr. Gheith Abandah 24

Page 25: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

Derbot’s LCD

Dr. Gheith Abandah 25

Each digit is a liquid crystal dot matrix

Page 26: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

LCD Drive Example – Page 1

lcd_write

call busy_check

bcf portc,lcd_rw

bcf status,c

rrf 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

Page 27: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

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

Page 28: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

LCD Drive Example – Page 3busy_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

Page 29: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

Sensors

• Convert physical variables to electrical.• Examples:

– The microswitch– Light-dependent resistor– Ultrasonic object sensor

Dr. Gheith Abandah 29

Page 30: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

The Microswitch

Dr. Gheith Abandah 30

Page 31: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

Light-dependent resistors

• A light-dependent resistor (LDR) is made from a piece of exposed semiconductor material. When light falls on it, it creates hole–electron pairs in the material, which improve the conductivity.

• 20M Ω to a few hundred ohms

Dr. Gheith Abandah 31

Page 32: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

Optical object sensingInfrared LED and phototransistor

Dr. Gheith Abandah 32

Page 33: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

The opto-sensor applied as a shaft encoder

Dr. Gheith Abandah 33

Page 34: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

Ultrasonic object sensor

Dr. Gheith Abandah 34

Page 35: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

Digital inputIf a microcontroller is to receive logic signals, then it is essential that those signals are at voltage levels which are recognized by it as being either Logic 0 or Logic 1.

Dr. Gheith Abandah 35

Page 36: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

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.

Page 37: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

Input protection

• For Rprot = 1KΩ and max. diode current =20 mA

• What is the maximum voltage spike?

Vmax =

[(20mA × 1 k Ω) + 5.3]= 25V

Dr. Gheith Abandah 37

Page 38: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

Ensuring legal logic levels

• Can use Schmitt trigger for speeding up slow logic edges.

• Schmitt trigger with RC filter can be used to filter voltage spikes.

• Digital filtering: sample the input three times and use a majority vote.

Dr. Gheith Abandah 38

Page 39: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

Isolation or level shifting with the opto-isolator

Dr. Gheith Abandah 39

Page 40: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

Switch bouncing

Dr. Gheith Abandah 40

Page 41: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

Hardware switch debouncing

Dr. Gheith Abandah 41

Page 42: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

Software switch debouncing

Dr. Gheith Abandah 42

Typically 10 ms

Page 43: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

Actuators: motors and servos

• Often need to cause physical movement

• For linear movement use solenoids

• For angular movement, use ‘servos’

• For angular or rotary, use DC or stepper motors

Dr. Gheith Abandah 43

Page 44: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

Comparison

DC Motors• Range from the extremely

powerful to the very small• Wide speed range• Controllable speed• Good efficiency• Can provide accurate

angular positioning with angular shafts

• Only the armature winding needs to be driven

Stepper Motors• Simple interface with digital

systems• Can control speed and

position• Awkward start-up

characteristics• Lose torque at high speed• Limited top speed• Less efficient• More complex to drive

Dr. Gheith Abandah 44

Page 45: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

Derbot DC Motor

Dr. Gheith Abandah 45

Page 46: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

Servo input and output characteristics

Dr. Gheith Abandah 46

Page 47: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

Interfacing to actuators

• Simple DC switching– Bipolar transistors– MOSFET transistors

• Reversible switching– The H-bridge

Dr. Gheith Abandah 47

Page 48: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

Bipolar transistor switching of DC resistive loads

Dr. Gheith Abandah 48

Page 49: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

MOSFET transistor switching of DC resistive loads

Dr. Gheith Abandah 49

Page 50: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

MOSFET transistor switching of DC inductive loads

Dr. Gheith Abandah 50

Page 51: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

Characteristics of two popular logic-compatible MOSFETs

Dr. Gheith Abandah 51

Page 52: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

Driving piezo sounder and opto-sensors

Dr. Gheith Abandah 52

I = (5 − 3.4)/91I = 17.6 mA

Page 53: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

Reversible switching: the H-bridge

Dr. Gheith Abandah 53

Page 54: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

The L293D dual H-bridge

Dr. Gheith Abandah 54

Page 55: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

The L293D applied in the Derbot motor drive circuit

Dr. Gheith Abandah 55

Page 56: The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.

Summary• An embedded microcontroller must be able to interface with

the physical world and possibly the human world as well.• Much human interfacing can be done with switches, keypads

and displays.• To interface with the physical world, the microcontroller

must be able to interface with a range of transducers. The designer needs an understanding of the main sensors and actuators available.

• Interfacing with sensors requires a reasonable knowledge of signal conditioning techniques.

• Interfacing with actuators requires a reasonable knowledge of power switching techniques.

Dr. Gheith Abandah 56