(Updated Oct 4, '03) Available Now.
Introductory Pricing.
The introductory pricing for the first 25 units;
Top View 4 X 20 LCD with Yellow Green LED Backlight.
The 3 watt resistor at the right limits the backlight current to nominally 200 mA.
The screen message should read "LCD #110" !
2X 16 Top View Note that the pushbuttons are not used in this design. (The backward "Sony" and the red scraw is a reflection off my camera).
Bottom View
The six terminal connector on right provides GRD, two inputs and reset. The four terminal connector at the top is a serial TTL interface. Note DB9 connector may be used in applications requiring RS232 levels.
Along the bottom are the ADC input, Counter input and Dallas 1-W interface.
Introduction.
The LCD #110 Module consists of an assembled module with a 2X16 LCD (not back lit) or a 4X20 LCD with yellow-green LED backlight, a relay with a form C contact and associated connector, an on-board 5 VDC power regulator and male connectors to interface with Dallas DS1820 temperature sensors, a 10-bit A/D input, a counter input and a miscellaneous connector for the reset function, two inputs and ground.
The LCD #110 module does not include the source code for the programmed Microchip processor.
This design provides a 2X16 or 4X20 LCD with a serial 9600 baud interface. It may be interfaced with such processors as a Microchip PIC, Basic Stamp, BX24 or similar using TTL levels via a 4-terminal Molex type connector. Alternatively, it may be interfaced with a PC or similar using RS232 levels using a 9-pin DB9 female connector.
In addition to providing the LCD function, the design provides a beeper, a relay with a form C contact rated at 10A at 240 VAC, two TTL inputs, a single 10-bit A/D converter and a twisted pair run which can accommodate up to sixteen Dallas DS18S20, DS18B20 and DS1822 (any mix) temperature sensors over a maximum distance of 200 feet. The design also includes a counter and a timer which may be used to count the number of events over a specified number of seconds.
The baud rate is fixed at 9600. The 2X16 LCD is not back lit. The 4X20 LCD is backlit with a yellow green LED. In both cases, the LCD contrast is implemented using fixed resistors.
The processor provides a 64 character buffer. However, to avoid framing errors, it is suggested the user initially provide a one millisecond delay between each character until I get a better handle on the performance.
A source of +8 to 15 VDC with a minimum current rating of 50 mA is required. A 5.5 mm OD, 2.1 mm ID, center positive barrel type connector is provided.
LCD Commands.
The examples used in this discussion use the Basic Stamp BS2 language format.
Consider;
SerOut 0, 84, 1, ["Hello?n"] ' output on P0 at 9600 with 1 ms pacing delayThe text "Hello" is displayed followed by a new line. Note that the character ? is used to indicate the next character is a command. The ? is followed by the specific command, in this case 'n' which moves the cursor to the beginning of the next line and clears this line.
A list of various commands follows. Note that the commands are case sensitive.
?a - set cursor to home position. ?b - destructive backspace ?f - clear LCD and leave cursor at home position ?g - beep ?h - backspace ?i - forward cursor ?j - up cursor ?l - clear the current line and leave the cursor at the beginning of the line ?m - carriage return. Position the cursor at the beginning of the current line. ?n - new line. Advance to the beginning of the next line and clear this line. ?t - tab. Advance the cursor one tab. ?? - display the character '?'.The cursor may be set to any position using the x and y commands;
?y0 ?x15Note that the line number, follows the 'y' command and the column number, consisting of two digits, follows the 'x' command.
Thus;
SerOut 0, 84, 1, ["?y1?x08Hello"]positions the cursor at column 08 of line 1 and then prints "Hello".
Note that the line and column numbers begins with 0. Thus, for the 2 X 16 LCD, valid lines are 0 - 1 and valid columns are 00 - 15.
Any of eight user defined characters may be displayed using the digits 0 - 7. Thus;
?5?2causes user defined character 5 followed by user character 2 to be displayed on the LCD. Defining the user characters is discussed below.
Configuration Commands.
A number of parameters are stored in the processor's EEPROM. This includes the cursor style, the number of spaces in a tab and the eight user defined characters. The settings of all of these are displayed briefly on the LCD when the processor boots.
The default is a tab size of 4, a full blinking cursor (3) and the eight special characters consisting of a single horizontal line, two horizontal lines, etc.
All of these parameters may be modified. Note that when the modifications are made, the new values are written to the processor's EEPROM. Thus, the user defined characters, the tab size and the cursor style need only be modified one time.
Set Tab
The tab size may be set;
?s5In this case, the tab size is set to five. Valid values of the tab are 1 - 8.
When this command is received by the processor, the new tab size is written to EEPROM and this value is used thereafter when executing the ?t command.
When executing the ?t command, the cursor is advanced, and any characters in its path are overwritten with a space. For example, if the cursor is in column 3 and the tab size is 5, the cursor will advance to column 5. Anything in columns 3 and 4 will be replaced with spaces.
Set Cursor Style
The style of the cursor may be set using the ?c command.
?c3where the number is in the range of 0-3. A 0 configures as no cursor, a 2 as a non blinking cursor and a 3 as a blinking cursor.
User Defined Characters.
User defined characters may be defined using the ?D command;
?D300000000001e1e1eThe number after the 'D' is the number associated with the user defined character, in this case user defined character 3. This is then followed by the eight data bytes expressed in two digit hexadecimal. Note that the hexadecimal letters must be lower case.
In this example, lines 0, 1, 2, 3 and 4 consist of no dark pixels and lines 5, 6 and 7 consist of all five pixels being dark. Thus, when user defined character 3 is displayed using the command ?3, a character consisting of the lower three lines will be displayed.
Each user defined character is saved in EEPROM.
The design provides a 64 byte serial receive buffer. However, be careful. If one is defining all eight user defined characters, this involves sending 19 * 8 or 152 characters. Writing each of the eight bytes to EEPROM requires 15 ms and thus, one can easily over run the buffer. Rather, provide a delay after defining each character to allow for programming the EEPROM. For example;
serout 0, 84, 1, ["?D000000000000001f"] delay 500 serout 0, 84, 1, ["?D1000000000001f1f"] delay 500
Direct Control of the LCD.
Commands may be directly passed to the LCD using the ?! command;
?!01In this example the command 01 is sent directly to the LCD which clears the LCD.
A word of caution. With all other commands the program keeps track of the current cursor position. This is not done with commands sent directly to the LCD using the ?! command. Thus, if the user configures the LCD such that the cursor is located at some point using the "?!" command, subsequent line feeds and similar will not work correctly as the program does not know the current cursor location.
Clearly, if the ?! command is used to place the LCD in a mode such that the cursor is decremented with each character or the display itself is scrolled, the subsequent operation of the LCD which assumes an incrementing cursor and a fixed display will give unpredictable results.
Other Commands
Note that when commands are sent to the LCD #110 module where a response is returned to the controlling processor, a minimum delay of 200 ms is provided to allow such relatively slow processors without a UART, such as the Basic Stamp, to configure for receiving serial data. These commands include;
?S - returns the state of the relay. ?Ix - returns the state of the specified TTL input. x is 0 or 1. ?A - return the A/D value in decimal ?T - returns the temperature of all DS1820 devices on the single twisted pair run. ?Cx - returns the count in decimal. x is a value in the range of 0 - 9.
Relay
The LCD #110 module provides a single relay which may be operated using the ?N command and released using the ?F command.
The state of the relay may be read using the ?S command.
The LCD unit then responds to the controlling processor with the state of the relay followed by a new line..
1
TTL Inputs
Two TTL inputs are provided. They may be read using the ?I command followed either a 0 or a 1.
?I0The LCD #110 unit responds by sending the state of that input.
1Note that internal pull up resistors are provided in the unit and thus an open will be read as a logic one and a ground as a logic zero.
Analog to Digital Converter
One ten bit analog to digital converter is provided. Note that the processor's positive supply and ground are the high and low references for the conversion. An A/D reading will be performed on the specified A/D in response to the ?A command.
The LCD unit responds by sending the decimal value in the range of 0 to 1023;
997
The ADC input to the unit consists of a 0 - 10V input and a 0-5V input with a 10K - 10K voltage divider. This arrangement provides the capability of measuring voltages in the range of 0 - 10 VDC, but the 10K input resistance may be an excessive load for some sensors. The voltage divider resistors may be easily removed by cutting out the 10K resistors.
Dallas DS1820 Temperature Sensor Interface.
The LCD #110 unit provides a single twisted pair run, which may accommodate up to sixteen DS18S20s, DS18B20s, or DS1822s or any mix of the three with a maximum of 200 feet of twisted pair cable. Note that the DS1822 is functionally the same as the DS18B20 except it is less accurate. But, it is about the same price as the DS18B20. Thus, the DS1822 may be used, but in my mind, it makes no sense to do so.
Temperatures on the run are performed in response to the ?T command; ?T The unit responds by sending the temperature measurements;
0 27.50 10 F33A 1 26.67 22 3B3B 2 25.72 28 3C2C 2 -5.26 etc 3 3.04 etcIn this example, four devices were found. As each was found, it was assigned a sequential number in the range of 0 - F. This is followed by the temperature in degrees C, followed by the device type. A 10 indicates a DS18S20 was found, a . 22, a DS1822 and a 28, a DS18B20. This is then followed by a 16-bit serial number which is assigned specifically to the DS1820 device.
A few notes;
Thus, 0 might correspond to a DS18S20 in your PC, 1 to the living room, 2 to the freezer. Assume you then add one on a cold water pipe in the basement. You may well find 0 is still your PC, but 1 is now the water pipe, 2 is the living room and 3 in the freezer.
However, note that once a system is in place, 0 will always be the PC, 1 the water pipe, etc. But if your cat pulls off the sensor in the living room, 2 will then be the freezer.
If you don't wish to use the serial number information, you might consider initially connecting the sensors on a breadboard and use your finger to determine which device is 0, which is 1, etc and then label each of the sensors and then install them with 0 in the PC, 1 in the living room, etc.
Note that all DS1820 devices are operated in the parasitic power mode (the DS1820s use the signal lead for power) and thus a single twisted pair may be multipled from one device to the next.
In this design, the resolution of the temperature is 0.03 degrees for a DS18S20 and 0.0625 for a DS18B20 and DS1822. .
Counter.
The counter function is implemented using the ?C command;
?C3The number of TTL transitions on input T0CKI are counted over the specified number of seconds, in this case, three seconds. The design provides for 1 to 9 seconds. The ?C0 command causes the LCD #110 module to respond with the current value of the 16-bit counter.
The unit responds with the number of counts expressed as a decimal number which occurred over the specified period of time, or, in the case of the ?C0 command, the current totalized count.
1234The maximum number of counts is 65,535.
When the processor is booted, the number of counts is set to zero and the counter is enabled. The counter may be read at any time using the ?C0 command. An application that comes to mind is in counting tipping bucket pulses in a rainfall gauge. However, it is important to note that the value of this counter is not continually written to EEPROM and if power is lost, the processor is rebooted and the number of counts is again initialized to zero.
Sample Code for the Parallax Basic Stamp 2.
' MeasAD2.BS2
'
' Illustrates an interface with the Serial LCD #110 Module to perform A/D measurement,
' read the state of relay and reverse the state of the relay. Also reads and displays
' the states of the two TTL inputs.
'
' BS2 Ser LCD #110 PIC
'
' term 5 ---------------------------- RX (TTL Ser, Term 2)
' term 6<--------------------------- TX (TTL Ser, Term 1)
'
' copyright, Peter H Anderson, Baltimore, MD, Sept, '03
BAUDRATE CON 84 ' 9600 noniverted
ADVal Var Word
N Var Byte
M Var Byte
RelayState Var Byte
InputState Var Byte
OUT0 = 1
DIR0 = 1 ' configure serial output
DIR1 = 0 ' serial input
Pause 2000 ' be sure the LCD has booted
SerOut 0, BAUDRATE, 1, ["?c0"] ' configure for no cursor
TOP:
SerOut 0, BAUDRATE, 1, ["?f"]
SerOut 0, BAUDRATE, 1, [" A/D Demo?n"] ' display on first line followed by new line
For N = 1 to 100
SerOut 0, BAUDRATE, 1, ["?A"] ' command for an A/D reading
Serin 1, BAUDRATE, 300, ADError, [Dec ADVal, Skip 2]
SerOut 0, BAUDRATE, 1, ["?y1?l", Dec ADVal] ' clear line and display result
ADContinue:
SerOut 0, BAUDRATE, 1, ["?I0"] ' read TTL input 0
Serin 1, BAUDRATE, 300, InputError, [Dec1 InputState]
SerOut 0, BAUDRATE, 1, ["?x08", Dec InputState] ' diplay on LCD
SerOut 0, BAUDRATE, 1, ["?I1"] ' read TTL input 1
Serin 1, BAUDRATE, 300, InputError, [Dec1 InputState]
SerOut 0, BAUDRATE, 1, ["?x10", Dec InputState] ' diplay on LCD
InputContinue:
Pause 1000
GoSub ToggleRelay
Next
Pause 5000
GoTo TOP
ADError: ' if time out in receiving result from Ser LCD
SerOut 0, BAUDRATE, 1, ["?lAD Error"]
GoTo ADContinue
InputError:
SerOut 0, BAUDRATE, 1, ["?lInput Error"]
GoTo InputContinue
ToggleRelay:
SerOut 0, BAUDRATE, 1, ["?S"] ' fetch state of relay
Serin 1, BAUDRATE, 250, ToggleRelayError, [Dec RelayState]
If RelayState = 0 Then TurnOnRelay
SerOut 0, BAUDRATE, 1, ["?F"] ' turn off relay
Return
TurnOnRelay:
SerOut 0, BAUDRATE, 1, ["?N"] ' turn on LED
Return
ToggleRelayError: ' if timeout in receiving response to ?S0 command
SerOut 0, BAUDRATE, 1, ["?lRelay Error"]
Return
' Counter2.BS2
'
' Illustrates an interface with the Serial LCD #110 Module to fetch
' the number of counts.
'
' BS2 Ser LCD #110 Module
'
' term 5 ---------------------------- RX (TTL Ser, Term 2)
' term 6<--------------------------- TX (TTL Ser, Term 1)
'
' copyright, Peter H Anderson, Baltimore, MD, Sept, '03
BAUDRATE CON 84 ' 9600 noniverted
CountVal Var Word
N Var Byte
OUT0 = 1
DIR0 = 1 ' configure serial output
DIR1 = 0 ' serial input
Pause 2000 ' be sure the LCD has booted
SerOut 0, BAUDRATE, 1, ["?c0"] ' configure for no cursor
TOP:
SerOut 0, BAUDRATE, 1, ["?f"]
SerOut 0, BAUDRATE, 1, [" Counter Demo"] ' display on first line
Pause 2000
For N = 1 to 100
SerOut 0, BAUDRATE, 1, ["?l?x06"]
SerOut 0, BAUDRATE, 1, ["?C0"] ' clr line, advance to col 06 and count command
Serin 1, BAUDRATE, 200, CountError, [Dec CountVal, Skip 2]
SerOut 0, BAUDRATE, 1, [Dec CountVal] ' display result
CountContinue:
Pause 1000
Next
Pause 5000
GoTo TOP
CountError: ' if time out in receiving result from Ser LCD
SerOut 0, BAUDRATE, 1, ["?lError"]
GoTo CountContinue
' MeasT2.BS2
'
' Illustrates an interface with the Serial LCD #110 Module to four DS1820 devices
' on the Dallas interface and display the device number, temperature, device type and
' serial number of each device on the single twisted pair run on the terminal. The four
' temperatures are displayed on the LCD.
'
' BS2 Ser LCD #110 Module
'
' term 5 ---------------------------- RX (Ser TTL, term 2)
' term 6<--------------------------- TX (Ser TTL, term 1)
'
' copyright, Peter H Anderson, Baltimore, MD, Sept, '03
BAUDRATE CON 84 ' 9600 baud
Device Var Byte
TWhole Var Byte
TFract Var Byte
DeviceType Var Byte
DeviceID Var Word
N Var Byte
OUT0 = 1
DIR0 = 1 ' serout
DIR1 = 0 ' serial input
Pause 200
SerOut 0, BAUDRATE, 1, ["?fTemp Demo?n"] ' clear display, msg and new line
Pause 2000
SerOut 0, BAUDRATE, 1, ["?f"] ' clear the LCD
Top:
SerOut 0, BAUDRATE, 1, ["?T"] ' command to begin temperature measurements
For N = 1 To 4 ' can be up to 16, but limit to 4 for display
' on 2X16 LCD
Branch N, [PT1, PT1, PT2, PT3, PT2]
PT1: SerOut 0, BAUDRATE, 1, ["?f"] 'clear and home the cursor
GoTo Continue
PT2: SerOut 0, BAUDRATE, 1, ["?x08"] 'advance to column 8
GoTo Continue
PT3: SerOut 0, BAUDRATE, 1, ["?y1?x00"]
GoTo Continue
Continue:
Serin 1, BAUDRATE, 3000, TempDone, [Dec Device, SDec TWhole, Skip 1, Dec2 TFract, Dec2 DeviceType, Hex4 DeviceID, Skip 2]
' important to get back to read the next sensor within 1.5 seconds
Debug Dec Device, " "
If TWhole < 128 Then Around
TWhole = TWhole ^ $ff + 1 ' if its negative, do 2's comp
Debug "-"
Serout 0, BAUDRATE, 5, ["-"]
Around:
Debug Dec TWhole, ".", Dec2 TFract, " ", Dec2 DeviceType, " ", Hex4 DeviceID, 13
' display on terminal
SerOut 0, BAUDRATE, 1, [Dec TWhole, ".", Dec2 TFract] ' display on LCD
'
Next
Goto TOP
TempDone:
Pause 1000
SerOut 0, BAUDRATE, 1, ["?fDone"] ' clear the LCD and display message
Pause 2000
SerOut 0, BAUDRATE, 1, ["?f"]
Goto Top