USB Thermostat

Home

About

Hardware

Data Transfer

Software

Downloads

Links

 

Hardware


PIC Microcontroller

The PIC18F252 by Microchip was chosen for its high versatility and low pin count. It has full hardware support for I2C in both slave and master modes. The USBI2CIO board only implements I2C master mode, and so the PIC must act as a slave to the USB board. But, the RTC and the temperature sensor both implement only I2C slave mode, and so the PIC must act as a master to those devices. Therefore, separate I2C buses had to be created for the USB board, and the peripheral chips. Then, the internal hardware handled the slave mode transactions, and software routines emulated an I2C master with other I/O pins to communicate with the peripheral chips.

The PIC microcontroller stores all of the temperature change entries as a table in its EEPROM memory, and keeps track of which is the current entry based upon the time it reads from the RTC.

Every five seconds, the RTC is accessed. Then, the current temperature change entry is calculated. And finally, the temperature sensor is updated with the new alarm temperature.

All of the PIC code was written in C, and compiled with Hi-Tech Software's PICC18 compiler.

Real-Time Clock

Dallas Semiconductor's DS1307 Real-Time Clock, in combination with the DS32KHZ Temperature-Compensated Crystal Oscillator, is accurate to ±1 Min/Yr. This allows the system to maintain a very accurate sense of time throughout operation. The devices also have internal circuitry which will automatically switch to battery-powered operation when Vcc drops below a threshold voltage. As such, the current time will still increment even while the USB Thermostat is unplugged.

Temperature Sensor

Texas Instruments' TMP101 is the temperature sensor chosen for the USB Thermostat. It has a resolution of up to 12-bits (.1125° F), and provides an ALERT pin which can be used to drive the relay directly. The PIC simply tells the sensor what the current temperature should be, and the TMP101 will automatically turn the relay on and off to maintain such a temperature.

PCB Design

Due to the use of mains voltage in this project, it was decided early on that a fully-enclosed solution was required to provide adequate safety. As such, a PCB board was designed to minimize size. Bob House of Georgia Tech milled the board in-house. A 6-pin expansion header is located to the right of the PIC18F252, and an I2C header is at the bottom-left of the PIC.

Final Design

The 12.6VCT transformer appearing in the top-left corner of the picture provides a stepped-down AC voltage to the custom PCB, which is then rectified and regulated to +5VDC. The solid-state relay is located at the top-right corner, and is rated at 230VAC at 10A. Our spaceheater runs off of 120VAC, but is also rated at 10A. Because of the lowered voltage, there should be no danger of burning out the relay, but using a higher current is not recommended. The thermostat PCB is located at the bottom, with the USB board located underneath, attached via stand-offs.

Back to Top