AN-1129 Android controlled LCD Display

This application note shows how an LCD display can be controlled via an Android application using Bluetooth. The SLG46620V GreenPAK™ CMIC has been used as the main controller for the project.

Following is a list (along with brief details) of the components/modules used in the project:

1. LCD 16X2 character display

2. SLG46620V GreenPAK4 CMIC

3. HC-06 Bluetooth

4. The Android application

LCD Character Display

The liquid crystal chosen for the project has a 16x2 (16 columns and 2 rows) display. The LCD, as shown below, has 16 pins; we have also described the use of each below.

R/W:

When this signal is '1' = Data is to be read from the LCD RAM

When this signal is '0' = Data is written on the LCD RAM.

‘Enable’ is basically a Latch signal. First, you have to send ‘1’, followed by the '0' signal (after specific delay) to latch the data.

Register Select Control signal:

When this signal is '1' = It accepts data i.e. to be displayed

When this signal is '0' = It accepts instructions for the LCD (setting fonts, cursor positions etc.).

The D0 to D7 pins constitute an 8-bit Data bus. It is used to send both data as well as Instructions to the LCD based upon the control signals.

Backlight + and Backlight GND: Turns the backlight of the LCD ON for visibility.

VEE: is a contrast voltage. Using a potentiometer, you can adjust the contrast of the LCD.

The greater the voltage, the more contrast you get and vice versa (voltage should never exceed VCC = +5 volts).

This LCD has 2 lines and can write maximum 16 characters per line.

LCD Display

Figure 1. LCD Display

SLG46620V GreenPAK4 CMIC

The SLG46620V is the first member of the 4th generation of GPAK products. It combines the best analog and digital resources from previous generations with expanded functionality and improved accuracy. The chip is available in a tiny 2.0 x 3.0 x 0.55 mm 20-pin STQFN package.

SLG46620V GreenPAK4 CMIC

Figure 2. SLG46620V GreenPAK4 CMIC

Code (Hex) Instruction
1 Clear display screen
2 Return home
4 Decrement cursor (shift cursor to left)
6 Increment cursor (shift cursor to right)
5 Shift display right
7 Shift display left
8 Display off, cursor off
A Display off, cursor on
C Display on, cursor off
E Display on, cursor blinking
F Display on, cursor blinking
10 Shift cursor position to left
14 Shift cursor position to right
18 Shift the entire display to the left
1C Shift the entire display to the right
80 Force cursor to beginning of 1st line
C0 Force cursor to beginning of 2nd line
90 Force cursor to beginning of 3rd line
D0 Force cursor to beginning of 4th line
38 2 lines and 5×7 matrix (8-bit mode)
28 2 lines and 5×7 matrix (4-bit mode)
n Next line
t Tab

 

Table 1. 16 x 2 LCD Commands

HC-06 Bluetooth

Bluetooth is a wireless technology standard used to exchange data over short distances from fixed and mobile devices. It can also be used to build personal area networks (PANs). Range of a Bluetooth module is approximately 10 Meters. The Bluetooth is interfaced with the CMIC via the UART interface. As no data is being sent back to the LCD, only the TX and the GND pins are connected with the CMIC. A separate power supply is connected to the VCC.

HC-06 Bluetooth

Figure 3. HC-06 Bluetooth

HC-06 Data Frame

Figure 4. HC-06 Data Frame

Android Application

A custom Android application is developed for the JHD162A 16x2 LCD display. It connects with the server Bluetooth (HC-06) as a client. Main features of this application are as follows:

  • Bluetooth client application; turns on Bluetooth on application startup
  • Send ASCII
  • Send HEX
  • Adjustable delay in between every byte sent
  • Custom initialization sequence for the LCD

The application is built using the Object Oriented programming principles.

Application Screenshots and use cases:

There are 2 screens in the application: Home Screen and the terminal. Both of the entities are shown in Fig. 5 & Fig. 6.

Home Screen Terminal Screen
Figure 5. Home Screen Figure 6. Terminal Screen

1. First of all, the user needs to press the INITIALIZE button to send an initialization sequence before sending any data. This is required by the LCD as it needs to be initialized with a specific sequence/commands first. Without the initialization, the LCD will not function properly. If the entered initialization sequence on the home screen was not the valid hexadecimal data, the application will give an error and won’t send any data. In such a case, the user needs to press DISCONNECT and change the initialization sequence to a valid hexadecimal format (or enter the initialization sequence manually and send it by pressing the HEX pushbutton).

2. Enter text in the text box available on the screen. The user has two options to send the data. If the user presses the ASCII button, the application will send data as it is, with propagation delays as selected in the previous screen.

3. If the user presses the HEX button, the application will check whether the user has entered the data in valid hexadecimal format. If yes, then the application will similarly send the data with propagation delays. (Check appendix for hex format for this application.)

4. User should be able to disconnect from the connected device by pressing the DISCONNECT button.

GreenPAK Designer Circuit

GreenPAK designer was used to design the circuit for the LCD. With the objective of zero code for LCD driving, the LCD must be driven from the CMIC. The CMIC had to be intelligently configured to drive the LCD. The GreenPAK designer divides the CMIC into 2 matrices; 0 and 1. Following is a detail of the designed circuit.

Matrix 0

Figure 7. Matrix 0

The first matrix receives the data from the Bluetooth device via the UART protocol. The Tx pin of the Bluetooth is connected to the PIN 10 of the CMIC. The data received via Bluetooth is 8-bit with an additional start and stop bit. A counter is deployed which increments with the incoming bits.

A SPI block is used to receive data via Bluetooth. As the SPI protocol is different from UART, slight modifications help us to receive the incoming data from the Bluetooth module.

PIN 9 is attached to the enable pin of the LCD. The enable is by default always high and momentarily goes to zero when the data needs to be latched onto the LCD.

The CNT/DLY0 (which is being used as the delay when the enable is active low) is configurable.

The LCD requires an active low signal of at least 30-60ms according to the datasheet. However, maximum delay values are used in order to make sure that no data gets lost, as the application is not time critical.

Matrix 1 shows the SPI block (which receives the data via Bluetooth) directly connected to the 8-bit data bus from D0 to D7. The data bus pins are in turn connected to the pins from 20 to 13, as shown in Table 2.

Code (Hex) PIN Number Data bit
20 D0
19 D1
18 D2
17 D3
16 D4
15 D5
14 D6
13 D7

 

Table 1. Data PINs

CNT/DLY0 properties

Figure 8. CNT/DLY0 properties

Matrix 1

Figure 9. Matrix 1

For RS and R/W of the LCD, 4-bit and 3-bit LUTs have been used, to differentiate between the control and the data commands.

The RS control pin is connected to PIN 12 of the CMIC while the R/W pin is connected to PIN 3 (in matrix 0). As the communication is half duplex i.e. the LCD is receiving commands via Bluetooth and the CMIC but no data/information is sent back to the Android app; the R/W is always active low (write mode).

The RS, R/W and EN pins of the LCD each require a pull-up resistor while the data bus pins are connected directly via the CMIC pins to the LCD.

Conclusion

In this application example, data sent to the SLG46620V CMIC via the Bluetooth module was displayed on the LCD. The Silego GreenPAK CMIC worked effectively for the task at hand. The Android app is designed to ensure that the CMIC is able to configure any other LCD, which may have a different initialization sequence. The Silego GreenPAK CMIC provides developers ease in transforming their ideas to products; without the hassle of coding!

About the Author

Name: Bilal Qamar

Background: Bilal Qamar is an electrical engineer focused on electronics and embedded system design. He has worked on different technologies including hardware prototyping, product design, Android / Windows Radio Interface Layer, Qt framework for cross platform tools and Internet of Things. He is currently working as an engineer at u-blox - a global leader in positioning and wireless semiconductors and modules.

Contact: appnotes@silego.com

 

Files



See full list of Application Notes

© 2017 Silego Technology. 1515 Wyatt Drive, Santa Clara, CA 95054.
Facebook LinkedIn Twitter YouTube Google