Matrix Keyboard Interface

  • Uploaded by: jinto0007
  • Size: 6.1 MB
  • Type: PDF
  • Words: 1,968
  • Pages: 90
Report this file Bookmark

* The preview only shows a few pages of manuals at random. You can get the complete content by filling out the form below.

The preview is currently being created... Please pause for a moment!

Description

Keyboard Interface

Matrix Keyboard

Scanning and Identifying Key • The rows are connected to an output port and the columns are connected to an input port. • If no key has been pressed, reading the input port will yield 1 s for all columns since they are all connected to high (V cc). • If all the rows are grounded and a key is pressed, one of the columns will have 0 since the key pressed provides the path to ground. • It is the function of the microcontroller to scan the keyboard continuously to detect and identify the key pressed. • To detect a pressed key, the microcontroller grounds all rows by providing 0 to the output latch, then it reads the columns.

Contd…. • If the data read from the columns is D3 – DO = 1111, no key has been pressed and the process continues until a key press is detected. • For example, if D3 – DO = 1101, this means that a key in the D1 column has been pressed. • Identifying the key: Starting with the top row, the microcontroller grounds it by providing a low to row DO only; then it reads the columns. • If the data read is all Is, no key in that row is activated and the process is moved to the next row. • This process continues until the row is identified.

 Four Major Stages: 1. Make sure that the preceding key has been released 2. To see if any key is pressed 3. To detect which row key press(Identify row) 4. To identify key press

Matrix Keyboard

Keyboard Interfacing

AT Keyboard • US standard keyboard introduced in 1986 by IBM . • The original version had 84-keys but was then replaced by the 101-key enhanced keyboard. • An AT keyboard may also be used to describe a keyboard that uses the AT (Din5) port as shown in the above illustration. • Today since most computers use either PS/2 or USB keyboards.

General description • Monitored by onboard processor • Monitors which key are pressed / released and send appropriate data to host

Scan Code • Make code • Break code ************** Scan Code Set: Set1….Set2…..Set3

set 1 (IBM PC XT)

set 2 (IBM PC AT)

set 3 (IBM 3270 PC)

key

A (normal letter)

PRESS

RELEASE

PRESS

RELEASE

PRESS

RELEASE

1E

9E

1C

F0 1C

1C

F01C

1C

9C

5A

F0 5A

5A

F0 5A

E0 1C

E0 9C

E0 5A

E0 F0 5A

79

F0 79

E0 5B

E0 DB

E0 1F

E0 F0 1F

8B

F08B

E0 5C

E0 DC

E0 27

E0 F0 27

8C

F08C

Return / Enter (main keyboard)

Enter (numeric keypad)

Left Windows key Right Windows key

KEYBOARD COMMANDS & RESPONSES Commands System Issues to Keyboard

• ED: Set/Reset Mode Indicators |7-3|2|1|0| Keyboard Status Indicator Option Byte Scroll-Lock indicator (0=off, 1=on) Num-Lock indicator (0=off, 1=on) Caps-Lock indicator (0=off, 1=on) reserved (must be zero)

• EE: Diagnostic Echo • F0 : Select/Read Alternate Scan Code Sets 00: return byte indicating scan code set in use 01:select scan code set 1 02:select scan code set 2 03:select scan code set 3

Contd… • • • • • •

F2: Read Keyboard ID F3: Set Typematic Rate/Delay F4 : Enable Keyboard F5: Disable Keyboard, disable scanning. FE: Resend FF: Reset

KEYBOARD COMMANDS & RESPONSES Keyboard Responses to System • 00: Key Detection Error or buffer over flow, Error for Scan Code Set 1. • FF: Key Detection Error or Overrun, Error for Scan Code Set 2 or 3. • FA: Keyboard sends this whenever a valid command or data byte is received (except on Echo and Resend commands). • EE: Echo Response, response to the Echo command. • AA: Keyboard sends this to indicate the keyboard test was successful. • FC: Keyboard sends this to indicate the keyboard test failed and stops scanning until a response or reset is sent. • FE: Resend, keyboard request resend of data when data sent to it is invalid or arrives with invalid parity. • Id: Keyboard ID Response, keyboard sends a two byte ID after ACK'ing the Read ID command(F2). The keyboard then resumes scanning.

Watchdog Timer • An electronic timer that is used to detect and recover from computer malfunctions • During normal operation, the computer regularly resets the watchdog timer to prevent it from elapsing, or "timing out“ • The timeout signal is used to initiate corrective action or actions. 

Contd…. • The watchdog and CPU may share a common clock signal, as shown in the block diagram below, or they may have independent clock signals.

• Eg: Mobile Diaplay

DS1232 Watchdog Timer

Functionality • Chip monitors three vital conditions for a microprocessor: -Power Monitor -Pushbutton reset control -Watchdog timer

Power Monitor • When TOL is connected to ground, the RST and RST’ signals become active as VCC falls below 4.75 volts. • When TOL is connected to VCC, the RST and RST’ signals become active as VCC falls below 4.5 volts. • On power-up, RST and RST’ are kept active for a minimum of 250 ms to allow the power supply and processor to stabilize.

Pushbutton Reset control

Watchdog timer

Real Time Clock • Keeps track of current time Requirements: Power Source Timing: Typically use 32.768KHz Eg: DS1302 RTC

DS1302 RTC • Real-Time Clock Counts Seconds, Minutes, Hours, Date of the Month, Month, Day of the Week, and Year with Leap-Year Compensation Valid Up to 2100 • The end of the month date is automatically adjusted for months with fewer than 31 days, including corrections for leap year. • The clock operates in either the 24-hour or 12hour format with an AM/PM indicator.

Synchronous Serial Communication

Signal Description • Vcc2: Primary Power-Supply Pin in Dual Supply Configuration • Vcc1: Low-Power Battery Backup • X1,X2: Connections for Standard 32.768kHz Quartz Crystal • GND • CE: CE signal must be asserted high during a read or a write • I/O : The I/O pin is the bidirectional data pin • SCLK : SCLK is used to synchronize data movement on the serial interface

Block Diagram

Parameters • CLOCK ACCURACY The accuracy of the clock is dependent upon the accuracy of the crystal and the accuracy of the match between the capacitive load of the oscillator circuit and the capacitive load for which the crystal was trimmed • Command Byte

Contd… • CE AND CLOCK CONTROL CE input high initiates all data transfers. The CE input serves two functions. Driving the - First, CE turns on the control logic that allows access to the shift register for the address/command sequence. -Second, the CE signal provides a method of terminating either single-byte or multiple-byte CE data transfer. • DATA INPUT (Write Operation)

Following the eight SCLK cycles that input a write command byte, a data byte is input on the rising edge of the next eight SCLK cycles • DATA OUTPUT (Read Operation)

Following the eight SCLK cycles that input a read command byte, a data byte is output on the falling edge of the next eight SCLK cycles

Contd….

• BURST MODE: Multiple values are written to or read from the DS1302 in a single data exchange. • CLOCK/CALENDAR Register: Contained in 7 Read/ Write Register • CLOCK HALT FLAG: Bit 7 of the seconds register • AM-PM/12-24 Mode: Bit 7 of hour register is used • WRITE-PROTECT BIT: Bit 7 of the control register is the write-protect bit.

Modes of Operation

Contd…

Contd…

ADC Interfacing • • • •

Data Acquisition device Transducer output: Analog Microcontroller read: Digital Transducer output ADC

Microcontroller

ADC0804 Chip

Pin Description • CLK IN & CLK R • Vref/2…..Not connnected (input: 0-5v) 2v Given (input: 0-4v) • D0-D7 (While CS=0 and RD forced to low)

• AGnd & DGnd: Analog Ground and Digital Ground 

Contd…. • • • •

Vin (+) and Vin (-)  RD (data enable)  INTR (end of conversion)  WR (start conversion):  If CS = 0 and WR makes a low-to-high transition, the ADC0804 starts converting • CS: Active low input used to activate the ADC0804 chip.

ADC Operation

ADC0804 Interfacing

DAC Interfacing • A system that converts a digital signal into an analog signal • Types 1. Binary Weighted

2. R/2R Ladder

Contd… • Resolution • No of analog levels= 2*n n- no of inputs Eg: DAC0808

DAC 0808

DAC interfacing

LCD Interfacing • Ability to display numbers, characters and graphics

Timing Diagram: Read

Program to send Letters ‘P’, ‘I’ and ‘C’

Stepper Motor Interfacing • A stepper motor is an electromechanical device which converts electrical pulses into discrete mechanical movements or steps. • This motor divides a full rotation of 360 degrees into a number of equal steps. 

Contd… • Motor Moves Each Time a Pulse is Received • Can Control Movement (Direction and Amount) Easily. • Permanent Magnet Rotor – Also Called the Shaft

• Stator – Surrounds the Shaft – Usually Four Stator Windings Paired with Center-Tapped Common • Known as Four-Phase or Unipolar Stepper Motor

Construction • Center Tapped Common

Different Step Operation

Two-Coil Excitation - Each successive pair of adjacent coils is energised in turn.

Half Step Working

Step Angle • Minimum degree rotation/ step • No. of steps= 360/ step angle • Steps/ second= (rpm* steps per revolution)/60

Program • A switch is connected to P2.7. write a program to monitor the status of the Switch. If Switch=0, motor moves clockwise and if Switch=1, motor moves anticlockwise.

DC Motor Interfacing • A DC motor is any of a class of rotary electrical machines that converts direct current electrical energy into mechanical energy. • Two leads…..+ve and –ve • Vcc to +ve and –ve Gnd…..Clockwise • Polarity change……Anticlockwise • DC Motor: Continuous rotation • Nominal Voltage(1v to 150v) • Current rating(25 mA to few Ampere)

Working

Unidirectional Control

Bidirectional Control

Program • A switch is connected to P2.7. Write a program to monitor the status of the SW. SW=1, DC Motor moves clockwise and SW=0, DC motor moves Anticlockwise once is enabled by P1.0

C If if it

L293 Motor Driver • Why?.............Current Amplifier • Dual H-Bridge Motor driver IC • L293D contains…..Two H-Bridge driver ckt (Can drive two Dc Motors)

Pin Diagram

MOTOR 1

INPUT 1

0 0 1

1

MOTOR 2

INPUT 2

0 1 0

1

INPUT 3

0

0 1

1

ENABLE PIN HIGH FOR WORKING INPUT 4

0

OPERATION

MOTOR 1 & 2 STOPs

1

MOTOR 1 & 2 ROTATE CLOCKWISE

0

MOTOR 1 & 2 ROTATE ANTICLOCKWISE

1

MOTOR 1 & 2 STOPs

Measurement Of Frequency • Frequency= no. of pulses/ time • T0 & T1 of 8051 is used • T0 for counting & T1 for Timing

Procedure • In the procedure Timer0 is configured as a counter • The Timer1 is configured as a 16 bit timer. Timer 1 is pre-loaded with a suitable value so that it will run for time which generates a time lapse of 100 microseconds. • During this time the Timer0 will count the number of pulses. • The count value is divided by the time. • Frequency of the pulse train applied externally at the pin P3.3

Measurement Of Phase Angle • In this mode, INT0 and INT1 are normally high and if the low level signal is applied  to them,It triggers the Interrupt. Then the microcontroller stops and jumps to the interrupt vector table to service that interrupt .

Pin Configuration

Measurement Of Pahse Angle

Cosine of angle between voltage and current.

Steps 1.Microcontroller starts on interrupt mode 2.INT0 & INt1 are enabled 3.Voltage given to INT0 & Current Given to INT1 4. Timer measures time interval between two interrupts 5.0-5ms=0-90degree 6.Calibrated data is converted from Hex to BCD and then to ASCII for display

Measurement Of Power Factor

Cosine of angle between voltage and current.

Similar documents

Matrix Keyboard Interface

jinto0007 - 6.1 MB

Human Interface Device

Benyamin Hedy Bruaris - 1.2 MB

© 2024 VDOCS.RO. Our members: VDOCS.TIPS [GLOBAL] | VDOCS.CZ [CZ] | VDOCS.MX [ES] | VDOCS.PL [PL] | VDOCS.RO [RO]