SPI input for the generic heating / cooling controller

The generic heating / cooling controller (hcctl) is a flexible bang-bang thermostat controller based on an ATTiny25.

The project has been expanded to accept a simple SPI temperature sensor. The test case uses a MAX31855 Cold-Junction Compensated Thermocouple-to-Digital Converter for K type thermocouples. The MAX31855 is around US$5 at Digikey for singles, but the tests were conducted using Adafruit MAX31855.

MAX31855

Thermocouples bring two challenges for hcctl:

  • low noise amplification of very low sensor voltage;
  • compensation of the ‘cold junction’ temperature; and
  • high resolution ADC.

The MAX31855 provides a solution to all of these challenges in a single inexpensive chip.

Implementation

There were insufficient pins on the ATTiny25 (8 pin DIP), so the code was adapted to run also in an ATTiny24 (14 pin DIP). This meant some significant code change to accommodate different functions on different ports and pins. In the process, the 2.56V reference option that was in prior versions of code has been dropped for simplicity as it doesn’t get used and is not supported on the ATTinyx4 series.

hcctl-SPI01

Above is capture of the SPI burst for one temperature measurement. Total transfer time is just less than 200µs, clock time is 6µs, quite reasonable for a MCU running on a 1MHz internal RC clock.

Screenshot - 13_05_2015 , 17_49_05

The concept of hcctl is flexible common code based with application constants stored in EEPROM. Above is a screenshot of the EEPROM structure for the enhanced code.

Temperatures ton, dif, and tal are specified in 1/4 degree increments, left shifted two bits, so effectively temperature*16 with resolution of 0.25°. The values read by SPI are anded with msk to mask off bits 0 and 1 which are not used for temperature with the MAX31855.

Test run

A test was conducted with the hcctl chip directly driving a SSR controlling a 1200W immersion heater in a 1l pot of water. The test frame consists of a thermocouple, the MAX31855 module, a single chip (ATTiny24 with hcctl), power supply bypass capacitor, 5V supply and SSR. The thermocouple is an inexpensive (A$2) naked Type K thermocouple which has very low thermal inertia and responds to temperature changes very quickly.

Clip 130At 400s, 10s after the heater had turned off, 50ml of 20° water was added to the pot to test response. The heater turned on, and as expected there was a little overshoot, rising to 53.4°. The pot cooled naturally, and the next heat phase added less than 2° before turning off.