upc eetac_1

Project P11: Adding ASCII messages 

LCD display


6-bit Johnson counter

1. Specifications

- Enhance the P10 project adding an standard LCD display to represented ASCII messages on the two-lines 16-character screen. Represent information about the  internal state. For example: "Click ST button to start the sequence", "State: Num 0", "Click ST button to stop", etc.

- Connect some digital outputs to drive the LCD display programming the application using the LCD library of the C compiler.

- Use an LCD_flag signal to write the LCD only when there is new information to be printed.

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.

LCD chip

Follow the discussion in class to fully understand these specifications and be able to infer a plan. 

Learning materials and tutorials:

Study carefully these tutorials and run them in Proteus to see how the system works, and can be programmed taken advantage of all your previous knowledge.

- This is a circuit based on the PIC18F4520 microcontroller that uses a library of LCD functions.  Here you are a very good link to read more on the subject.

- Alternatively, when installing the PLIBS for the XC8 compiler you have access to a variety of peripheral libraries that includes the XLCD (Not yet available in Citrix computers).  Try this example circuit that works because 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.

- 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 adapted (PIC16F877A, XC8) from the former Unit 4.11 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) Project locations and file names. This is the list of files when using the libraries from the example above (PIC16F877A) and copying and renaming the P10 source file as LCD_Display.c.

FILES 

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 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 LCD_flag to not to write continuously to the display, but only when new information has to be presented. Class notes: (1).

 

Fig. 2.

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 features at a time. For instance:

(1) Run the P10 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.

 

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.

LCD

Fig. 3. The LCD to represent ASCII  messages.

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.

 

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.

 

Fig. 4. 

 

5. Report

This is a page with some guidelines on how to deliver an oral presentation.

 

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.  

 

Other materials of interest

Books, web pages, etc.

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