Temperature logging

This article uses a pic16f88 development board to log time and air temperature to a computer via a serial link. It builds on the AD595 circuit (see html) and serial communication (see html) projects. The toolchain can be found here (html).

The main loop of the program is shown below:

int
main(void)
{
    setup();
    delay_ms(1000);

    while (1) {
        read_temp();
        transmit_data();
        delay_ms(200);
    }
}

After setting up the registers and IO pins, the main loop reads temperature and transmits data every 200ms. An interrupt routine was used to keep time using the 4MHz internal clock. The length of a second had an error of about 0.5%, or about 10s every 30mins.

Since data was transmitted every 200ms or so, multiple temperature values were recorded for each second. These were averaged during postprocessing.

CuteCom seemed to have trouble writing to a log file, so I wrote a python script that used the very nice pySerial library (html) to log the incoming data.

Results

The temperature of air was logged for 1000s (see Figure 1).

temperature data

Figure 1: Air temperature

Some of the logged data had to be slightly edited to be plotted. Corruption during transmission was suspected.

The value varied quickly over a very small range. Measuring the AD595 pins with a multimeter showed that the voltage was indeed fluctuating this quickly.

To validate the thermocouple, the temperature of ice (see Figure 2a) and boiling water (see Figure 2b) were measured. The temperature should be 0°C and 100°C respectively.

ice temperature
Figure 2a: Ice temperature
boiling water temperature
Figure 2b: Boiling water temperature

The measured temperature of ice had a variation of about +/-0.5°C and an offset of about +0.5°C. It should be noted that the thermocouple could not read negative temperatures in this configuration. The measured temperature of boiling water had a variation of about +/-1°C and an offset of about +1°C.

Conclusion

Time and temperature data was successfully logged by computer over a serial link. Some of the logged data had to be slightly edited, and corruption during transmission was suspected. Since the measured thermocouple voltage was sensitive to resistance, screw terminals are recommended to connect the thermocouple wires to the circit. It was suspected the small voltage offset was due to this contact resistance.

cc:by-nc-sa