Introduction
There are varieties of digital temperature logger projects available online based on different microcontrollers. The one I am going to talk about is based on a Microchip's 8-pin microcontroller, PIC12F683. It reads temperature values from a DS1820 digital sensor and stores in its internal EEPROM. PIC12F683 has 256 bytes of internal EEPROM and we are going to store the temperature values in 8-bit format. This means only the eight most significant bits of temperature data from DS1820 will be read and as such the temperature resolution will be of 1 degree C.- Reads temperature from a DS1820 sensor and stores in the internal EEPROM locations.
- Can store up to 254 temperature values. EEPROM location 0 is used to store the sampling interval, and location 1 is used to store the number of records.
- Three sampling interval options: 1 sec, 1 min, and 10 min. This can be selected during powering up.
- Start and Stop buttons for control operations.
- The recorded temperature values can be sent to PC through a serial port. A separate Send button is available to initiate data transfer.
- A LED to indicate various ongoing operations.
- Reset button to clear all previous records.
PIC12F683 has 6 I/O pins, out of which one (GP3, pin 4) is I/P only pin. Here is how we are going to assign the port pins.
The six I/O pins of PIC12F683 are assigned as follows:
1. GP0 (Pin 7, I/P): This pin will be used to read the temperature value from DS1820 sensor.
2. GP1 (Pin 6, O/P): This will be used for serial data transfer to a PC.
3. GP2 (Pin 5, O/P): LED output pin.
4. GP3 (Pin 4, I/P): Send (tactile switch)
5. GP4 (Pin 3, I/P): Stop (tactile switch)
6. GP5 (Pin 2, I/P): Start (tactile switch)
A simple transistor based level shifting will be used to convert the TTL voltage from PIC12F683 to appropriate RS232 level for serial data transfer to PC. The required negative voltage is derived from PC RS232 port pin 3 (Tx), which remains idle as no data transfer occurs from PC to PIC. I soldered all the components on a general-purpose prototyping board. Besides, my finished product runs on 3-AAA batteries with a diode in series for reverse polarity protection. I also have a power switch on the board. The PIC uses internal oscillator at 4MHz, and MCLR is disabled.
List of Components
PIC12F683 microcontroller
DS1820 temperature sensor
BC557 NPN transistor
Resistors: 10K (4), 4.7K (2), 470 Ohm (1)
Capacitor: 10uF, 50V (1)
LED (1)
Tact switches (3)
Software
The firmware is written in C and compiled with mikroC compiler from MikroElektronika. I used the free version of it because our HEX output is going to be less than 2K. The download link for mikroC ishttp://www.mikroe.com/eng/downloads/get/29/mikroc_pro_pic_2010_v380_setup.zip
The 3 user input switches work on interrupt-on-change mode. That means any time the user presses any button, an interrupt is generated except at times when the microcontroller is reading temperature values from DS1820 (which is instantaneous) and when it is transferring data to a PC through serial port. The interrupts are disabled at those instants. The data transfer takes place at 9600 baud rate. You can write your own software to receive data on PC side, but I have used the Hyperterminal application for this purpose. My Hyperterminal settings are
bps : 9600, Data Bits: 8, Parity : None, Stop Bits : 1, Flow Control : Hardware
Configuration: Internal clock @ 4 MHz, MCLR Disabled, WDT OFF
Program Sequence
The firmware inside the PIC does the following sequence of operations.
- Power ON.
- Blinks the LED for 3 times.
- Check any key pressed. If yes, identify the key and store the appropriate sampling interval to EEPROM location 0. After it identifies the pressed key, the LED will glow up, and you need to release the key. Once the key is released, the selected sampling interval is stored in the EEPROM. Every time when a EEPROM location is written, the LED blinks for 3 times.
- Read EEPROM location 0, and get Sampling Time. Now the program is inside the main loop. The three switches (Start, Stop, and Send) connected to GPIO 5, 4, and 3 work in Interrupt-on-Change mode. That means, when any of these buttons is pressed, an interrupt will be generated, and served accordingly. Start will start the logging of temperature values. Stop will interrupt the logging process, and Send will transfer data to serial port. If the Send is pressed for more than 2 sec, the EEPROM memory will be cleared.
Pictures
Finished Board
Serial connection to PC
Data Logger is clear (Default sampling time = 1 sec after reset)
LED blinks during data transfer
Various sampling time select and recorded values
I have posted this project on Electronics-Lab website. The complete project including firmware is downloadable from there. Here is the link.
No comments:
Post a Comment