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 pins P3.1 through P3.3 of IC1 are connected to S2, S3 and S4 switches for ‘up,’ ‘down’ and ‘display’ respectively. These pins are pulled high through a 10-kilo-ohm resistor. Switches S1 through S3 are used for setting/changing the temperature. When the set temperature is exceeded, the relay connected to port pin 3.7 through a transistor is latched on. Switch S1 is used as a reset switch. Power-‘on’ reset is achieved by capacitor C3 and resistor R4.
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.
Fig. 2 shows the circuit of power supply. The AC mains is stepped down by transformer X1 to deliver a secondary output of 7.5V at 300 mA. The transformer output is rectified by a full-wave bridge rectifier comprising diodes D2 through D5, filtered by capacitor C1 and regulated by IC6. Capacitor C2 bypasses any ripple present in the regulated output. Regulated 5V is used for circuit operation and unregulated 6V is used for the relay.
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).
Can not download the source code . please check
Dear AjitKumar, the source code is present at the end of the article. Please click on the embed URL and the download will start automatically.
Hi, How can I help you?
I get Error 404 File Not Found error when I attempt to download the source code file for this project. Where can I download it?
Thank you for your comment. We have updated the article with the correct source code.
Please share c code for the above article. I have downloaded the code but its not code its just explanation. please share c code for above project.
waiting for your reply
This project was designed using BASIC program and not in C language, so we do not have C code.
Please share the contact details of the designer on my email id([email protected]) so that I can contact him for further discussion regarding this project.