Single-wire mode. The DS1821 is supplied by the manufacturer in single-wire mode (=0). In this mode, the DQ pin of the DS1821 is configured as a single-wire port for communication with a control unit (microcontroller) using the protocols described in the single-wire bus system section of the datasheet. These communications can include reading and writing the high and low thermostat trip-point registers (TH and TL) and the configuration register, and reading the temperature, counter and slope accumulator registers. Also in this mode, the microcontroller can initiate and stop temperature measurements as described in the operation-measuring temperature section of the datasheet.
The TH and TL registers and certain bits (THF, TLF, , POL and 1SHOT) in the status/configuration register are stored in the non-volatile EEPROM memory, so these will retain data when the device is powered down. This allows the registers to be pre-programmed when the DS1821 is to be used as standalone thermostat.
Writing to these non-volatile registers can take up to 10 ms. To avoid data corruption, no write action to the nonvolatile memory should be initiated while a write to the non-volatile memory is in progress. Non-volatile write status can be monitored by reading the NVB bit in the status/configuration register: If NVB=1, a write to EEPROM memory is in progress. If NVB=0, the non-volatile memory is in idle state.
Fig. 1 shows the circuit of the temperature controller using Dallas DS1821 temperature sensor. Microcontroller AT89S8252 is interfaced to DS1821 temperature sensor, three 7-segment displays and relay RL1. Port P1 of IC1 is used to output the data on the segment display. Port pins P1.0 through P1.3 and port pins P1.4 through P1.7 are connected to IC3 and IC2, respectively. ICs CD4511 (IC3 and IC2) receive the BCD data and provide the compatible code for 7-segment displays DIS2 and DIS3.
Port pins P3.4 and P3.5 are used for ‘b,’ ‘c’ and ‘g’ segments of DIS4 through buffers N1, N2 and N3, respectively. Segments ‘b’ and ‘c’ become active when temperature exceeds 99°C. Segment ‘g’ becomes active when temperature goes below 0°C. This indicates ‘–’ sign for negative temperature. DIS1 is used in reverse direction for indication of °C. Segments ‘a,’ ‘b,’ ‘g’ and ‘dp’ (decimal point) are made permanently high with resistors R19 through R22 to indicate °C.
Port pin P3.0 of IC1 receives the data from temperature sensor DS1821. Pin 17 (P3.7) of IC1 is connected to the base of transistor T1 through buffer N4. The signal from port pin P3.7 drives relay RL1. Diode D1 is used as a free-wheeling diode and LED2 is used for relay-‘on’ indication. The device is connected through contacts of RL1. Resistors R5 through R22 and R26 through R28 limit the current through the 7-segment display. A 12MHz crystal is used for microcontroller clock.
An actual-size, single-side PCB for temperature controller (Fig. 1) including its power supply (Fig. 2) is shown in Fig. 3 (View as PDF) and its component layout in Fig. 4 (View as PDF).