upc eetac_1

P10

Project P11: Peripherals. Libraries of specialised functions

P12


LCD display to represent text messages (ASCII code)

1. Specifications

Enhance any of the P10 project adding a standard LCD display to represent ASCII messages on the two-line 16-character screen. Information can be about the internal state, for example: "Click ST button to start the sequence", "State: Num 0", "Click ST button to stop", etc.

LCD

Fig 1. The common LCD display LM032L. The LCD controller is the standard Hitachi HD44780 (Dot Matrix Liquid Crystal Display Controller/Driver) or equivalent like the HD44100.

HD44100 

 

Learning materials and tutorials:

Several example projects that include an LCD. Study and run them in Proteus to see how the system works and can be programmed taking advantage of all your previous knowledge. Here you are a very good link to read more on the subject.

- LAB#11. This project of the serial transmitter with an LCD is solved in the laboratory session.   

- This is the project of the Adder_BCD_1digit from P9 enhanced with the LCD to show results. Ideas and discussion, Proteus hardware circuit, C source filezipped project containing the remaining library files, and a picture with some results.

- This is tutorial for a fixed-time Timer_LCD (PIC18F4520, XC8) that uses a library of LCD functions. It is organised as a control unit with a datapath for counting real time from an external CLK signal.

- Alternatively, when installing the PLIBS for the XC8 compiler you have access to a variety of peripheral libraries that includes the XLCD. Try this example circuit where all the required functions and headers from the PLIBs are copied in the project folder and so you can compile and run it.

LCD display

Fig 2. Using the 8th bit of the PORT where the LCD is connected you can switch ON and OFF the LCD.

Examples for other μC:

- These are Internet references (1) (2) (3) with different sets of high-level C functions to interface the LCD display. This example  (PIC16F877A, XC8) is copied  from (1). Thus, you can integrate these libraries into your project and use the LCD functions.

- This is an example (PIC16F877A, XC8) that you can study and learn about what is necessary to use the LCD. The functions were integrated in the old HI-TECH C compiler which is no longer in use. 

- This is an example using ATmega8535 from the former Unit 4.11. And here is the same example slightly modified to be able to write in both rows of the LCD display.

 

2. Planning

1) Copy and rename conveniently a project from P10. For instance, the Serial_Transmitter becomes now the project:

L:\CSD\P11\Serial_Transmitter_LCD\(files)

 In Fig. 3 is an example list of source files when using the libraries to interfece specific hardware.

Files

Fig. 3. Example of a typical project that includes the LCD libraries to drive specific and advanced hardware subsystems (peripherals), thus, becoming a multiple-file project.

2) Organise the hardware. Draw your circuit in a sheet of paper and discuss where to connect: reset (CD), CLK oscillator, digital I/O and push-buttons. A good idea is to connect inputs and outputs in the free pins of a development board like the PICDEM2 Plus, in case you would like to prototype the application. In this board, the LCD display is connected to the microcontroller's PORTD.

3) Determine which functions in the main program have to be modified in order to control the LCD display. Define the RAM internal variables that will facilitate the communication to the LCD. Use a convenient indicator like var_LCD_flag to not to write continuously to the display, but only when new information has to be presented.

4) Plan a sequence for building and debugging the application: the idea is "plan & develop & test" step by step enhancing the initial state diagram with a new feature at a time. For instance:

(1) Start running the copy of P10 project and try to print only the typical ASCII message "Hello World" on the LCD.

(2) Add now the messages you like in each FSM state or add new states when

3. Development

1) Draw the schematic of the application in Proteus copying the P10 and modifying it so that the LCD is made visible on the top schematic. Serial_transmitter_LCD.pdsprj

2) Run the microcontroller's IDE to develop and compile the C code copying and adapting the previous P10 code. Do it section by section according to your plan, testing if it works before adding new code. Serial_transmitter_LCD.c

 

4. Testing 

Run the Proteus simulator. Do it in step by step mode while watching variables and placing break points, specially to follow the interrupt flags. This is the zipped project.

 

Fig. 4. 

 

5. Report

This is a page with some guidelines on project oral presentations and written reports. 

 

6. Prototyping

You're invited to download the application to a given training board an verify that it works as expected and the same as in the simulator.

 

Other similar projects on sequential circuits

Books, web pages, etc.

- The LCD interface is solved everywhere for many microcontroller environments.  

- Exams, questions, and problems

 

Other materials of interest

Books, web pages, etc.

- The datasheet of the Hitachi chip used in to control simple LCD displays.