+ All Categories
Home > Documents > Lecture – 7 Basic input and output 1. Outline Switch-based inputs Keypads LEDs 7-segment LED...

Lecture – 7 Basic input and output 1. Outline Switch-based inputs Keypads LEDs 7-segment LED...

Date post: 22-Dec-2015
Category:
Upload: dwain-wheeler
View: 219 times
Download: 0 times
Share this document with a friend
25
Lecture – 7 Basic input and output 1
Transcript
Page 1: Lecture – 7 Basic input and output 1. Outline Switch-based inputs Keypads LEDs 7-segment LED Displays LCD Displays Temperature sensor Flow sensor Infrared.

1

Lecture – 7

Basic input and output

Page 2: Lecture – 7 Basic input and output 1. Outline Switch-based inputs Keypads LEDs 7-segment LED Displays LCD Displays Temperature sensor Flow sensor Infrared.

2

Outline

• Switch-based inputs• Keypads• LEDs• 7-segment LED Displays• LCD Displays• Temperature sensor• Flow sensor• Infrared repeater

Page 3: Lecture – 7 Basic input and output 1. Outline Switch-based inputs Keypads LEDs 7-segment LED Displays LCD Displays Temperature sensor Flow sensor Infrared.

Switch-based inputs

• Most inputs to a PIC are switch based.

• The figure illustrates a few variations of mechanical switches often used with microcontrollers which include are SPST, SPDT (single-pole, double-throw), and DPDT (double-pole, double-throw) switches and pushbuttons.

• Each switch or pushbutton is connected so that either a logic zero or logic one is present at the output connection or connections.

• In all cases, a 10K resister is used to pull up the switch output to a logic one when the switch contacts are open.

• The value of the resister can range from a low of about 1K (lower values will cause excessive current flows) and a maximum of 47K (larger values will cause a problem with noise). 3

Page 4: Lecture – 7 Basic input and output 1. Outline Switch-based inputs Keypads LEDs 7-segment LED Displays LCD Displays Temperature sensor Flow sensor Infrared.

4

Various switches

Page 5: Lecture – 7 Basic input and output 1. Outline Switch-based inputs Keypads LEDs 7-segment LED Displays LCD Displays Temperature sensor Flow sensor Infrared.

5

Switch De-bouncing

• Switches present problems when being used to enter certain types of data because they mechanically bounce.

• A switch internally contains metal pole pieces that, when connected, physically bounce apart a few times.

• The figure shows what a bounce appears as electrically on a switch, and it also shows noise.

• Noise occurs on switch signal lines because it is usually impossible to shield a switch and its connections to a system from environmental noise.

• In most cases noise, as well as bounces, must be removed from a switch connection for reliable system operation.

Page 6: Lecture – 7 Basic input and output 1. Outline Switch-based inputs Keypads LEDs 7-segment LED Displays LCD Displays Temperature sensor Flow sensor Infrared.

6

Switch bouncing and noise

• Actual switch signal

• De-bounced switch signal

Page 7: Lecture – 7 Basic input and output 1. Outline Switch-based inputs Keypads LEDs 7-segment LED Displays LCD Displays Temperature sensor Flow sensor Infrared.

Keypads• Keypads are often used in applications and are usually in the form of a

key matrix.

• As with single switches keypads must be de-bounced.

• The figure illustrates telephone-style numeric keypad interfaced to

Ports A and B.

• This is a 4 x 3 key matrix. Keypads are available in a variety of styles

and sizes from 2 x 2 to almost any size.

• A keypad matrix is constructed with SPST pushbutton switches that

connect a vertical column with a horizontal row.7

Page 8: Lecture – 7 Basic input and output 1. Outline Switch-based inputs Keypads LEDs 7-segment LED Displays LCD Displays Temperature sensor Flow sensor Infrared.

8

Telephone-style 4 × 3 keypad matrix

Page 9: Lecture – 7 Basic input and output 1. Outline Switch-based inputs Keypads LEDs 7-segment LED Displays LCD Displays Temperature sensor Flow sensor Infrared.

9

LEDs

• The LED is often interfaced to an embedded system such as an indicator or segmented numeric display.

• The main advantage is high visibility and longevity. The LED normally functions for about 20 years.

• Other advantages are relatively low power requirements and the low level of heat generated compared to an incandescent lamp.

• Light emitting diodes are used in many applications, but they must be biased properly to be used.

• A current limiting resistor is used in series with an LED to select the correct current for the device.

Page 10: Lecture – 7 Basic input and output 1. Outline Switch-based inputs Keypads LEDs 7-segment LED Displays LCD Displays Temperature sensor Flow sensor Infrared.

10

LEDs

• The figure illustrates a single LED diode interfaced to a PIC18 port pin.

• One interface uses 10 mA of current and an inverter that provides enough current, which is slightly more than allowed by a port pin. The other uses 8.5 mA, which is allowed at a port pin.

• The series current limiting resistor is chosen using Ohm's law ( R =V/I ).

• Because the LED drops 1.65 V, the voltage across the resister is 3.35 V so the current of 10 mA determines that the resister size is 335 Ω (3.35 V/10mA).

• A 335 Ω resister is not available, so a 330 a standard value resister is chosen.

Page 11: Lecture – 7 Basic input and output 1. Outline Switch-based inputs Keypads LEDs 7-segment LED Displays LCD Displays Temperature sensor Flow sensor Infrared.

11

Driving a single LED using a +5.0 V power supply

Page 12: Lecture – 7 Basic input and output 1. Outline Switch-based inputs Keypads LEDs 7-segment LED Displays LCD Displays Temperature sensor Flow sensor Infrared.

7-segment LED Displays

• These devices are used when the display must be fairly large and have good

visibility.

• Two types of 7-segment displays:

– common Cathode.

– common Anode.

• The common anode version has all its anodes of the LEDs connected to 5.0 V with

a logic zero lighting a segment.

• The common cathode version connects all its cathodes to ground and a logic one is

applied to the segments to light them.

• The LED display contains seven segments lettered from a to g. Some displays also

contain a decimal point labelled dp.

12

Page 13: Lecture – 7 Basic input and output 1. Outline Switch-based inputs Keypads LEDs 7-segment LED Displays LCD Displays Temperature sensor Flow sensor Infrared.

13

7-segment displays types

Page 14: Lecture – 7 Basic input and output 1. Outline Switch-based inputs Keypads LEDs 7-segment LED Displays LCD Displays Temperature sensor Flow sensor Infrared.

14

Simple single 7-segment LED system

• The figure illustrates a single 7-segment display connected to a

PIC18F1220.

• Also connected to the microcontroller is a single push button switch.

• The switch is connected to RA0 and the 7-segment display is connected to

Port B.

• This display is driven with a 74LS244 buffer to provide the 10 mA per

segment required by the display.

• Every time the button switch is pressed, the number on the 7-segment

display increments one time.

Page 15: Lecture – 7 Basic input and output 1. Outline Switch-based inputs Keypads LEDs 7-segment LED Displays LCD Displays Temperature sensor Flow sensor Infrared.

15

Simple single 7-segment LED system

Page 16: Lecture – 7 Basic input and output 1. Outline Switch-based inputs Keypads LEDs 7-segment LED Displays LCD Displays Temperature sensor Flow sensor Infrared.

LCD Displays• LCD displays are very common because they are low cost devices.

• The figure illustrates the connection of the Optrex DMC-20481, LCD display

interfaced to a PIC18F1220.

• The DMC-20481 is a 4-line by 20-characters-per-line display that accepts ASCII

code as input data and it also accepts commands that initialize it and control its

operation.

• The data and control connections, attached to Port B, are used to input display data

and read information from the display.

• The LCD operates with either an 8-bit or 4-bit data connection. When using a 4-bit

data connection, data bits D4 through D7 on the LCD are used for data and

connection; data bits D0 through D3 have no function and are not connected. 16

Page 17: Lecture – 7 Basic input and output 1. Outline Switch-based inputs Keypads LEDs 7-segment LED Displays LCD Displays Temperature sensor Flow sensor Infrared.

17

LCD interfaced to the microcontroller

Page 18: Lecture – 7 Basic input and output 1. Outline Switch-based inputs Keypads LEDs 7-segment LED Displays LCD Displays Temperature sensor Flow sensor Infrared.

18

Temperature sensor

• The figure illustrates the LM70 from National Semiconductor interfaced to the microcontroller.

• The device itself is the temperature sensor and is small enough to mount just about anywhere.

• The LM70 has a chip select input to enable it for a read or a write, a SI/O pin for serial data, and a SC input that functions as a serial clock signal.

• To read the temperature, place a logic zero on the chip select input and then pulse the SC input.

• After pulsing the SC input, read a bit of the temperature from the SI/O pin.

Page 19: Lecture – 7 Basic input and output 1. Outline Switch-based inputs Keypads LEDs 7-segment LED Displays LCD Displays Temperature sensor Flow sensor Infrared.

19

Temperature sensor

Page 20: Lecture – 7 Basic input and output 1. Outline Switch-based inputs Keypads LEDs 7-segment LED Displays LCD Displays Temperature sensor Flow sensor Infrared.

20

Flow sensor

• Flow sensors produce pulses as liquids flow through them.

• Suppose that fuel flow and consumption need to be measured in a system.

• This is accomplished by using a flow sensor such as the Gems FT-I 10 flow sensor.

• This device (model 173934) produces 8300 pulses per gallon of flow.

• The measurable flow rate is from 0.07 to 5.3 gallon per minute.

• This is a simple device to interface and requires only a single pull-up resistor and three wires.

Page 21: Lecture – 7 Basic input and output 1. Outline Switch-based inputs Keypads LEDs 7-segment LED Displays LCD Displays Temperature sensor Flow sensor Infrared.

21

Flow sensor

Page 22: Lecture – 7 Basic input and output 1. Outline Switch-based inputs Keypads LEDs 7-segment LED Displays LCD Displays Temperature sensor Flow sensor Infrared.

22

Infrared Remote Control Devices

• Infrared remote controls are extremely common and have many uses with embedded applications.

• The sensor and emitter are usually a simple infrared LED, or multiple LEDs for distances greater than a few meters.

• The signal is often transmitted at the relatively low rate of 36 KHz for many remote control devices, which makes the interface especially suited to a microcontroller.

• A useful device that illustrates the principle of infrared sensors is a remote control range extender circuit constructed with the microcontroller.

Page 23: Lecture – 7 Basic input and output 1. Outline Switch-based inputs Keypads LEDs 7-segment LED Displays LCD Displays Temperature sensor Flow sensor Infrared.

23

Infrared repeater

• This device requires both the infrared emitter and sensor, and illustrates some basic serial programming.

• The circuit uses the inexpensive PIC18F1220 and a few components.

• The power supply here is battery operated using four AA batteries (1.5V) and a MAX603 regulator to provide a steady 5 V to the circuit.

• This MAX603 integrated circuit uses an internal change pump and MOSFET to generate the 5 V output voltage from any input voltage between 2.7 V and 11.5 V.

Page 24: Lecture – 7 Basic input and output 1. Outline Switch-based inputs Keypads LEDs 7-segment LED Displays LCD Displays Temperature sensor Flow sensor Infrared.

24

Infrared repeater

Page 25: Lecture – 7 Basic input and output 1. Outline Switch-based inputs Keypads LEDs 7-segment LED Displays LCD Displays Temperature sensor Flow sensor Infrared.

25

Summary• Switches bounce for approximately 10 ms and must be de-bounced for proper

operation in many applications. De-bouncing is best handled with software.

• Keypads are often connected to a microcontroller for inputting various types of information. Keypads are most often constructed in the form of a matrix where pressing a key connects a row to a column.

• Light-emitting diodes that are interfaced to a microcontroller often require a driver circuit to produce enough current to light the LED. Numeric displays use LEDs in a 7-segment configuration that uses 7-segment code.

• Liquid crystal displays (LCD) are often connected to a microcontroller to display both numeric and alphabetic data. Various sizes of LCD display panels are available from I-line to line displays that have from 16 to 40 characters on a display line.

• Sensors are devices that convert motion or some other physical event into an electric signal that is processed by the microcontroller. These include rotational motion, pressure, temperature, liquid flow, and so forth.


Recommended