The software for the temperature controller is compiled using Bascom51 version. The demo version of Bascom-8051 is available on MCS Electronics.
First, define the crystal speed and include the header file for microcontroller. Initialise all ports to ‘0.’ Timer-0 is used as an internal counter and increments by a second. This is used here for timing delays. Pin P3.0 of the microcontroller is configured for single-wire communication. Normally, DQ pin (single-wire bus) of DS1821 is high. Through DQ, the device gets its power to perform tasks.
When the microcontroller waits for the event through single-wire bus, it issues a reset command. Then DQ goes low for some time. This resets the device and it acknowledges a pulse and then follows the microcontroller. The communication on the single-wire bus is initiated by the microcontroller, and issued by low time slots on a normally-high DQ line, issued by the device.
Declare the variables as bits, bytes and words. Define the various port pins as per the connections. Set the maximum temperature to ‘40’ as default. Subroutines ‘dispset’ and ‘disptemp’ are used for display preset and real temperature, respectively. The source program is well commented for easy understanding.
Download PCB and component layout PDFs: click here
Download Source code: click here