Effective Utilization of a Microcontroller Port for Optimisation of Hardware

Similar documents
Microcontroller & Interfacing

e-pg Pathshala Subject: Computer Science Paper: Embedded System Module: Interfacing External Devices using Embedded C Module No: CS/ES/22

GUJARAT TECHNOLOGICAL UNIVERSITY

SARDAR RAJA COLLEGES SARDAR RAJA COLLEGE OF ENGINEERING ALANGULAM

Mrs.T.Divya Barathi AP/ECE. Integrated Circuits Digital Logic Circuits Stack & Queue Concepts

Rewa Engineering College, Rewa. Rewa Department OF Electrical Engineering

Embedded Piano Interfaced with LCD

e-pg Pathshala Subject : Computer Science Paper: Embedded System Module: Interrupt Handling Module No: CS/ES/13 Quadrant 1 e-text

1. Pin diagram of 8051 and ports

SANKALCHAND PATEL COLLEGE OF ENGINEERING, VISNAGAR. ELECTRONICS & COMMUNICATION DEPARTMENT Question Bank- 1

RTC Interface 89C51 DS M. Krishna Kumar MAM/M7/LU17/V1/ Vcc VCC 5 SDA P1.0 6 SCL P KHz 3 BAT 3.

Keywords Digital IC tester, Microcontroller AT89S52

e-pg Pathshala Subject: Computer Science Paper: Embedded System Module: Interrupt Programming in Embedded C Module No: CS/ES/20 Quadrant 1 e-text

Environmental Data Acquisition Using (ENC28J60)

SRM UNIVERSITY FACULTY OF SCIENCE AND HUMANITIES DEPARTMENT OF PHYSICS AND NANOTECHNOLOGY COURSE PLAN FOR PHY0408

e-pg Pathshala Subject : Computer Science Paper: Embedded System Module: 8051 Architecture Module No: CS/ES/5 Quadrant 1 e-text

1. LCD (Liquid Crystal Display)interface


Pearson New International Edition. The 8051 Microcontroller and Embedded Systems Mazidi Mazidi McKinlay Second Edition

GUJARAT TECHNOLOGICAL UNIVERSITY

Academic Course Description

THE AVR MICROCONTROLLER AND EMBEDDED SYSTEMS. Using Assembly and С

Unit-I. 1. INTRODUCTION TO MICROCONTROLLERS. Micro controller, types, selection of a microcontroller and applications

BIRLA INSTITUTE OF TECHNOLOGY AND SCIENCE, Pilani Pilani Campus

Bachelor of Engineering in Computer and Electronic Engineering

e-pg Pathshala Subject : Computer Science Paper: Embedded System Module: Serial Port Communication Module No: CS/ES/11 Quadrant 1 e-text

Topics. Interfacing chips

CORRIGENDUM ISSUED FOR NATIONAL COMPETITIVE BIDDING UNDER TEQIP PHASE-II

Microcontrollers. Fig. 1 gives a comparison of a microprocessor system and a microcontroller system.

e-pg Pathshala Subject : Computer Science Paper: Embedded System Module: Introduction to Computing Module No: CS/ES/1 Quadrant 1 e-text

The IIC interface based on ATmega8 realizes the applications of PS/2 keyboard/mouse in the system

VALLIAMMAI ENGINEERING COLLEGE. SRM Nagar, Kattankulathur DEPARTMENT OF COMPUTER SCIENCE ENGINEERING

INTRODUCTION OF MICROPROCESSOR& INTERFACING DEVICES Introduction to Microprocessor Evolutions of Microprocessor

Department of Electronics and Communication Engineering Microprocessors and Microcontrollers Laboratory Description:

Trends in Prototyping Systems. ni logic Pvt. Ltd., Pune, India

GSM BASED SMART NOTICE BOARD

Class: S.E. (Electrical) Course: 2012 PAT. Semester: IV : FUNDAMENTALS OF MICROPROCESSOR AND MICROCONTROLLER Textbooks:

Syllabus for Bachelor of Technology. Computer Engineering. Subject Code: 01CE0501. Subject Name: Microprocessor Fundamentals & Programming

EMBEDDED DATA ACQUISITION SYSTEM USING M2M COMMUNICATION

Design of An Embedded System For Monitoring and Controlling Temperature and Light

EC 6504 MICROPROCESSOR AND MICROCONTROLLER

3. The MC6802 MICROPROCESSOR

FPGA Interfacing of HD44780 Based LCD Using Delayed Finite State Machine (FSM)

Ali Karimpour Associate Professor Ferdowsi University of Mashhad

Ali Karimpour Associate Professor Ferdowsi University of Mashhad

Embedded Systems. Software Development & Education Center. (Design & Development with Various µc)

UNIT V MICRO CONTROLLER PROGRAMMING & APPLICATIONS TWO MARKS. 3.Give any two differences between microprocessor and micro controller.

MECE336 Microprocessors I

The industrial technology is rapidly moving towards ARM based solutions. Keeping this in mind, we are providing a Embedded ARM Training Suite.

LABORATORY MANUAL Interfacing LCD 16x2, Keypad 4x4 and 7Segment Display to PIC18F4580

8051/8052/8031 Microcontroller

POWER THEFT DETECTION USING WIRELESS SYSTEM: A DISTRIBUTED APPROACH FOR POWER THEFT PREVENTION

The Design of Embedded MCU Network Measure and Control System

GSM Based Electronics Notice Board

CPEG300 Embedded System Design. Lecture Interface with Peripheral Devices

ITT Technical Institute. ET2640 Microprocessors and Microcontrollers Onsite and Online Course SYLLABUS

9. PERIPHERAL CHIPS 9a

Microcontroller-Based Solar Data Logger System using Proteus Virtual System Modeller

WIZTECH AUTOMATION SOLUTIONS (P) LTD., An ISO 9001:2000 and IAO certified company

DGBV-EP DIGITAL GENERATOR AND GENERATOR-TRANSFORMER UNIT PROTECTION. Field of application

Department of Electronics and Instrumentation Engineering Question Bank

Sensors State Monitoring based on LabVIEW and Wireless Nodes

Programming 8-bit PIC Microcontrollers in С

CoiNel Technology Solutions LLP. LPC2148 ARTIST Instruction Manual LPC2148 ARTIST. Instruction manual. Revision 1

Electrical Engineering

Microcontroller basics

BLACK BOX FOR CAR ACCIDENT

MLR INSTITUTE OF TECHNOLOGY DUNDIGAL , HYDERABAD QUESTION BANK

Controlling and Monitoring Of Industrial Parameters by Using GSM

ARM7 TDMI Microcontroller

17. I 2 C communication channel

Displaying of Digital Clock through digital circuits and through Assembly Language Programs of 8051 microcontroller

The Design of the Embedded WEB Server Based on ENC28J60

Microcontroller and Embedded Systems:

Programmed Engine Locking System by Automatically Detecting Drunken Drivers

A First Look at Microprocessors

Microcontroller Based Code Locking System with Alarm

PIC Microcontroller Introduction

Adding PC Connectivity to the MTS-88 Microcomputer Teaching. Omar Walid Abdul-Wahab, Wameedh Nazar Flayyih. System

EasyPIC5 Development System

Review of Ultra Fast Acting Electronic Circuit Breaker at Overloading

Advanced Embedded Systems

LPC2148 DEV BOARD. User Manual.

1 MALP ( ) Unit-1. (1) Draw and explain the internal architecture of 8085.

Computer Software Requirements for Real-Time Applications

LCD. Configuration and Programming

Design and Development of Graphical HMI panel with Modbus Communication for interfacing with various AC Drives Patel Vaibhavi Vadilal 1

8051 MICROCONTROLLERS

Summer 2003 Lecture 21 07/15/03

Future Designs, Inc. Your Development Partner LCD DEMO KITS

Microprocessors and Microcontrollers (EE-231)

[FILE] 8051 MICROCONTROLLER MAZIDI SOLUTION MANUAL ARCHIVE

2. List the five interrupt pins available in INTR, TRAP, RST 7.5, RST 6.5, RST 5.5.

LCD AND KEYBOARD INTERFACING

DTMF BASED INDUSTRIAL AUTOMATION

Introduction to ARM LPC2148 Microcontroller

B.C.A 2017 MICROPROCESSOR AND ASSEMBLY LANGUAGE MODULE SPECIFICATION SHEET. Course Outline

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

Microcontrollers. Principles and Applications. Ajit Pal +5 V 2K 8. 8 bit dip switch. P2 8 Reset switch Microcontroller AT89S52 100E +5 V. 2.

JOURNAL OF INFORMATION, KNOWLEDGE AND RESEARCH IN ELECTRICAL ENGINEERING (ISSN: ISSN , GIF: , SIF: )

Transcription:

Available online at www.sciencedirect.com Procedia Technology 4 (2012 ) 461 465 C3IT-2012 Effective Utilization of a Microcontroller Port for Optimisation of Hardware Mr. Sandeep Hanumante a and Prof. Kirti Sawlani b a Student, ME (Electronics), Department of Electronics Engineering, K. J. Somaiya College of Engineering, Mumbai-400077, India. b Faculty, Department of Electronics Engineering, K. J. Somaiya College of Engineering, Mumbai-400077, India. Abstract In embedded systems microcontrollers play a very important role because modern day s microcontrollers have inbuilt program as well as data memory of enough length to implement any embedded application without need of any external memory. But it has limited number of IO port pins to interface IO peripherals and better utilization of these IO port pins becomes extremely challenging. 2011 Published by Elsevier Ltd. Selection and/or peer-review under responsibility of C3IT Open access under CC BY-NC-ND license. Key words: Micro-controller; IO pins; LCD; Matrix keyboard 1. Introduction Now a days Liquid Crystal Displays (LCDs) are becoming very popular output devices and are rapidly replacing seven segment displays. There are varieties of alphanumeric LCDs readily available in the market ranging from 16X1 up to 40X4. In fact, it is a basic output device used along with 4X4 matrix keyboard in many embedded applications. If we interface these input and output peripherals on separate IO ports of a microcontroller, then very limited number of IO pins will remain available to interface other input and output devices like ADC, DAC, relays, I2C devices (DS1307/SHT71), etc. If we use LCD in 8-Bit mode then at least 13 IO pins will be required to interface it, but to minimize the IO pin count, generally, we use LCD in its 4-Bit mode operation. Thus at least 7 Pins will be required for the LCD. Apart from that, 4X4 matrix keyboard will require 8 more IO pins of a microcontroller. Thus both LCD and 4X4 matrix keyboard will consume 15 IO port pins of a microcontroller [1]. This is definitely poor utilization of microcontroller port pins to interface basic IO devices. To improve the utilization of port pins of a microcontroller we should interface 2212-0173 2012 Published by Elsevier Ltd. doi:10.1016/j.protcy.2012.05.073 Open access under CC BY-NC-ND license.

462 Mr. Sandeep Hanumante and Kirti Sawlani / Procedia Technology 4 ( 2012 ) 461 465 LCD and 4X4 matrix keyboard at the same port. This technique will work without fail if both devices have Tri-state IO buffers, which otherwise will fail due to bus contention. Both the devices are using same port of a microcontroller in time division multiplexing mode. Here, one may raise a point that if a microcontroller is communicating with LCD and at the same time user has pressed a key, then it will not be read by a microcontroller and any vital data fed from user may be lost by a microcontroller. But there are two basic assumptions, first is that, this port is available almost all the time for matrix keyboard, as LCDs are operating at very high rate and will take very less time to communicate with a microcontroller and second is that, 4X4 matrix keyboard is operated by human beings who are very slow in operation. Between any two key strokes, generally, minimum time gap of 500ms is observed and this time gap is quite sufficient for LCD communication if at all it is to be taken place. So with this basic assumption, interfacing of LCD and 4X4 matrix keyboard to the same port of a microcontroller will work without fail. 2. Interfacing of LCD & Keyboard In this section, interfacing of a LCD and 4X4 matrix keyboard to a common port of MCS-51 family microcontroller is explained. As a case study author has chosen 89C52 microcontroller along with MM74C922 a keyboard controller. As 4X4 matrix keyboard does not have capability of tri-stating its output line, so MM74C922 keyboard controller IC is used to fulfil this task. Another advantage of using keyboard controller is that, microcontroller is fully relieved from keyboard polling, as MM74C922 generates interrupt upon a key press and generates corresponding key code in its output buffer to be read by a microcontroller. Second advantage is that de-bouncing of a pressed key is done by the keyboard controller itself. Thus vital 20ms de-bouncing delay time of a microcontroller is saved. Using this controller, 4X4 matrix keyboard is interfaced with the microcontroller at the expense of 6 IO pins instead of 8 IO pins, out of which 4 IO pins are common data lines with the LCD. That means, exclusively 2 IO pins are required for 4X4 matrix keyboard and 3 IO pins are required exclusively to control the LCD. Thus total number of IO pin count to interface basic IO devices will be limited to 9 instead of 15, which is less by 6, if both the devices would have been interfaced separately to the microcontroller. In this case study, 8-Bits of Port 0 are used to interface both LCD and 4X4 matrix keyboard. Here LCD is used in its 4-Bit mode operation, 4 data lines of the LCD D7 to D4 are connected to P0.7 to P0.4 pins respectively [2] and to the same data lines, keyboard data lines D to A are connected respectively. Control lines EN of the LCD and OE ~ (OE BAR) of MM74C922 are connected to P0.2 and P0.3 pins respectively. Data Available (DA) is an interrupt of keyboard controller and is connected to P3.2 pin which is alternatively used as INT0 [3]. The circuit diagram is shown in fig. 1. This figure is a Proteus VSM 7 simulation run output. Microcontroller asserts only that control line of the device with whom it wants to communicate. For example, if it is going to read the output buffer of keyboard controller then EN of the LCD is de-asserted and OE ~ of MM74C922 is asserted. 3. Software Design To illustrate proper working of LCD and 4X4 matrix keyboard both connected to a common port, author has also interfaced Real Time Clock (DS1307) to the microcontroller [4]. To initialize DS1307 at the time of power-on, user is asked to give choice to continue with old time or change to new time. This message is displayed on LCD as shown in fig.1. During this communication with the LCD, output buffer of the keyboard controller is tri-stated by de-asserting OE ~. Microcontroller communicates with the LCD via different subroutines like put_nibbles, put_string, lcd_ready, etc. During execution of any subroutine of the LCD, OE ~ signal of keyboard controller is de-asserted. The longest execution time is required for

Mr. Sandeep Hanumante and Kirti Sawlani / Procedia Technology 4 ( 2012 ) 461 465 463 put_string subroutine and its rough estimate is 630 μs, provided that crystal frequency is 12MHz. Some of the subroutines used to communicate with LCD and keyboard are shown in the table 1. If user presses key A, then he/she will be asked to input all timing parameters starting from current seconds up to current year. As user presses any key to enter tens of seconds, microcontroller is interrupted by the keyboard controller. Then microcontroller executes Interrupt Service Routine to read output buffer of the keyboard controller and the pressed key is echoed back to the user as shown fig. 2. During execution of this ISR EN signal of LCD is de-asserted so as to tri-state IO buffer of the LCD. Execution time for this ISR is 10 μs fixed. Table 1 Different subroutines used to communicate with LCD and keyboard Subroutine to transfer nibbles to LCD: void put_nibbles(void) lcd_ready(); kbd_en=1; //tri-state output buffer of 74C922 lcd_buff1=lcd_buff; rw=0; rs=lcd_rs; rd_buff1=lcdport; rd_buff1=rd_buff1&0x0f; lcd_buff=lcd_buff&0xf0; lcd_buff=lcd_buff rd_buff1; lcdport=lcd_buff; lcd_en=1; //Enable LCD to write HI-NIB. into it lcd_en=0; //Disable it lcd_buff1=lcd_buff1<<4; lcd_buff1=lcd_buff1 rd_buff1; lcdport=lcd_buff1; lcd_en=1; //Enable LCD to write HI-NIB. into it lcd_en=0; //Disable it and return Interrupt Service Routine to read key code: void isrint0(void) interrupt 0 //ISR to read KBD. lcd_en=0; //Disable LCD lcdport=0xf0; //make HI-nib of P0 as input kbd_en=0; //enable output buffer of 74C922 keycode=lcdport; kbd_en=1; //Disable output buffer of 74C922 keycode=keycode>>4; kbd_buff[kbd_ptr]=keycode; Subroutine to check LCD Ready: void lcd_ready(void) kbd_en=1; //tri-state output buffer of 74C922 busy=1; //set MSB as input bit rw=1; rs=0; lcd_busy: lcd_en=1; //Rd status of LCD enabling it rd_buff1=lcdport; lcd_en=0; rd_buff1=rd_buff1&0x80; lcd_en=1; rd_buff2=lcdport; lcd_en=0; if(rd_buff1==0x80)//if busy is still HI goto lcd_busy; //then do not return Subroutine to display string on LCD: void put_string(unsigned char _string[16]) lcd_rs=1; for(i=0;i<16;i++) if(_string[i]==0x24) goto exit; lcd_buff=_string[i]; put_nibbles(); exit:;

464 Mr. Sandeep Hanumante and Kirti Sawlani / Procedia Technology 4 ( 2012 ) 461 465 Fig. 1 Interfacing of LCD and keyboard to PORT0 of 89C52 microcontroller Fig. 2 Status of display when user presses key 5 to enter tens of second

Mr. Sandeep Hanumante and Kirti Sawlani / Procedia Technology 4 ( 2012 ) 461 465 465 Fig. 3 Output status of the system when user completes initialization of RTC DS1307 As soon as initialization process of RCT DS1307 is finished, it generates square wave of 1Hz continuously on its SOUT pin. This signal is connected to P3.3 pin of the microcontroller which has alternate function of INT1. During execution of ISR for Interrupt-1 every after 1 second, microcontroller reads current time, day and date from DS1307 and displays it on the LCD, as shown in fig. 3. 4. Conclusion In this work, it is observed that a systematic design approach for interfacing LCD and 4X4 matrix keyboard to a single PORT of a micro-controller is quite possible so as to improve the hardware utilization factor of the system. 4-Bit interface mode of LCD is used to reduce number of IO pins required to interface it with a micro-controller. Tri-stating of 4X4 matrix keyboard is achieved by using MM74C922 keyboard controller. For complex embedded system applications where number of IO peripherals in the system is more, generally Hi-end microcontrollers like ARM7 are chosen where number IO port pins are in abundant, but it results in increased complexity, size and cost of the circuit. But by using the effective interfacing technique for basic IO devices like LCD and matrix keyboard, as illustrated above, one can still build complex embedded system using Low-end microcontrollers like 8051/PIC16FXXX. Applications of this technique are many, like public telephone booth, fuel (petrol/diesel) filling machine, automation of green-house, AC & DC drives, etc. Any embedded system which consists of 4X4 matrix keyboard and LCD can be built using this novel technique. The same technique can be used for those devices which have internal buffers that can be Tri-stated by enable control signal. References 1. Muhammad Ali Mazidi, Janice Gillispie Mazidi, Rolin McKinlay The 8051 Microcontroller and embedded Systems Using Assembly and C, 2/e, Pearson Education, Inc. 2. http://embeddedcraft.org/lcd4bit.html#top 3. http://www.edaboard.com/ftopic312107.html 4. www.8051projects.net/