Jordan University of Science and Technology Electrical Engineering Department Microcontrollers and Embedded Systems Spring 2011

Similar documents
Embedded Systems. PIC16F84A Sample Programs. Eng. Anis Nazer First Semester

PIC PROGRAMMING START. The next stage is always the setting up of the PORTS, the symbol used to indicate this and all Processes is a Rectangle.

Binary Outputs and Timing

Flow Charts and Assembler Programs

Input/Output Ports and Interfacing

Chapter 11: Interrupt On Change

Dept. of Computer Engineering Final Exam, First Semester: 2016/2017

The University of Texas at Arlington Lecture 5

PIC Discussion. By Eng. Tamar Jomaa

PIC 16F84A programming (II)

Figure 1: Pushbutton without Pull-up.

Chapter 4 Sections 1 4, 10 Dr. Iyad Jafar

Lesson 14. Title of the Experiment: Introduction to Microcontroller (Activity number of the GCE Advanced Level practical Guide 27)

When JP1 is cut, baud rate is Otherwise, baud rate is Factory default is that JP1 is shorted. (JP1 is jumper type in some model)

Mechatronics and Measurement. Lecturer:Dung-An Wang Lecture 6

ECE Homework #3

TOPIC 3 INTRODUCTION TO PIC ASSEMBLY LANGUAGE. E4160 Microprocessor & Microcontroller System. Prepared by : Puziah Yahaya JKE, POLISAS / DEC 2010

University of Jordan Faculty of Engineering and Technology Department of Computer Engineering Embedded Systems Laboratory

Lecture (04) PIC16F84A (3)

LAB WORK 2. 1) Debugger-Select Tool-MPLAB SIM View-Program Memory Trace the program by F7 button. Lab Work

Chapter 3: Further Microcontrollers

EXPERIMENT 4: Parallel Input/Output. Objectives Introduction to the Parallel Input/Output (I/O) Familiarization to Interfacing

CHAPTER 6 CONCLUSION AND SCOPE FOR FUTURE WORK

Laboratory Exercise 5 - Analog to Digital Conversion

CONNECT TO THE PIC. A Simple Development Board

Weekly Report: Interactive Wheel of Fortune Week 4 02/014/07-02/22/07 Written by: Yadverinder Singh

ME 515 Mechatronics. A microprocessor

/* PROGRAM FOR BLINKING LEDs CONEECTED TO PORT-D */

which means that writing to a port implies that the port pins are first read, then this value is modified and then written to the port data latch.

LPTCOM. Bruce Misner Lakehead University h d3 RD2 pin 21. RD3 pin h d4. RD4 pin 27 RD5 pin h d5. RD6 pin 29 RD7 pin H d6

Discrete Logic Replacement A Keypad Controller for Bi-directional Key Matrix

Embedded System Design

UNIVERSITY OF ULSTER UNIVERSITY EXAMINATIONS : 2001/2002. Semester 2. Year 2 MICROCONTROLLER SYSTEMS. Module Code: EEE305J2. Time allowed: 3 Hours

Introduction. Embedded system functionality aspects. Processing. Storage. Communication. Transformation of data Implemented using processors

Professor E. Ambikairajah UNSW Sydney

APPLICATION NOTE Wire Communication with a Microchip PICmicro Microcontroller

Assembly Language Instructions

UNIVERSITY OF ULSTER UNIVERSITY EXAMINATIONS : 2001/2002 RESIT. Year 2 MICROCONTROLLER SYSTEMS. Module Code: EEE305J1. Time allowed: 3 Hours

Interfacing PIC Microcontrollers. ADC8BIT2 Schematic. This application demonstrates analogue input sampling

Hi Hsiao-Lung Chan Dept Electrical Engineering Chang Gung University, Taiwan

AN587. Interfacing to an LCD Module. Interfacing to an LCD Module INTRODUCTION OPERATION CONTROL SIGNAL FUNCTIONS TABLE 2: CONDITIONAL ASSEMBLY FLAGS

Learning Objectives:

EE6008-Microcontroller Based System Design Department Of EEE/ DCE

Interrupts. ELEC 330 Digital Systems Engineering Dr. Ron Hayne. Images Courtesy of Ramesh Gaonkar and Delmar Learning

APPLICATION NOTE 2361 Interfacing an SPI-Interface RTC with a PIC Microcontroller

ME 6405 Introduction to Mechatronics

Application Note - PIC Source Code v1.1.doc

DESIGN AND FABRICATION OF FARE METER OF TAXICAB USING MICROCONTROLLER

ECE Test #1: Name

SOLAR TRACKING SYSTEM USING PIC16F84A STEPPER MOTOR AND 555TIMER

Arithmetic,logic Instruction and Programs

EEE111A/B Microprocessors

A Better Mouse Trap. Consumer Appliance, Widget, Gadget APPLICATION OPERATION: Ontario, Canada

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING. EE Microcontroller Based System Design

Outlines. PIC Programming in C and Assembly. Krerk Piromsopa, Ph.D. Department of Computer Engineering Chulalongkorn University

D:\PICstuff\PartCounter\PartCounter.asm

Hardware Interfacing. EE25M Introduction to microprocessors. Part V. 15 Interfacing methods. original author: Feisal Mohammed

Embedded Systems Programming and Architectures

Chapter 5 Sections 1 6 Dr. Iyad Jafar

CENG 336 INT. TO EMBEDDED SYSTEMS DEVELOPMENT. Spring 2006

CENG-336 Introduction to Embedded Systems Development. Timers

CHAPTER 4. PIC Microcontrollers. Assembly Language Programming. on-line FREE! Index Development systems Contact us

Timer2 Interrupts. NDSU Timer2 Interrupts September 20, Background:

ECE 354 Introduction to Lab 2. February 23 rd, 2003

Section 11. Timer0. Timer0 HIGHLIGHTS. This section of the manual contains the following major topics:

ECE 354 Computer Systems Lab II. Interrupts, Strings, and Busses

The University of Texas at Arlington Lecture 3

Wireless Model Rocket Igniter, William Grill, Riverhead Systems

NH-67, TRICHY MAIN ROAD, PULIYUR, C.F , KARUR DT. DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING COURSE MATERIAL

Lecture (04) PIC 16F84A programming I

Performance & Applications

16.317: Microprocessor Systems Design I Fall 2013 Exam 3 Solution

Done 1 NVB THF TLF T/R POL 1SHOT. Figure 1: Status register

1 Introduction to Computers and Computer Terminology Programs Memory Processor Data Sheet Example Application...

SOLUTIONS!! DO NOT DISTRIBUTE!!

Microchip 18F4550 Interface, Signal conditioning, USB, USB- RS-232, 16x2 LCD Interface

Model Answer Microcontrollers. MCQ Problems Total Q1 Q2

EE 367 Introduction to Microprocessors Homework 6

SOLUTIONS!! DO NOT DISTRIBUTE PRIOR TO EXAM!!

DERTS Design Requirements (1): Microcontroller Architecture & Programming

EECE.3170: Microprocessor Systems Design I Summer 2017 Homework 5 Solution

Chapter 5. Problems All programming problems should include design pseudo code either as a separate design document on embedded comments in the code.

C and Embedded Systems. So Why Learn Assembly Language? C Compilation. PICC Lite C Compiler. PICC Lite C Optimization Results (Lab #13)

Appendix D: Source Codes. PDF created with pdffactory Pro trial version

Chapter 9. Input/Output (I/O) Ports and Interfacing. Updated: 3/13/12

S w e d i s h c r. w e e b l y. c o m j a l i l a h m e l i v e. c o m Page 1

Week1. EEE305 Microcontroller Key Points

C:\IDE\Brooke-16F88-LED\Brooke-16F88_LED.asm

1 Introduction to Computers and Computer Terminology Programs Memory Processor Data Sheet... 4

Beacon Keyers Using PIC s. Dave Powis, DL/G4HUP

Lecture (03) PIC16F84 (2)

EECE.3170: Microprocessor Systems Design I Spring 2016

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING. EE6008 Microcontroller based system design

Laboratory 10. Programming a PIC Microcontroller - Part II

Build instructions. Name: James Kinney Project: Air-Suspension System School: Colorado State University Class: MECH307 Mechatronics

Controller Provides Display of Monitored Process Deviation

EECE.3170: Microprocessor Systems Design I Summer 2017

Physics 335 Intro to MicroControllers and the PIC Microcontroller

SEVEN SEGMENT DISPLAY LAB EXPERIMENT

Outline. Micriprocessor vs Microcontroller Introduction to PIC MCU PIC16F877 Hardware:

Transcription:

Jordan University of Science and Technology Electrical Engineering Department Microcontrollers and Embedded Systems Spring 2011 Microcontrollers andembedded Systems and and EE445 Embedded Embedded Microcontrollers EE445 - Systems Keypad-Interfacing: Compiled by Dr. Abdel-Rahman Jaradat - JUST JUST JUST Systems May 10, 2011 - EE445Microcontrollers Software Solution: Keypad scanning PIC in Practice, A Project-Based Approach, D. W. Smith, Newnes-Elsevier publisher, 2006. Keypads are an excellent way of entering data into the microcontroller. The keys are usually numbered but they could be labeled as function keys for example in a remote control handset in a TV to adjust the sound or color etc. As well as remote controls, keypads find applications in burglar alarms, door entry systems, calculators, microwave ovens etc. So there are no shortage of applications for this section. Keypads are usually arranged in a matrix format to reduce the number of I/O connections. A 12 key keypad is arranged in a 3 by 4 format requiring 7 connections. A 16 key keypad is arranged in a 4 by 4 format requiring 8 connections. Consider the 12 key keypad. This is arranged in 3 columns and 4 rows as shown in the Table below. There are 7 connections to the keypad C1, C2, C3, R1, R2, R3 and R4. From: PIC n Up The Pace, David Benson, Publisher: Squares 1 Electronics, 1999. 1

This connection to the micro is shown in the figure below. The keypad works in the following way: If for example key 6 is pressed then B2 will be joined to B4. For key 1 B0 would be joined to B3 etc. as shown in the figure below. The micro would set B0 low and scan B3, B4, B5 and B6 for a low to see if keys 1, 4, 7 or * had been pressed. The micro would then set B1 low and scan B3, B4, B5 and B6 for a low to see if keys 2, 5, 8 or 0 had been pressed. Finally B2 would be set low and B3, B4, B5 and B6 scanned for a low to see if keys 3, 6, 9 or # had been pressed.

. As a programming example when key 1 is pressed display a binary 1 on PORTA, when key 2 is pressed display a binary 2 on PORTA etc. Key 0 displays 10. Key * displays 11. Key # displays 12. This program could be used as a training aid for decimal to binary conversion. The flowchart is shown in Figure below. PORTA has been configured as an output port and PORTB has been configured with 3 outputs and 5 inputs. PORTB has internal pull up resistors so that the resistors connected to PORTB in the Figure are not required.

;KEYPAD.ASM ;EQUATES SECTION STATUS EQU 3 ;means STATUS is file 3. PORTA EQU 5 ;means PORTA is file 5. PORTB EQU 6 ;means PORTB is file 6. TRISA EQU 85H TRISB EQU 86H OPTION_R EQU 81H LIST P 16F84 ;we are using the 16F84. ORG 0 ;the start address in memory is 0 GOTO START ;goto start! ;CONFIGURATION BITS Config H3FF0 ;LP Osc, WDT off, ;Put on, ;code protection disabled. ;CONFIGURATION SECTION START BSF STATUS,5 ;Turns to Bank1. MOVLW B00000000 ;PORTA is OUTPUT MOVWF TRISA MOVLW B11111000 MOVWF TRISB ;PORTB is mixed I/O. BCF OPTION_R,7 ;Turn on pull ups. BCF STATUS,5 ;Return to Bank0. CLRF PORTA ;Clears PortA. CLRF PORTB ;Clears PortB. ;Program starts now. COLUMN1 BCF PORTB,0 ;Clear B0 BSF PORTB,1 ;Set B1 BSF PORTB,2 ;Set B2 CHECK1 BTFSC PORTB,3 ;Is B3 Clear? GOTO CHECK4 ;No MOVLW.1 ;Yes, output 1. CHECK4 BTFSC PORTB,4 ;Is B4 Clear? GOTO CHECK7 ;No MOVLW.4 ;Yes, output 4. CHECK7 BTFSC PORTB,5 ;Is B5 Clear? GOTO CHECK11 ;No MOVLW.7 ;Yes, output 7. CHECK11: BTFSC PORTB,6 ;Is B6 Clear? GOTO COLUMN2 ;No MOVLW.11 ;Yes, output 11. COLUMN2 BSF PORTB,0 ;Set B0 BCF PORTB,1 ;Clear B1 BSF PORTB,2 ;Set B2 CHECK2 BTFSC PORTB,3 ;Is B3 Clear? GOTO CHECK5 ;No MOVLW.2 ;Yes, output 2. CHECK5 BTFSC PORTB,4 ;Is B4 Clear? GOTO CHECK8 ;No MOVLW.5 ;Yes, output 5. CHECK8 BTFSC PORTB,5 ;Is B5 Clear? GOTO CHECK10 ;No MOVLW.8 ;Yes, output 8. CHECK10 BTFSC PORTB,6 ;Is B6 Clear? GOTO COLUMN3 ;No MOVLW.10 ;Yes, output 10. COLUMN3 BSF PORTB,0 ;Set B0 BSF PORTB,1 ;Set B1 BCF PORTB,2 ;Clear B2 CHECK3 BTFSC PORTB,3 ;Is B3 Clear? GOTO CHECK6 ;No MOVLW.3 ;Yes, output 3. CHECK6 BTFSC PORTB,4 ;Is B4 Clear? GOTO CHECK9 ;No MOVLW.6 ;Yes, output 6. CHECK9 BTFSC PORTB,5 ;Is B5 Clear? GOTO CHECK12 ;No MOVLW.9 ;Yes, output 9. CHECK12 BTFSC PORTB,6 ;Is B6 Clear? GOTO COLUMN1 ;No MOVLW.12 ;Yes, output 12. GOTO COLUMN1 ;Start scanning again. END

. On page 70-Programming 8-bit PIC Microcontrollers in C, M. Bates there is an example on building a calculator. The figure below shows the schematic diagram for the calculator. Calculator Schematic Hardware Solution: Keypad scanning

From PIC Microcontrollers, Martin Bates, Newnes, Elsevier Publisher, 2004. Column lines are connected up to pull-up resistors (10k each) and pulled high to +5V. If no key was pressed, then no column will have zero on it, and hence the encoder will not produce any output (see truth table for the encoder. We can add an output bit on the encoder output V to indicate a valid output). If a valid output appeared on the encoder, then the resulting output code from hex keypad will be: [R1 R0 C1 C0]