Introduction to LCDs Kit


The aim of this kit is to show how to use a 16×2 alphanumeric Liquid Crystal Display (LCD) with a PC. First we show how to connect it to the parallel port and echo and handle-keyboard input. Then we show how to use the LCD to display temperature from a DS1620 Digital Thermometer/Thermostat chip and set the HI & LO trigger points in it. All C source code is provided.


The circuit is quite straightforward. IC2 is a 5V regulator the powers the kit. Diode D2 protects the kit against reverse polarity on the DC input jack. The trimpot is used to adjust the contrast and viewing angle of the LCD. Resistors R2 and R3 hold the DS1620 CLK and RST inputs low when the kit is disconnected from the PC. This allows the chip to work in stand-alone mode. Resistor R1 and diode D1 convert the separate data input and output lines from the PC to the single bidirectional data line on the DS1620. When writing to the chip, R1 pulls DQ high when AUTO is high. DQ is pulled low via D1 when AUTO is low. When reading from the DS1620, AUTO must be set high first. This high is blocked by D1 so that the DQ output can drive ACK. Connection to the DS1620 alarm outputs is via connector X3. The DC input voltage also appears on this connector as does ground. This is useful for powering devices driven by the alarm outputs directly from the kit.
LIQUID CRYSTAL DISPLAYS LCDs have become very popular over recent years for information display in many smart appliances. They are usually controlled by microcontrollers. They make complicated equipment easier to operate. LCDs come in many shapes and sizes but the most common is the 16 character x 2 line display. It requires only 11 connections  eight bits for data (which can be reduced to four if necessary) and three control lines (we have only used two here). It runs off a 5V DC supply and only needs about 1mA of current. The display contrast can be varied by changing the voltage into pin 3 of the display, usually with a trimpot. To get the display working requires eight bits of data, a register select line (RS) and a strobe line (E). These are supplied from the PC printer port (refer to schematic). A third input, R/W, is used to read or write data to/from the LCD. In this kit the R/W line is tied low so only writes to the LCD are possible (more on this later). The eight bits of data are supplied from the printer port data lines and two printer port control lines are used for RS (auto) and E (strobe). Basically the LCD has two registers, a data register and a control register. Data is written into the control register when RS is low and into the data register when RS is high. Data is latched into the LCD register on the falling edge of Enable. The sequence for writing to the LCD is: 1. To begin, E is low 2. Select the register to write to by setting RS high (data) or low (control) 3. Write the eight bits of data to the LCD 4. Set the Enable signal high then low again. There are certain minimum timing requirements that must be followed when writing to the LCD, such as data setup times and Enable signal pulse width. These are in the order of tens and hundreds of nanoseconds. Extra timing delays are also introduced by the cable capacitance used to connect the kit to the PC printer port. Delay routines may be needed when using fast PCs to meet these timing requirements. The software supplied include these delay routines. LCD displays have a busy flag that is set while it is executing a control command. This flag is not accessible because the R/W line has been tied low (write). This is not such a problem because all commands have a maximum execution time. We simply wait for this time to pass before accessing the LCD again, eliminating the need to check the flag and thereby saving on an I/O line! Eg. The Clear Display command has an execution time of approx. 1.6mS. After sending this command to the LCD we simply wait 2mS before continuing on. This ensures that the command has finished. Characters to be displayed are written into the LCDs data RAM memory. The amount of RAM available depends on the type of LCD. The LCD used in this kit has 80 bytes of RAM. An internal address counter holds the address of the next byte to write to. These 80 bytes are broken up into two blocks of 40 bytes. The address range of the first block is from 00h to 27h and the second block from 40h to 67h. After power up and initialization address 00h is the first character of the top line and address 40h is the first character of the bottom line. The address counter is set to address 00h and is automatically incremented after each byte is written. Only the first 16 bytes of each line are visible. If we now start writing data to the LCD it will be stored from address 00h on but only the first 16 characters will be visible. To display the rest of the characters we need to scroll the display. Scrolling simply means changing the start address of each line. If we scroll left one position address 01h becomes the first character of the top line and address 41h the first character of the bottom line. Scrolling right does the opposite  addresses 27h and 67h become the first characters of the top and bottom lines. As you can see, each block of addresses wrap around in a circular manner. The next address after 27h is 00h; the next address after 67h is 40h. If we scroll left 40 times we will bring address 00h back into view as the last character on the top line. As you can see the address ranges of each block are not continuous. There is a gap of 24 bytes between the end of the first block (27h) and the start of the second (40h). So, if we keep writing characters to the display the first 40 will be stored in addresses 00h to 27h, the
next 24 will be lost and the next 40 will be stored at addresses 40h to 67h. The internal address counter is directly accessible so we can set the next address to write to. This is how the characters are written to the second line of the LCD. For example, we can send 5 characters to the first line, set the address counter to 40h and then start writing characters to the second line.
Using the DS1620 The DS1620 is a Digital Thermometer/Thermostat IC from Dallas Semiconductor. The chip measures temperatures from -55 to +125 C (-67 to +257 F) in 0.5 C increments and has three alarm outputs. It requires no calibration or external components. You may get the data sheet from The three alarm outputs, designated THIGH, TLOW and TCOM function as follows: ᄋ THIGH goes high when the measured temperature is greater than or equal to a user-defined upper limit (TH). ᄋ TLOW goes high when the measured temperature is less than or equal to a user-defined lower limit (TL). ᄋ TCOM goes high when the temperature exceeds the upper limit and stays high until the temperature falls below the lower limit. These three outputs can be used to directly control heating and cooling appliances via suitable drive circuitry (eg. Relays and optocouplers). Data is read from and written to the DS1620 via a 3-wire serial interface (DQ, CLK and RST). The user-defined upper and lower trip points are stored in the IC in non-volatile memory. This means that the trip points are remembered even when the power is removed. The DS1620 can be used in two modes  Three-Wire mode for interface to a computer or Stand-Alone mode. This last mode does not require a computer interface. With RST and CLK low, the chip will continuously monitor the temperature and set the alarm outputs accordingly. This means that once you have programmed the upper and lower trip points the kit can be disconnected from the PC and you can use the alarm outputs for monitoring or control functions. You can even remove the chip from its socket and put it in your own temperature controller, using the kit simply as a DS1620 programmer. As with the LCD, certain minimum timing requirements must be observed between each of these steps. In particular, RST must remain low for at least 5ms after writing data to the DS1620 (step 8). This gives the chips internal EEPROM time to store the data. Also, the DS1620 needs 1 second to execute a start-convert instruction. So, after starting a temperature conversion, you must wait 1 second before reading the result. Temperature registers in the DS1620 are nine bits long and can be positive or negative values. Each reading has a resolution of 0.5 C. For positive temperatures, the most significant bit (bit 8) = 0 and bits 1-7 hold the integer value. Bit 0, is set, adds 0.5. For negative temperatures, bit 8 = 1 and bits 7-0 represent the twos complement of the temperature. To get the actual value, invert bits 7-0 then add 1. The DS1620 is controlled via a set of 8-bit instructions. Depending on the instruction an 8 or 9 bit data value is either read from or written to the chip. All instructions and data are transferred serially starting with the least significant bit D0.
To read or write a value to the DS1620:
1. To begin, RST is low and CLK high.2. RST high
3. CLK low
4. Set DQ equal to Bit 0 of instruction
5. CLK high
6. Repeat steps 3, 4 and 5 for remaining instruction
To write to the chip:
7. Repeat steps 3, 4 and 5 for Bits 0-7 or 0-8 of the
data to be written
8. RST low for at least 5ms
To read from the chip do Steps 1 through 6 above then:
7. Set the AUTO signal high so that data can be read
from the DS1620
8. CLK low. DQ now outputs the data to be read (LSB
9. Read and store DQ
10. CLK high
11. Repeat steps 8, 9 and 10 for the remaining bits of
data to be read
12. RST low