Home      Projects     Experiments     Circuits     Theory     BLOG     PIC Tutorials     Time for Science

20 February 2010
Author: Giorgos Lazaridis
PIC Thermometer and Thermostat

 IMPORTANTDANGER OF ELECTRIC SHOCK!Read this before taking any further action!!!Precautions to avoid electric shock

The circuit on a breadboard for bench test

The circuit is designed for a very specific operation: For the etching bath heater. I use this circuit for my homemade etching bath. A thermostat is a device that measures the temperature (in this case the temperature of the etching liquid), and according to a temperature window, will turn on or off the heater. This circuit has a fixed temperature window between 37 and 41oC. This can be changed of course very easy. I am preparing an etching bath and got an aquarium heater. Unfortunately, the heater's thermostat can be set up to 32oC. Higher temperatures are not proper for fish aquariums (unless you think of a fish soup). Therefore, i had to design my own thermostat.

The Circuit

This circuit has many things in common with another older circuit, the Low Cost PIC Thermometer. Actually, it uses the same technique to measure the temperature, not to mention that i use exactly the same NTC sensor (found in this experiment). The visualization of the temperature is done with 2 7-segment digits, instead of the LCD that i used with the previous circuit. So, this circuit can also be sued as a plain thermometer!

Additionally, i have add a relay. This relay will be actuated according to the temperature. If the temperature is above the bellow threshold, then the relay is actuated. The relay is released when the temperature goes above the high threshold. This is the schematic circuit:

The circuit uses it's own power supply, composed of a 2 diodes, 3 capacitors and the 7805. I use half wave rectification with the 1N4001 diodes. So, it can be powered directly from a 7 to 12V transformer. The PIC i have chosen is the 16F526. Why is that? Well, its a dead-cheap chip, with less than few capabilities, but surely enough for this application. My opinion is to always use the best PIC for the job. OK, i do not have the complete line up of Microchip, but i have more than 15 different PICs that i can choose from. This PIC was the closest to my "choosing" criteria for this application. And why is all this blah blah? This PIC has one great disadvantage: Low memory and tiny program counter. For those who understand of PIC programming, the memory page is just 256 bytes! So, if you want to change this program and/or expand it, then i strongly suggest you move to another PIC, otherwise you may get a headache.

The temperature sensor is a 10K NTC sensor, performing a voltage divider with a 10K Resistor. The output is shown in 2 7-seg digits, multiplexed with a NPN and a PNP transistor. With this technique, i save another (precious) line from the small 14-pin PIC. The schematic is for a HDK123 dual 7-seg display that i had chopped from an old TV, a VERY old TV - ITT brand.

The relay is driven with a 2N2222 switching transistor. An 1 AMP fuse in the high voltage part of the circuit will save you from troubles. If you plan to draw a schematic, you should consider thicker lines for this part of the circuit. I used the other part of the relay for LED indicator. Originally, the LED was connected to a PIC output, but it occupied a (precious) I/O pin.

The pin 13 (LPS1) is a free I/O with weak pull-up resistor in the pic, that can be used directly for a push-button, in case you decide to upgrade this circuit.

The thermistor is connected directly to the "THERM" connector of the circuit. As for the bus:

• a1 and a2 goes to pin RC0
• b1 and b2 goes to pin RC1
• c1 and c2 goes to pin RC2
• d1 and d2 goes to pin RC3
• e1 and e2 goes to pin RC4
• f1 and f2 goes to pin RC5
• g1 and g2 goes to pin RB4

Here is the complete project from the MPLAB for you to view/change and recompile:

 project.asm - The assembly listing

For compiling the above assembly sheet, you will need to have the P16F526 header file:

 The Microchip Standard Header File for PIC16F526

The two threshold points, LOW and HIGH can be changed from the two constants at the beginning of the program, with the names GLLowThreshold and GLHighThreshold. The current compiled binary has the temperature window between 38 and 42oC.

If the 38-42 window fits your needs (for FeCl3 etchant this is perfect), then you can directly upload the following binary file to a PIC

 project.hex - The binary file to upload directly to the PIC

Bill Of Materials
 Resistors R1 Resistor 330 Ohm 1/4 Watt 5% Carbon Film R2 Resistor 1.5 KOhm 1/4 Watt 5% Carbon Film R3-9 Resistor 150 Ohm 1/4 Watt 5% Carbon Film R10 Resistor 10 KOhm 1/4 Watt 1% Metal Film R11 Resistor 2.2 KOhm 1/4 Watt 5% Carbon Film Capacitors C1 0.1 uF ceramic capacitor C2 1 uF 25 Volts electrolytic capacitor C3 1000 uF 25 Volts electrolytic capacitor Diodes D1-3 1N4004 General Purpose Diode Rectifier Transistors T1 2N2222 Switching NPN Transistor T2 BC548 Switching and Applications NPN Epitaxial Transistor T3 BC327 Switching and Amplifier Applications PNP Epitaxial Silicon Transistor ICs IC1 PIC16F526 Microcontroller IC2 7805CV Positive Voltage Regulator

Relative pages
• High accuracy temperature meter
• A 2-speed PWM temperature fan controller
• High accuracy humidity and temperature sensor
• Low cost medium accuracy PIC temperature meter
• Experimenting with a thermistor
• The voltage divider theory
• Dr.Calculus: Voltage divider calculator