Simple Temperature Indicator Uses RISC-Based MCU

Sept. 1, 2003
A very simple temperature indicator can be built around an 8-bit RISC microcontroller (see the figure). Data from a temperature sensor is processed by the MCU and used to display the temperature. The...

A very simple temperature indicator can be built around an 8-bit RISC microcontroller (see the figure). Data from a temperature sensor is processed by the MCU and used to display the temperature. The MAX6577 temperature sensor used in the circuit can measure temperature over a range of −40°C to 125°C. It requires almost no other external components.

This sensor converts the temperature into a square wave with an output signal frequency that's proportional to absolute temperature (K). If this frequency is measured, it becomes fairly easy to compute the temperature. This can be achieved via various time-measuring circuits or a timer available in an MCU.

This circuit uses an AVR AT90S4433 low-cost MCU for processing the sensor data and displaying the temperature. Among other parts, this MCU has 4 kbytes of in-system programmable flash memory, 128 bytes of SRAM, 128 bytes of system-programmable EEPROM, a six-channel, 10-bit ADC, 20 programmable I/O lines, timers, and a UART.

Temperature is displayed on three common-anode, seven-segment displays. The respective segments of the displays are tied together, and multiplexing of the display data is handled with the help of software. This approach not only reduces the number of I/O interface lines, it also lowers the current requirement.

The displays are interfaced to Port D of the MCU. To display a temperature reading, the data is latched on this port and the respective display is made active. This is made possible with Timer 0, which is configured with a prescaling factor of 64. Whenever an overflow of the Timer 0 count occurs, an interrupt is generated. Timer 0's ISR latches the display data on Port D (i.e., on the display data bus) and generates the appropriate signal to enable the respective display unit (at Port B and through its respective transistor Q1, Q2, or Q3).

Temperature measurement is achieved by using Timer 1. Timer counts determine the input signal's pulse width. A sensorstatus() subroutine repeatedly checks the logic state of the sensor's signal. As soon as the first rising edge is detected, the timer, configured earlier in timer mode with prescaling factors of 1, is enabled. Then, at the first falling edge of the sensor's signal, the timer is disabled. Subsequently, the contents of the timer are read and used for computing the pulse width of the temperature sensor's signal. The timer is re-initialized to 0 after its contents have been read. Once the time period of the signal is known, the signal frequency can be easily computed (fOUT = 1/tOUT). After this, the data is checked for its limits.

Because the input signal is a square wave with 50% duty cycle, the total pulse period is 2 × width. So, the temperature is computed as CPU_FREQ/(2 × width). Then, 273.15 K is subtracted to obtain the temperature in degrees Celsius. Converting the pulse's time period to temperature has been made considerably simpler by implementing the AVR-GCC development environment, which can handle the floating-point data.

The range status and temperature information to be displayed is achieved by means of variable "r." Once the ISR of Timer 0 is active, the value of "r" is checked and the respective data is latched on Port D, depending upon the value of the DISPLAY_ON variable, which is also used to select the respective active seven-segment display unit. If the input data is within the range, the ISR calls a binarytobcd() subroutine that converts the binary data into a valid BCD format. The BCD data (nibble) is separated out depending on the active seven-segment display unit, which is again achieved in conjunction with the DISPLAY_ON value. Once the ISR completes its job, the Timer-0 gets re-initialized to a value (Refresh_Val) that will generate the next interrupt, subsequently displaying the next data without causing any flickering.

The software was written using the AVR-GCC development environment. This can handle all of the AVR MCU's functionality, including the various interrupts, EEPROM, timers, UART, ADC, and so forth. This software was used to compile the C source program and generate the HEX file. This file was downloaded to the MCU's in-system programmable flash using a parallel-port-based programmer (i.e., uisp).

The software can easily be modified to display the complete temperature range from −40°C to 125°C or display the data in degrees Fahrenheit. The same software can also be modified to read an input signal's frequency.

Sponsored Recommendations

Highly Integrated 20A Digital Power Module for High Current Applications

March 20, 2024
Renesas latest power module delivers the highest efficiency (up to 94% peak) and fast time-to-market solution in an extremely small footprint. The RRM12120 is ideal for space...

Empowering Innovation: Your Power Partner for Tomorrow's Challenges

March 20, 2024
Discover how innovation, quality, and reliability are embedded into every aspect of Renesas' power products.

Article: Meeting the challenges of power conversion in e-bikes

March 18, 2024
Managing electrical noise in a compact and lightweight vehicle is a perpetual obstacle

Power modules provide high-efficiency conversion between 400V and 800V systems for electric vehicles

March 18, 2024
Porsche, Hyundai and GMC all are converting 400 – 800V today in very different ways. Learn more about how power modules stack up to these discrete designs.

Comments

To join the conversation, and become an exclusive member of Electronic Design, create an account today!