Skip to main content

AN-1129 Android controlled LCD Display

Contents

References

For related documents and software, please visit:

//www.xmece.com/products/greenpak

Download our free GreenPAK Designer software [1] to open the .gp file [2] and use the GreenPAK development tools [3] to freeze the design into your own customized IC in a matter of minutes.

Dialog Semiconductor provides a complete library of application notes [4] featuring design examples as well as explanations of features and blocks within the Dialog IC.

  1. GreenPAK Designer Software, Software Download, and User Guide, Dialog Semiconductor
  2. AN-1129 Android controlled LCD Display.gp, GreenPAK Design File, Dialog Semiconductor
  3. GreenPAK Development Tools, GreenPAK Development Tools Webpage, Dialog Semiconductor
  4. GreenPAK Application Notes, GreenPAK Application Notes Webpage, Dialog Semiconductor
  5. SLG46620Datasheet, Dialog Semiconductor

Introduction

This application note shows how a LCD display can be controlled via an Android application using Bluetooth. The SLG46620V [5] GreenPAK IC 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 GreenPAK IC
  3. HC-06 Bluetooth
  4. The Android application
Figure 1. LCD Display
Figure 2. SLG46620V GreenPAK IC

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.).

Table 1. 16 x 2 LCD Commands

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

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.

SLG46620V GreenPAK IC

The SLG46620V is the first member of the 4th generation of GreenPAK 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.

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 IC 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 IC. A separate power supply is connected to the VCC.

Figure 3. HC-06 Bluetooth
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 Figure 5 and Figure 6.

Figure 5. Home Screen
Figure 6. Terminal Screen
  1. First of all, the user needs to press theINITIALIZEbutton 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 pressDISCONNECTand 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 theASCIIbutton, 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 theDISCONNECTbutton.

GreenPAK设计电路

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 IC. The GreenPAK IC had to be intelligently configured to drive the LCD. The GreenPAK designer divides the IC into 2 matrices; 0 and 1. Following is a detail of the designed circuit.

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 GreenPAK IC. 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 defaultalways highand 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.

Table 2. Data PINs

MSB to LSB

PIN Number

Data bit

20

D0

19

D1

18

D2

17

D3

16

D4

15

D5

14

D6

13

D7

Figure 8. CNT/DLY0 properties
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.

RS控制销与销12 GreenPAK IC 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 IC 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 GreenPAK IC pins to the LCD.

Conclusion

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