Вы находитесь на странице: 1из 20

Abstract Embedded system might appear less user friendly to most people but the reality is that all

the systems they think to be more user friendly are composed of one or more embedded systems. Moreover, the use of embedded systems in the design of our daily used devices is becoming inevitable. The design and simulation of a serial terminal device which can be control remotely has been illustrated in this report. Focus has been on the interfacing of peripheral devices such as keypads, LCD and virtual terminals to a microcontroller.

1.0 Introduction Embedded systems come in handy when a system needs to be cost effective and still delivers its purpose of design efficiently. Thus embedded systems can be defined as computing systems with tightly coupled hardware and software integration, which are designed to perform a specific task [1]. Though it limits the developers ability to exploit the system, it has all the components needed to perform a designated function. Embedded systems can found in most of our daily used devices such MP3, printers, routers, and even vehicles. Basically, embedded systems are microcontrollers or microprocessors which are quite different from the traditional processors which serve general purpose functions. This project will be focusing on PIC microcontroller and it interface with some peripheral devices. It will also look expected results when the interfaced circuit is simulated using the MPLAB software.

2.0 Problem Analysis


2

This project has been aimed to design a serial terminal system to control a remotely operated 4-bit pattern generator. A PIC18F4520 microcontroller will be interfaced with a Liquid Crystal Display (LCD) and a numeric keypad. Each of the four I/O pins will be independently controllable to provide steady state high and low or pulse signal with separately controllable high of low periods within 1ms 5s. The current state of the device will be shown by a liquid Cristal Display (LCD) which will also be used as a user interface during the adjustment of the pattern generator through a numeric keypad. The expected results when the system is designed using a FreeRTOS running on a PIC18F4520 microcontroller will be discussed. The serial connection can be used for debugging purposes. But since its function it not very evident in this project, it will be rarely conversed. Figure 1.0 shows a simplified block diagram of the device interconnectivity.

KEYPAD

I/O

MICROCONTROLLER

SERIAL CONNECTIO N

LCD DISPLAY

Figure 1.0: Block Diagram of Component Interconnections

3.0 Problem Solution


3

A PIC18F4520 will be used as microcontroller generating the 4-bit pattern; a LM016L will serve as the LCD to display device status while the KEYPAD-PHONE will be the numeric keypad for manipulating the pattern generator. The FreeRTOS will be used to write a C code to implement the system and finally simulation and testing will be done using the MPLAB IDE and the Proteus VSM. 3.1 Hardware Component Overview Components needed for this project are: Microcontroller - PIC18F4520 LCD - LM016L Numeric keypad KEYPAD-PHONE

Virtual terminal - Serial Port

3.1.1 Microcontroller - PIC18F4520 In general, PIC microcontrollers are very common and often used by developers because the availability of development tools such as compilers, assemblers, debuggers and emulators. Moreover, it is believed to come from a reliable source - Microchip Technology Corporation. However, this project will be using a microcontroller from PIC18 family which has RISC architecture with on-chip program ROM, data RAM, data EEPROM, timers, ADC and USART and I/O ports. PIC18F4520 particularly has the following advantages: Economically high computational power (nanoWatt Technology) High endurance Enhanced flash program memory Design enhancement capability

Figure 2.0: PIC18F4520 Microcontroller

Features Operating frequency Program memory (bytes) Program Memory(Instructions) data memory(bytes) data EEPROM memory(bytes) Interupt Sources I/O Ports Timers Capture/Compare/PWM Modules Enhanced Capture/Compare/PWM Modules Serial communications Parallel Communications (PSP) 10-bits A/D Module Resets (and delays)

PIC18F4520 DC 40 MHz 32768 16384 1536 256 20 Ports A,B,C,D,E 4 1 1 MSSP, Enhanced USART Yes 13 Input Channels POR, BOR, RESET INSTRUCTION, Stack Underflow (PWRT,OST), MCLR (optional), WDT Yes Yes 75 Instructions; 83 with Extended Instruction Set Enabled 40-Pin PDIP 44-Pin QFN

Programmable High/low-voltage detect Programmable Brown-out reset Instruction Set Packages

44-Pin TQFP Table 1.0: PIC18F4520 Features

3.1.2 LCD - LM016L LCDs are becoming more popular and commonly used as user interface displays in embedded system design because of its numerous advantages over the traditional LEDs. These advantages include: Unlike LEDs it can display graphics in addition to numbers and characters Characters and graphics are easily programmed Gets cheaper by the day

Ability to refresh on its own

LM016L comprises of 14 pins as shown in Table 2.0 Pin 1 2 3 4 Symbol Vss Vcc VEE RS I/O ---I Description Ground +5 V power supply Power supply to control contrast RS = 0 to select command register, RS = 1to select data 5 6 7 8 9 10 11 12 13 14 RW I register R/W = 0 for write, R/W = 1 for read Enable The 8-bit data bus The 8-bit data bus The 8-bit data bus The 8-bit data bus The 8-bit data bus The 8-bit data bus The 8-bit data bus The 8-bit data bus

E I/O DB0 I/O DB1 I/O DB2 I/O DB3 I/O DB4 I/O DB5 I/O DB6 I/O DB7 I/O Table 2.0: Pin position of the LCD

3.1.3 Numeric keypad KEYPAD-PHONE

Figure 3.0: Internal structure of keypad phone Just as briefly shown in Figure 3.0, the keypad is organised in 3X4 matrix of rows and columns which is accessed by the microcontroller through ports. This access always involves two processes, key detection and key identification, when programming the interfaced keypad. The processor can implement the key detection process by using either interrupt method or scanning method as shown in Figure 4.0.

1 Start

Ground all rows

Ground next row

Read all columns Read all columns No Al keys ope n? Row identifi ed? 8

Yes Yes Initialise RBIF Find which key is pressed

Wait for interrupt

Get scan code from table

RBIF ?

Return from interrupt

Wait for debounce Read all columns

Figure 4.0: a flow chat of the key press detection (Interrupt method)[2] 3.1.4 Serial Port Serial data communication transfers data using two methods, asynchronous and synchronous, which is done one bit at a time as opposed to the parallel communication. It can be connected to interfaces such as Ethernet, firewire, USB etc enabling the device to be operated efficiently from a remote location. 3.2 Software Components overview

FreeRTOS - FreeRTOS is a small footprint, premtive, open source, real time kernel that has been designed specifically for use on microcontroller[3]. It is becoming very popular now with a lot of developers switching to its use because of the following features: pre-emptive r co-operation, flexible task priority assignment, queues, binary

semaphores, counting semaphores, recursive semaphores etc. But unfortunately, it has been rarely used in this project for reasons explained later in this report.

Protues Virtual System Modelling (VSM) this a software that combines mixed mode spice circuit simulation, animated components and microprocessor models to facilitate co- simulation of complete microcontroller based designs[4]. It has played a major role in the accomplishment of this project. If you can design a circuit using this software (which is not very hard), then the physical prototype of your design will be run through.

MPLAB Integrated Development Environment (IDE) is a free, integrated toolset for the development of embedded applications employing Microchip PIC and dsPIC microcontrollers[5]. This software has been used to write and compile the C program that runs the LCD.

4.0 Problem Implementations 4.1 LM016L (LCD) Interfacing

10

Figure 5.0: LCD Interfacing This LCD consists of 14 pins as show in figure 0.0 where the Vcc was used to supply +5V and the Vss terminal was connected to the ground while the VEE was used to control the contrast of the LCD. The RS pin was used to allow the sending of commands to the LCD when it was set to 0 (RS = 0) and also the sending of data to be shown on the LCD when RS is set to 1 (RS =1). Moreover, the R/W (Read/Write) pin was used to allow the reading of information from the LCD when it set to 1 (R/W = 1) and when set to 0 (R/W = 0) allows the writing of information to LCD. T o latch information that is currently at the LCDs data pins, a high-low pulse was sent to the En pin. The 8-bit data pins of the LCD are basically used to send information or read the content of the LCD. However, there are two methods of sending either commands or data to the LCD.
Implementing a delay before sending the next character

Using the busy flag to Verify that the LCD is ready for the next character

4.2 Numeric keypad KEYPAD-PHONE interfacing

11

Figure 6.0: Keypad Interfacing

Two methods can be employed for the key press detection of the keypad:

Interrupt method- using the PORTB-Change, the rows are connected to the PORTB.Low and the columns are connected to PORTB.High such that any changes made to the pins (connected to the column) will cause an interrupt signifying a key press.

Scanning method- the processor provides 0 to the output latch by grounding all the rows then reads data from the columns, unless these data are not equal to 1111, a key has not been pressed. The microcontroller continues to loop this process until a key press is identified.

4.3 Device implementation


12

Figure 7.0: Device Interfacing The circuit, as shown in Figure 7.0, was designed using Protues VSM and was supposed to be simulated using the MPLAB IDE. The MPLAB which act as assembler, linker and simulator is a PIC microcontroller tool provided for free by Microchip Corporation. The program was written using a C programming language. 4.3.1 A Pseudocode on how the system program works Displays a request, Pls Enter Pin No., for the user to select an output channel on the LCD (line 1) Check keypad to identify key pressed Verify that a valid key has been pressed if not keep requesting for a valid user input Display a request, Pls enter pulse width, for the user to enter the pulse period of the signal Verify that 1ms input 5s if not keep requesting for a valid period within the period range Display the output pin number on line 1 and the pin status on line 2 Return to keypad scan 4.3.2 Additional sub program for enhanced performance
13

If * key is pressed, decrement the pulse width by 1ms unless it is already 1ms If # key is pressed increment the pulse width by 1ms unless it is already 5s Figure 8.0 shows the flow chart of the system operation

Start

LCD display: enter channel

LCD display: channel mode and

Keypress detection Vali d entr y?

No

Return to scan keypads

Yes

LCD display: enter period

Keypress detection No

1ms delay 5s ? Yes 1

Figure 8.0: System Flow Chart 5.0 Results When the device is powered (simulated), a user input request ( Pls Enter Output pin ) is displayed on the LCD indicating that the device is well interfaced. This is the only output
14

produced by device since the programs for other components has not been included. Figure 9.0 shows the simulated device on ISIS.

Figure 9.0 Device in Running Mode

6.0 Discussion of Results Ideally the status of any of the output pins is to be displayed on the LCD with respect to the user input through the keypad. But the program to run the numeric keypad and the microcontroller was unavailable, so only the LCD which had its program well written was running on the device. Moreover, the fact that the LCD was able to come on and display the required characters showed that it has been properly connected to the microcontroller. Besides, the LCD did not display anything initially after interfacing it with microcontroller. I had to connect a resistor to the RE3 pin of the microcontroller which acts as a reset. There was also limited time for me to carry out some required research to improve the current performance of the system. However, it would have been more challenging and interesting if all the required codes for the device components was available. Though it would take more time and dedication, a more
15

intrinsic understanding of the device operation would have been appreciated. Nevertheless, was happy to have designed a working embedded system.

7.0 Conclusion The design and simulation of an embedded system device to provide a serial terminal and remote control of a 4-bit I/O has been the aim of this project. All the required components
16

was able to be interfaced but only the LCD, which had its code written, was able to run fully during simulation On completion of the project, I realised that embedded systems, known for its limited user interface, should be carefully designed to avoid confusion or misunderstanding to end users. This project, though basically software has all the required ideas to produce a physical hardware prototype. This project can be said to be a fundamental to many embedded system design because of it structure and application. Its application can be found in weather monitoring devices where the user does not necessarily be in this location with the device.

References [1] Qing, L. (2003) Real-Time Concepts for Embedded Systems. New York: Elsevier Science & Technology.
17

[2] Mazidi, M. (2008) PIC Microcontroller and Embedded Systems Using Assembly and C PIC18. New Jersey: Pearson Education, Inc., [3] Barry, R. Summary Information on FreeRTOS project and the FreeRTOS product family. [Online] (http://www.freertos.org/). 2010. (Accessed Decenmber 7, 2010). [4] Labcenter Electronics, The VSM Advantage. [Online] (URL http://www.labcenter.com/products/vsm_overview.cfm). (Accessed December 5, 2010). [5] Microchip, MPLAB Integrated Development Environment. [Online] (URL http://www.microchip.com/stellent/idcplg? IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en019469&part=SW007002). 2010. (Accessed December 9, 2010).

Appendices

18

Appendix 1 Bill of Materials

19

Appendix 2: Programming and compilation using MPLAB

Appendix 3: Designed Circuit on Run Mode

20

Вам также может понравиться