Introduction and functional description
This document describes the hardware and software design of an LCD display driver board. The purpose of this board is to receive data from an external circuit board via serial interface, and display the data on an LCD display module. It is mainly intended to be a diagnostic/debugging tool, displaying data from external microcontroller circuits under development. It can however, be used in any application where data needs to be displayed on an LCD.
The on-board PIC16F1713 microcontroller contains functions for the following main tasks:
This document describes the technical implementation details of the functions, while the Use Manual document describes how to use the UART protocol and LCD display functions.
Terms and definitions
Please note the distinction between the following:
The main components of the LCD display driver board are
LCD Display module
The following LCD display module is used in this project:
DEM 16226 SYH-LY from DISPLAY Elektronik gmbh
This module is compatible with Hitachi HD44780U, which is the most commonly used standard for LCD modules. It should be straightforward to use any compatible LCD module.
The module has 8 data input lines, but can be configured to use only 4 to reduce the number of I/O pins on the controlling MCU, at the cost of reduced speed. In this project, all 8 data input lines are used. In addition, the LCD module has 3 control lines (RS, RW, E which is standard for Hitachi HD44780U compatible devices), which is controlled by the controlling MCU.
The module has backlight and adjustable contrast/intensity.
Operation voltage, VDD: Typ 5V, max 7V
Operation voltage, backlight: 4 – 4,5V
Input voltages max VDD + 0,3V
In this project the PIC16F1713 is used. This is kind of arbitrary, it was the most suitable one I had around at the time. This MCU is considerably larger and more feature-rich than actually needed for the functionality currently included in this project, so a smaller and simpler MCU can be used. On the other hand, it opens up for adding more functionality later, like navigation buttons and number pads.
The microcontroller must satisfy the following requirements:
Serial UART port
UART module is used in asynchronous mode, to receive 8-bit words from external circuit on the RX line on the receiving MCU.
Note that the default RX pin on the PIC16F1713 is on port C, which is currently used by the LCD data lines. However, by using the Peripheral Pin Select (PPS) module, this pin can be configured on any pin on the B port. Hence, RB3, RB4 and RB5 can be used for the TX/RX line and the two additional control lines, respectively. Currently RB3 is selected as the RX pin.
The baud rate used in this project is 2400bps.
The display driver board PCB includes 3 diagnostic LEDs, one of each of the channels E, RS and R/W. These LEDs are not vital and can be omitted.
The LCD module includes backlight LEDs. These are powered by separate power pins, which has been made available on the display driver board PCB.
LCD contrast adjustment
The LCD module includes pins for contrast adjustment. This has been implemented by a trim potentiometer on the display board driver PCB.
The display driver PCB has common input voltage connectors to drive the MCU and the LCD module.
This voltage should not exceed 6,5 Volts, which is the maximum operating voltage for the PIC16F1713 (the LCD module has a maximum of 7 Volts). Typically, 5Volts is used in this project.
The display driver PCB has a standard Microchip ICSP connector for ICSP programmers such as PICkit3.
Header for external connections
A 13-pin header for external connections is currently mounted on the PCB. This provides ground and power connector to external boards, and the serial input connector. It also provides an 8-pin parallel connector to the PIC MCU. This parallel interface seemed to be needed in the early phase of this project, but it will probably be removed in the next HW revision.
The software structure is designed to support the reception of data from an external circuit board via serial interface, and display the data on an LCD display module. The transmitted data can be commands to the LCD module, such as clear display, or data to be displayed on the LCD display. The data to be displayed can be in various formats, such as unsigned decimal, signed decimal, hexadecimal or strings/characters. A number of functions on the PIC microcontroller performs the tasks of receiving serial data, converting it to the desired format/command and sending it to the LCD module.
Since the data sent over the UART link is nothing but raw bytes, some kind of protocol is needed to interpret the transmitted data and to convert it to the appropriate format or command before being sent to the LCD display module. Currently, the following simple protocol is implemented;
This structure is illustrated in Figur 1.
Future versions of the protocol may be extended to more than three bytes, to support strings or larger numbers.
The functions given in Table 1 are currently implemented. The value of the control byte is given for each function. Functions with no control byte value (given as “-“ in the table) is internal to the PIC MCU and is not intended to be controlled by an external board.
Functions that may be implemented in the future are given in Table 2. These are mainly functions converting to various number formats, and will be implemented as needed. Since they are not yet implemented, a control byte value has not yet been assigned.
[Table to be inserted]
Synchronization of serial channel
In the first version, simple UART communication will be used. There is no acknowledge signal or any way to know if the transmission was successful, or even more important for this application, no way to know if the receiving MCU is ready to receive another series of bytes.
In the first version, using UART communication, it will be the responsibility of the transmitting MCU to wait sufficiently long, using a suitable delay.
With the baud rate and main oscillator frequency used in this project (2400bps and 1MHz), it turns out that the transmission of the three bytes takes longer (~10ms, measured 8,1ms for two bytes) than the function that sends the byte to the display (5ms), so that there will never be a conflict. However, if in the future more complicated LCD functions are implemented, delays might be required on the transmitting side.
The main loop is in LCD_driver_v01.c.
Two additional files will be created;