Serial LCD Kit LCD #118 (formerly LCD #108) with Variable LED Backlight) for the PICAXE


Introduction.

The photo has not been updated to indicate LCD #118. The LCD #118 operates at 2400 baud and includes a 4.0 ceramic resonator. Otherwise, it is the same as the #117 shown. Note the TIP-41 power transistor which is used to control the LED backlight current.


(Oct 16, '06). The LCD #118 kit replaces the LCD #108. The LCD #118 adds a number of capabilities.

These added capabilities are noted in parenthesis in the following discussion.

The LCD #118 is intended for PICAXE users. It uses 2400 baud and also uses a precise external 4.0 MHz resonator. It may of course be used with any processor capabable of 2400 baud. I also have the LCD #117 which has the same capabilities, but operates at 9600 baud.

The LCD #118 kit includes a programmed PIC16F648A (18-pin DIP) or similar, a 4.7K resistor for the /RESET of the PIC, a 330 and 4.7K resistor for biasing the contrast of the interfacing LCD, a TIP41 NPN transistor as associated 330 Ohm resistor for controlling the intensity of the LED backlight, a small supply of 22 AWG solid wire (four colors) suitable for use on a solderless breadboard and schematics. This kit was designed for tinkerers using a solderless breadboard. A PCB is not provided.

Note that this kit does not include an LCD. I have a number which are available including the 20X4 Character LCD with Yellow - Green Back light shown in the photo here. This includes a 4.7 Ohm (0.5W) and 39 Ohm (3W) current limiting resistor which may be used to limit the back light LED current to a maximum of nominally 200 mA when using either a +5 VDC or a +12 VDC source, respectively.

The LCD #118 PIC processor is code protected and the source code is not provided.

The programmed PICs (16F648A or similar) may be purchased in bulk; $34.95 / 10, $295.00 / 100. Note this includes only the programmed PICs. Feel free to sell these to others or incorporate them in your product.

If you would like a baud rate other than 9600, I can supply 300, 1200, 2400 or 19.2K. There is a $10.00 charge for this. For 38.4K and 57.6K, please contact me.


I am away until June 20, '08


wulf den at hawk's mountain has developed a nice circuit board and offers a number of configurations in kit form at very reasonable prices. Note that if you buy the LCD #117 programmed PIC from him, you do not need to buy it from me.

K107 module from wulf den


This is a combination of my popular LCD #118 Kit, a K107 printed circuit board from wulfden at hawk's mountain and a quality 4X20 LCD with blue backlight. Note that this is a fully assembled unit. $39.95.

Rear View.

Documentation.


Introduction.

This design provides an interface between a 2400 baud serial line from a PICAXE and similar and a character LCD having an HD44780 interface.

The serial interface is TTL. That is, the idle state is a TTL logic one, or near +5 VDC. This is often termed non-inverting or true. For the PICAXE, use the T2400 specifier.

The baud rate is fixed at 2400.

The processor provides for variable backlight intensity. The backlight current is controlled by a TIP-41 transistor which is included with the kit. The maximum backlight intensity is controlled with a series limiting resistor.

The processor does not provide for variable contrast. Two fixed resistors, 4.7K and 330, are included in the kit to provide nominally 0.3 VDC for contrast. However, the user may wish to use a potentiometer.

The processor provides a 64 character buffer. However, delays of nominally 100 ms are required after sending a command which requires the LCD processor to write to it's EEPROM.

A source of +5 VDC with a minimum current of 10 mA is required for this design. If the interfacing LCDs LED back light feature is used, the back light current must be limited to less than 250 mA.


LCD Commands.

A list of various text manipulation commands follows. Note that all commands are prefaced with a "?" and 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
?k - down cursor
?l - clear current line and leave 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 '?'.

Note that the "?g" causes a 50 ms burst of nominally 500 Hz on a processor output. The LCD #118 kit does not include the interfacing audible device.

The cursor may be set to any position using the x and y commands;

?y0
?x15
Note that the line number, follows the 'y' command and the column number, consisting of two digits, follows the 'x' command.

Thus, outputting the string;

    "?y1?x10Hello?n"
positions the cursor at column 10 of line 1 and then prints "Hello", followed by a newline which also clears the next line.

Note that the line and column numbers begins with 0. Thus, for a 4 X 20 LCD, valid lines are 0 - 3 and valid columns are 00 - 19.

Any of eight user defined characters may be displayed using the digits 0 - 7. Thus;

	"?5?2"
causes user defined character 5 followed by user character 2 to be displayed on the LCD. Defining the user characters is discussed below.

(New with the LCD #118). A user text screen may be displayed at any time using the command;

    "?*"
I ship this with the customized text message as simply all numbers and characters. This may be modified using the ?C command which is discussed below.

Big Number Mode (New with LCD #118). This capability is operational only when using a 20X4 LCD.




The LCD #118 design provides both three and four block wide characters. The big number mode is entered;

    "?>3"
or
    "?>4"
On receipt of either of the "?>3" or "?>4" commands, the processor will download to the LCD the special characters required to display the big numbers. These are probably different from any user defined characters which the user may have defined. Thus, don't display your user defined characters when displaying in the "big number" format.

The cursor is then located on the top row of the current column.

In the >3 mode, as each numeric digit is received, it will erase anything appearing in the three column wide by four high space and display the number in the big number format. In addition, it will clear the column to the right of the character. The cursor will then be located at the top row for display of the next digit. Note that for the three block wide mode, this is four columns to the right of the upper left of the previous character. Thus, each digit uses four columns, three for the display of the digit and one for the spacing between digits.

Display of the minus sign, colon and decimal point use two columns, one for the display of the symbol plus one space.

The >4 mode is similar, except that each digit is four wide plus one space.

There is no intelligent "wrapping" provision for the "big number" mode. Thus, if there are only two columns remaining before the end of the LCD and you attempt to display a "7", part of the "7" will appear on the right side of the LCD, and the rest on the beginning of the display.

The big number mode may be exited at any time:

    "?<"

This may be used to display ordinary text along with the "big number" characters. For example, in one of the photos, the message "4X4 Demo" appears. This might be done;

    "?<"  ' exit the big number mode
    "?y0?x164X4"  ' row 0, beginning at column 16 - 4X4
    "?y1?x16Demo" ' row 1, beginning at column 16 - Demo

Note that the "?< command simply exits the "big number" mode. It does not download the user defined characters that might be used for graphics.

If one later wishes to use the user defined characters;

    "?R"  ' restore the user defined characters.
Again, note that the characters associated with the display of the "big number" characters are not compatible with the user defined characters one might use for plotting and thus, "big numbers" and graphics type applications using specially defined characters cannot coexist on the display.

Configuration Commands.

A number of parameters are stored in the processors EEPROM. This includes the geometry of the LCD, the type of cursor, 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 20 X 4 LCD, a tab size of 4, a full blinking cursor (3), eight user defined characters consisting of a single horizontal line, two horizontal lines, etc., a backlight intensity setting of 40, a text screen consisting lower case letters "a-t", "A-T" and two rows of numbers (see photo). The default screen which is selected for bootup is the configuration screen which displays the geometry, tab size, specially defined characters, the backlight setting and the cursor type.

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 and the geometry of the LCD need only be modified one time.

Note that after sending commands which cause the processor to save data to EEPROM, provide a 100 ms delay prior to sending additional characters. Otherwise the addtional characters may be lost.

Set LCD Geometry

Setting the geometry defines the configuration of the interfacing LCD.

?Gyxx
For example;
   "?G216"
indicates the LCD is a 2X16 configuration.

Note that appropriate configurations include 2X16, 2X20, 2X24, 2X40, 4X16 and 4X20.

The configuration is important for the processor to properly position the cursor after each text character is displayed and in executing such commands as backspace, up cursor, down cursor, new line, etc.

Set Tab

The tab size may be set;

	"?s5"
In 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.

Backlight Intensity

The intensity of an LED backlight on the associated LCD may be adjusted;

    "?B80"
Note that the digits following the "B" are two digit hexadecimal, ranging from 00 (back light off) to FF (back light full on). This command causes an output to change duty cycle over the range of 0 to 255/256. The output may be used to switch a power transistor which then controls the avarage backlight current.

Set Cursor Style

The style of the cursor may be set using the ?c command.

	"?c3"
where 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. As with the set geometry and set tab, the style of the cursor is saved to EEPROM.

User Defined Characters.

User defined characters may be defined using the ?D command;

	"?D300000000001f1f1f"
The 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 pixels and lines 5, 6 and 7 consist of all five pixels. 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 or more and thus, one can easily over run the buffer. Rather, provide a one second delay after defining each character.

Custom Text Screen (New with the LCD #118).



The customized text screen may be an advertisement which is displayed on boot or a template which may be displayed at any time. It is set using the ?C command, followed by the row, followed by the twenty characters which are to appear on the row. For example, the following sequence defines the custom screen shown in the photo.

    "?C0abcdefghijklmnopqrst"
    "?C1ABCDEFGHIJKLMNOPQRST"
    "?C201234567890123456789"
    "?C398765432109876543210"

Note that this custom screen may be displayed at any time;

    "?*"

Boot Screen Selection (New with the LCD #118).

The screen which is displayed on boot may be specified using the ?S command followed by a number, 0, 1 or 2.

   "?S1"  ' display the configuration setting on boot
   "?S0"  ' display no screen on boot.
   "?S2"  ' display the user custom text screen on boot.

Direct Control of the LCD.

Commands may be directly passed to the LCD using the ?! command;

	"?!01"
In 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, 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.

General Purpose Outputs

The LCD #118 provides two general purpose TTL outputs. Either of these outputs, 4 and 5, may be brought high or low using the 'H' and 'L' commands.

	"?H4?L5"
The above brings output 4 high and output 5 low. Note that outputs 0, 1, 2, 3 and 6 and 7 are not valid.

On power up, all outputs are at a high impedance (configured as inputs). As each output is addressed, it is taken out of the high impedance state. The initial high impedance state permits the user to use either pull up or pull down resistors to avoid "bounce" when the processor is powered.

The current (source or sink) by any output should be limited to 15 mA.


Assembly

Content of the Kit.

Please take a few seconds to acquaint yourself with the content of the kit.

It consists of;

1 	Programmed Microchip PIC16F628 Processor (18-pin DIP).
1   4.0 MHz Ceramic Resonator (3-pin SIP)
1	4.7K Resistor for the /MCLR on terminal 4 of the processor
1 	4.7K Resistor for LCD contrast.
1	330 Ohm (Orange, Orange, Brown) for LCD contrast.

1   TIP-41 NPN Power transistor and 330 Ohm base resistor.

1	5V LED with integrated series limiting resistor for debugging.

1	Bundle of 22 awg solid wire suitable for use with a solder less breadboard.

Assembly.

Wire the circuitry as shown in Fig #1,

Note that the programmed PIC is an 18-pin DIP device with terminals 1-9 on one side and terminals 10 (across from terminal 9) through 18 on the other side. Integrated circuits are descendants of vacuum tubes and the terminal assignment is in a circular counter clockwise fashion as viewed from the top.

The layout of the LCD terminals is illustrated on the extreme right of the figure. It has been my experience that most LCDs have either an array of 14 terminals arranged in a single line or 2 lines of 7 terminals. If the LCD has an LED back light there may also be terminals 15 and 16. However, occasionally, I have seen other arrangements and it is best to consult the LCD data sheet for the LCD terminal numbers.

Note that there is a 4.7K pull up resistor to +5 VDC on the /MCLR terminal (term 4 of the PIC processor). The processor may either be reset by applying power, or by momentarily grounding the /MCLR terminal.

Connect the center terminal of the 4.0 MHz resonator to GRD and connect the two outter terminals to terminals 16 and 16 of the PIC processor.

Note the OP/TEST input on terminal 8 of the processor. For the moment, leave this input open.

Prior to applying +5 VDC and GRD to the circuit, carefully check that +5 VDC is on terminal 14 of the PIC and terminal 2 of the LCD. Carefully, check to verify ground is on terminal 5 of the PIC and terminal 1 of the LCD.

Apply power and verify the LCD displays the geometry of the LCD, the tab size, eight user defined characters and a blinking cursor. The unit is shipped with a 4 X 20 geometry, a tab size of 4, user defined characters of a single row of pixels, two rows, three rows, etc and a blinking cursor.

This screen message appears for about two seconds and the LCD is cleared and the cursor is positioned at the home position. The LCD is now awaiting the receipt of characters to display. Momentarily ground the /MCLR (term 4) on the PIC processor to reboot the processor and the message will again appear for two seconds.

If the message does appear, it verifies that both the processor and the LCD are operational and the associated wiring is correct.

Troubleshooting the LCD circuitry

If the screen message does not appear.

Sample Routines

Most of the features of the LCD #118 are illustrated in the following routines which were written for the PICAXE-18X. Note that the "beep" function may be tested using the test LED on terminal 6 of the PIC. Operation of the 'H' and 'L" output commands may be similarly tested using the test LED.

One important point. Normally, when idle the serial terminal is at a logic one. When a character is sent, the lead is brought low for 1/2400 secs (start bit) followed by the data bits. However, when the PICAXE is booted, the output is initially at a high impedance and is then brought to an output logic zero. Thus, prior to executing the first SerOut instruction, it is important to bring the output to a logic one and pause briefly.


' LCD118_1.Bas  (PICAXE-18X)
'
' Illustrates many capabilities of the LCD #118 LCD
'
' Congigures the interfacing LCD for 4X20 geometry.  This need only be done one time as
' this is saved in the LCD #118 EEPROM
'
' Clears the LCD using the "?f" command.
' Writes some text.  Note the new line function "?n"
' Displays the user defined characters using commands ?0, ?1, etc
' Moves cursor to line 1, col 00 using commands "?y1" and "?x00"
' Clears lines 1, 2 and 3 using "?l" command.  Note "?j" is used for down cursor.
'
' Positions cursor at line 1 and displays the values of N and Word in decimal and in Hexadecimal.
'
' Defines new user defined characters consisting of no vertical lines, 1 vertical line,
' etc through 5 vertical lines.
'
' A bar scaled to 0 through 25 is displayed on line 3.  This might be used to graphically
' display a quantity.
'
' The PWM duty cycle is then set to 25 steps over the range of 00 to 250 using the ?B command.
' The duty cycle is also displayed on the LCD.
'
' The program then continually sets the two general purpose outs to 10 and 01 using the ?H and
' ?L commands.
'
'
' Peter H Anderson, Baltimore, MD, Feb, '04

   Symbol N = B2
   Symbol OWord = W0
   Symbol OByte = B3


   ' These variables are used in Sub BarDemo
   Symbol NN = B8
   Symbol LeftOver = B9
   Symbol Num_5 = B10
   Symbol J = B11

   ' These variables are used in Sub SerOutByteHex
   Symbol X = B8

   ' Variables used in PWMDemo
   Symbol Duty = B9

   High 0		' Be sure Tx Pin is idle for some time
   Pause 5000		' wait for PICAXE LCD to boot


   SerOut 0, T2400, ("?G420")			' configure LCD as 4 X 20
   SerOut 0, T2400, ("?f")			' clear the LCD and home the cursor

   Pause 100
   SerOut 0, T2400, ( "    PICAXE LCD?n")	' note new line


   SerOut 0, T2400, ("www.phanderson.com?n")

   SerOut 0, T2400, ("?0?1?2?3?4?5?6?7?n")		' display special characters

   Pause 2000			' pause to admire

   SerOut 0, T2400, ("?y1?x00")						' position cursor at beginning of row 1

   SerOut 0, T2400, ("?l?j?l?j?l?y1")				' clear lines 1, 2 and 3 and start at line 1
   ' note the use of down cursor command

   OWord = 12345



   For N = 0 to 25
      SerOut 0, T2400, ("?x00?y1")	' locate cursor to beginning of line 1

      SerOut 0, T2400, (#N)		'  display in decimal
      SerOut 0, T2400, ("?t")

      OByte = N
      GoSub SerOutByteHex     		' display in hex
      SerOut 0, T2400, ("?t")


      SerOut 0, T2400, (#OWord, "?t")	' display a word in decimal

      GoSub SerOutWordHex			' and in hex
      SerOut 0, T2400, ("?n")

      OWord = OWord + 1

      SerOut 0, T2400, ("?g")		' beep
      Pause 1000
   Next

   SerOut 0, T2400, ("?D00000000000000000")		' define special characters
   Pause 200					' delay to allow EEPROM to program

   SerOut 0, T2400, ("?D11010101010101010")
   Pause 200

   SerOut 0, T2400, ("?D21818181818181818")
   Pause 200

   SerOut 0, T2400, ("?D31c1c1c1c1c1c1c1c")
   Pause 200

   SerOut 0, T2400, ("?D41e1e1e1e1e1e1e1e")
   Pause 200

   SerOut 0, T2400, ("?D51f1f1f1f1f1f1f1f")
   Pause 200


   SerOut 0, T2400, ("?c0")		' no cursor


   SerOut 0, T2400, ("?y3?x00?l")	' cursor to beginning of line 3 and clear line

   GoSub BarDemo

   Pause 200

   GoSub PWMDemo

   Pause 200


AGAIN:   					' continually bring outputs 5 annd 4 high and low
   SerOut 0, T2400, ("?H5?L4")
   SerOut 0, T2400, (".")
   Pause 500
   SerOut 0, T2400, ("?L5?H4")
   SerOut 0, T2400, ("!")
   Pause 500
   GoTo AGAIN

BarDemo:

   For N = 0 to 25				' increasing bar
      SerOut 0, T2400, ("?y3?x00")
      NN = 4 * N
      Num_5 = NN / 5
      LeftOver = NN % 5
      For J = 1 to Num_5
         SerOut 0, T2400, ("?5")
      Next
      LeftOver = LeftOver + 48		' convert to a character
      SerOut 0, T2400, ("?", LeftOver)
   Next

   For N = 0 to 25			' decreasing bar
      SerOut 0, T2400, ("?y3?x00?l")
      NN = 4 * N
      NN = 100 - NN
      Num_5 = NN / 5
      LeftOver = NN % 5
      For J = 1 to Num_5
         SerOut 0, T2400, ("?5")
      Next

      LeftOver = LeftOver + 48		' convert to a character
      SerOut 0, T2400, ("?", LeftOver)
   Next

   Return

PWMDemo:
    SerOut 0, T2400, ("?f")	' clear the LCD
    SerOut 0, T2400, ("  PWM Duty Demo?n")
    For N = 0 to 25
       Duty = 10 * N
       SerOut 0, T2400, ("?l")
       OByte = Duty
       GoSub SerOutByteHex	' display the PWM in hex

       SerOut 0, T2400, ("?B")	' backlight control
       GoSub SeroutByteHex
       Pause 200
    Next

    SerOut 0, T2400, ("?f")	' clear the LCD
    SerOut 0, T2400, ("?B00")	' set PWM to 0

    Return


SerOutByteHex:
    X = OByte / 16	' high nibble
    X = X + 48		' add the character '0'

    If X <= 57 Then SerOutByteHex_1
       X = X + 7	' it is alphabetic; A, B, C, D, E, F

SerOutByteHex_1:
    SerOut 0, T2400, (X)

    X = Obyte % 16	' low nibble
    X = X + 48		' add the character '0'

    If X <= 57 Then SerOutByteHex_2
       X = X + 7	' it is alphabetic; A, B, C, D, E, F

SerOutByteHex_2:
    SerOut 0, T2400, (X)

    Return

SerOutWordHex:

    OByte = OWord / 256
    GoSub SerOutByteHex
    OByte = OWord % 256
    GoSub SerOutByteHex

    Return


Big Number Capability.

' LCD118_2.BAS  (PICAXE-18X)
'
' Illustrates displaying quantities using the Big Number (3-wide) format.
'
' Continually calls a stub program which returns temperatures in the range
' of -99.9 to 999.9 and display on the LCD in the 3-wide big number format.
'
' Configured for 2400 baud, 8 bits, no parity.
'
' PICAXE-18X			                    LCD #118
'
' Pin0 (term 6) -----------------------------------> RX (term 7)
'
' Sets geometry of LCD as 4X20, sets backlight intensity to 40 hex and configures
' for no cursor.
'
' Note that PICAXE Editor 5.0.0 was used in this development.
'
' copyright, Peter H. Anderson, Baltimore, MD, Oct, '06


   Symbol T_10 = W0
   Symbol TWhole = B2
   Symbol TFract = B3
   Symbol Digit = B4
   Symbol N = B5

   Symbol BaudMode = T2400

   HIGH 0  ' this is the steady state for non-inverted
   PAUSE 1000  ' allow to stabilize

   SEROUT 0, BaudMode, ("?G420") ' configure LCD geometry
   PAUSE 200  ' pause to allow LCD EEPROM to program

   SEROUT 0, BaudMode, ("?B40") ' set backlight to 40 hex
   PAUSE 200    ' pause to allow LCD EEPROM to program

   SEROUT 0, BaudMode, ("?c0") ' clear the cursor
   PAUSE 200

   SEROUT 0, BaudMode, ("?f")  ' clear the LCD

'   SEROUT 0, BaudMode, ("?>3")  'note new line
'   PAUSE 200    ' allow time for the new special characters to be downloaded.

AGN:
   FOR N = 0 TO 6 ' for seven different temperatures
      SEROUT 0, BaudMode, ("?f") ' clear the LCD
      SEROUT 0, BaudMode, ("?>3")' big num 3 format
      PAUSE 200    ' allow time for the new special characters to be downloaded.

      GOSUB MEasTemp

      IF T_10 >= $8000 THEN  ' if its negative
         T_10 = -T_10
         TWhole = T_10 / 10  ' separate off whole and fractional parts
         TFract = T_10 // 10

         IF TWhole > 9 THEN ' -10 to -99
            SEROUT 0, BaudMode, ("-")
            Digit = TWhole / 10
            SEROUT 0, BaudMode, (#Digit)
            Digit = TWhole // 10
            SEROUT 0, BaudMode, (#Digit)
         ELSE         ' -0.0 to - 9.9
            SEROUT 0, BaudMode, ("?y0?x04")
            SEROUT 0, BaudMode, ("-")
            Digit = TWhole
            SEROUT 0, BaudMode, (#Digit)
         ENDIF

      ELSE    ' its positive
         TWhole = T_10 / 10
         TFract = T_10 // 10
         IF TWhole > 99 THEN   ' 100.0 - 999.0
            Digit = TWhole / 100
            SEROUT 0, BaudMode, (#Digit)
            TWhole = TWhole // 100
            Digit = TWhole / 10
            SEROUT 0, BaudMode, (#Digit)
            Digit = TWhole // 10
            SEROUT 0, BaudMode, (#Digit)
         ELSEIF TWhole > 9 THEN ' 10.0 to 99.0
            SEROUT 0, BaudMode, ("?y0?x02")
            Digit = TWhole / 10
            SEROUT 0, BaudMode, (#Digit)
            Digit = TWhole // 10
            SEROUT 0, BaudMode, (#Digit)
         ELSE
            SEROUT 0, BaudMode, ("?y0?x06")
            Digit = TWhole
            SEROUT 0, BaudMode, (#Digit)
         ENDIF
      ENDIF
      ' now the fractional part
      SEROUT 0, BaudMode, (".")

      SEROUT 0, BaudMode, (#TFract)

      SEROUT 0, BaudMode, ("?<")  ' Display "Deg F" in normal text
      SEROUT 0, BaudMode, ("?y1?x17")
      SEROUT 0, BaudMode, ("Deg")
      SEROUT 0, BaudMode, ("?y2?x17")
      SEROUT 0, BaudMode, (" F ")

      PAUSE 2500
   NEXT

   GOTO AGN

   MeasTemp:
   ' This is a stub which returns various values of a temerature T_10
   ' It is intended to illustrate examples from -99.9 to 999.0
      LOOKUP N, ($ff85, $ffd6, $fff8, 1234, 723, 72, 2), T_10 ' negative numbers are stored in 2's compliment
                '-123,  -42,   -8,    1234, 723, 72, 2
                ' -12.3 -4.2   -0.8   123.4, 72.3 7.2, 0.2
      RETURN