Digital temperature controller circuit and working
Fig. 2 shows circuit diagram of the digital temperature controller. The circuit is built around microcontroller PIC16F877A (IC1), precision thermocouple amplifier AD8495 (IC2), K-type thermocouple (connected at CON3), 16×2 LCD (LCD1), single-changeover relay (RL1) and a few common components.
Sensor selection. There are basically two types of temperature-measurement systems—direct temperature-measurement systems for up to 1000ºC and indirect temperature-measurement systems for higher temperature range, where temperature sensors may get physically damaged due to the high temperatures. The selection of temperature sensor is dependent on the range of temperature you wish to check. There are different types of direct-measurement sensors, for different ranges of temperature (refer Table I).
Microcontroller. The heart of the system is microcontroller PIC16F877A, which is a low-power, high-performance, CMOS 8-bit microcontroller. It includes 8kB Flash memory, 256-byte EEPROM, 368-byte RAM, 33 input/output (I/O) pins, 10-bit 8-channel analogue-to-digital converter (ADC), three timers, watchdog timer with its own on-chip crystal oscillator for reliable operation, and synchronous I2C interface.
Port pins RD0 through RD7 of IC1 are connected to pins D0 though D7 of the LCD. Port pins RB0 through RB2 are connected to register select RS, read/write R/W and enable EN of the LCD. ADC channel RA0 of the microcontroller receives the analogue signal from thermocouple amplifier IC2. Switches S2 through S4 are connected to port pins RC0 through RC2 of IC1. Switches S2 and S3 are used to set the minimum and maximum limits of temperature, respectively. Switch S4 closes to start the ADC function and display the actual temperature. Port pin RC3 controls the heating element. When port pin RC3 goes ‘high,’ transistor T1 drives into saturation and relay RL1 energises to turn on the heating element.
A 4MHz crystal is connected between pins 13 and 14 of microcontroller IC1 to provide the basic clock frequency. Power-on reset is provided by the combination of resistor R2 and capacitor C1. Switch S1 is used for manual reset. IC2 is a precision instrumentation amplifier with thermocouple cold-junction-compensation circuit. The input signal for IC2 (approximately 42µV/°C) is generated by thermal effects of the thermocouple. IC2 produces output (5mV/°C) directly from a thermocouple signal. With a 5V supply, the 5mV/°C output allows the device to cover nearly 1000 degrees of a thermocouple temperature range. Output of IC2 is connected to ADC input pin RA0 of microcontroller IC1.
Download PCB and component layout PDFs: click here
Download source code: click here
The program is written in ‘C’ language and compiled using Hi-Tech compiler along with MPLAB to generate hex code. The generated hex code is burnt into the microcontroller using a suitable programmer with configuration bit setting as shown in Fig. 4. The program is well commented and easy to understand.
Construction and testing
An actual-size, single-side PCB for the digital temperature controller is shown in Fig. 5 and its component layout in Fig. 6. Assemble the circuit on a PCB to save time and minimise assembly errors. Carefully assemble the components and double-check for any overlooked error. Use proper IC base for IC1. IC2 being an SMD chip, it needs to be soldered at the solder side of PCB. After assembling and wiring the circuit properly, connect 230V, 50Hz mains supply to primary winding of the transformer, and connect transformer secondary to the PCB at X1.