Serial Temperature (DS18S20), Relay and A/D with Local LCD

TM Module #145

Peter H. Anderson
915 Holland Road, Bel Air, MD 21014
http://www.phanderson.com, pha@phanderson.com


Note. (June 24, '04). The original firmware provided an interface with only the Dallas DS18S20. On units shipped after June 24, '04, the firmware has been modified such that the unit may be interfaced with the DS18S20, DS18B20 and DS1822 or any combination of these on the same twisted pair run.

The TM #145 is now shipped with a single DS18B20. There is no compromise in perfromance over the older DS18S20.

If you purchased a TM #145 unit prior to this firmware change and need to add DS18B20 sensors, please contact me for an upgraded processor.

In the following discussion, the term DS1820 refers to DS18S20 / DS18B20 / DS1822.


Overview.

This is an assembled unit that is controlled by a PC COM port or similar (9600 baud, 8 data bits, no parity, no flow control) with a local 2 x 16 LCD.

The unit provides the capability of measuring the temperatures on each DS18S20 / DS18B20 / DS1822 on a single twisted pair. Up to sixteen DS1820 temperature sensors may be accommodated on the twisted pair. The maximum total cable length is 200 feet. This may be extended by using CAT3 or CAT5 cable.

The module provides a single form C relay (15A / 120 VAC, 10A / 240 VAC, 15 A / 24 VDC) with a three position screw type connector.

It also provides a single 10-bit analog to digital converter which may be configured for either 0 - 10 VDC or 0 - 5 VDC ranges.

A beeper is also provided. However, it is neither loud nor piercing.

An LED is provided which blips periodically to indicate the unit is alive and blips multiple times when a command is received from the PC.

The module includes a female DB9 connector, RS232 level shift circuitry, an on-board 5 VDC supply (78L05), a Microchip PIC processor and associated 20 MHz crystal and 2 X 16 LCD. All of this is fully assembled.

One DS18B20 temperature sensor is provided. Additional DS18B20s may be purchased separately.

The unit includes a coaxial power connector which will accommodate a 9 - 12VDC (2.1mm ID x 5.5mm OD female center positive) wall power unit and compatible 120 VAC wall power unit.

A DB9M to DB9F through serial cable is also included.

Connection to the Dallas DS1820 twisted pair run is facilitated using a two terminal connector (0.1 inch centers). Connection to the A/D uses a similar three terminal connector. A six terminal connector is provided to permit the processor to be manually reset.


Underside of the unit. This is a manufacturer photo and does not show the programmed PIC16F876-20/P processor Note relay (blue) and associated screw type connector with the two terminal interface to the DS1820 to its right. The three terminal connector is the interface with the A/D. The phono type connector has been replaced with a two terminal connector and was intended for frequecy measurements. This is not implemented in this design. The four terminal connector at the top provides +5 VDC, GRD and TTL serial Tx and Rx.


Pricing.

Guarantee

The intent in designing modules such as this is to involve my undergraduate students in meaningful design experiences, while at the same time providing useful low cost products for hobbyists and tinkerers.

In the spirit of this activity, I don't want people buying items that do not work for them or do not meat their expectations. Thus, this unit may be returned at any time for a full credit.

Detailed Description.

The unit continually cycles, beginning with a fast blip of the LED. The units checks the state of the on-board relay, performs an A/D conversion and a temperature measurement sequence and displays this on the local 2 x 16 LCD. The state of the relay ("ON" or "OFF") and the ten-bit A/D value are continually displayed on the left side of the display. The temperatures are displayed in a scrolling format on the right side as each measurement is performed. Each temperature measurement requires nominally one second. The cycle is completed with a nominal 2.5 second quiet period. Thus, the cycle is one second per temperature measurement plus 2.5 seconds. Note that all of this data is only displayed on the local LCD. It is not sent to a PC.

The temperature display consists of a single hexadecimal digit in the range of 0 - F which is assigned as each DS1820 is found followed by the temperature is degrees C with a resolution of 0.03 degrees. The unit may alternately be configured to display the temperature in degrees F. This is discussed below.

The A/D result is displayed in decimal fashion and is in the range of 0 - 1023.

The unit includes six pushbutton switches off which only two are used. The switch at the three and nine o'clock positions may be used to turn on or turn off the relay. This action occurs immediately.

At any time during the cycle, the PC may send a single command. The command is received, but is not acted on until the local measurement sequence is completed. Thus, if a unit is equipped with ten DS1820s and a command is received from the PC at the beginning of the cycle, the execution of the command will occur nominally ten seconds later when the measurement sequence is completed.

All commands consist of a single character followed by a newline. Operations are;

	N	' Turn on relay
	F 	' Turn off relay
	S	' Read relay status

	B	' beep five times

	A	' read A/D
	T	' read temperatures - degrees C
	t	' read temperatures - degrees F


On receipt of any command, the processor rapidly flashes the LED. If the command is not valid, the processor returns an error message.

All valid commands are echoed followed by a newline followed by the results of the command followed by a newline followed by a prompt ('>"). Commands may not be queued. Rather one at a time and the PC should wait for the prompt before issuing the next command.

Responses to the "relay oN and ofF commands;

N
1
>
F
0
>

The response to the "Status" command is to return the current state of the relay.

S
0
>
The response to the Beep command;
B
>

The beeper is not all that loud or piercing, but might be used to page or alert a person who is near the unit.

The response to the A/D command is a decimal number in the range of 0 - 1023.

A
780
>
With the 'T' command, the processor echoes the command followed by the temperature measurements.
	T
	0 27.55 10D6F33A 00000036
	1 26.67 10773B3B 000000CE
	2 -5.26  etc
	3 105.04 etc
Note that in 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 unique 64-bit serial number expressed in hexadecimal.

If no sensor is found on the designated run, the command is echoed, but no other data is returned. If a cyclic redundancy check error occurs in communicating with the temperature sensors, a temperature reading of -88.88 is returned and the measurement sequence is aborted.

Note that the response to a PC command is sent only to the PC and not to the LCD. However, once the PC command has been completed, the unit will begin another measurement cycle, displaying data to the LCD as discussed above.

All commands other than the 'T' command are case insensitive.

A lower case 't' will cause the temperature readings to be returned in degrees F. Subsequent displays to the LCD will also be in degrees F. An upper case 'T' similarly places the unit the degrees C mode. The degrees F or C mode is stored in EEPROM and if power is lost and restored, displays to the LCD will be in the format which was last specified by the PC

Notes.

Ordering Information. Please order as TM #145.