Abstract: This application note describes a temperature monitor based on the MAXQ3212 microcontroller. This simple system compares the detected ambient temperature with a preset threshold and controls a relay to output the comparison result. The system also includes a 1-Wire digital thermometer and a 4-digit, 7-segment LED display driven by an 8-digit LED display driver. The use of a microcontroller and a highly integrated display driver can effectively reduce the number of external components.
This application note describes how to design such a control system or temperature monitor using a MAXQ microcontroller. Considering the functions of the MAXQ3212 and its simple design, low price, and the availability of a low-cost development environment, the MAXQ3210 evaluation kit (MAXQ3210-KIT), we chose this device as the system controller. The development environment used in this article is MAX-IDE version 1.0 and the MAXQ3210 simulation development kit version A.
The MAXQ3212 is used as the system controller. Two pushbutton switches are connected to the pins of the processor configured as input ports to implement the user interface function (setting up and down adjustment). Another microprocessor port is used as a signal output to control the relay action.
Figure 1. System Circuit Diagram
A 4-digit, 7-segment LED display is used as the system display to ensure that it provides effective display in various lighting environments without the need for an additional system backlight.
To simplify the interface design between the processor and the display and provide the necessary drive current and multiplexing switch, this system uses Maxim's 8-bit LED display driver ICM7218AIPI. This device contains all the circuits that directly connect to the microcontroller and the common anode LED display. The LED driver can drive up to 8 digits, but only 4 digits are used in this system. No external current limiting resistors are required to drive each segment of the 7-segment display.
The system output controls a standard electromechanical relay to switch the AC power to any load, which can be set according to the power supply requirements of the load. The system uses a relay that can switch 8A current and the coil voltage is exactly the 5V system supply voltage. Of course, the relay can operate under any conditions that do not exceed the rated voltage or current of the final drive FET (BS170).
Considering the feasibility of this system implementation, no accurate system simulation or optimization of the closed-loop performance of the system is required. A simple comparison of the actual temperature with the required temperature threshold is the only output switching rule. The software subroutine Relay_Switch can be modified to achieve the requirements of the actual system. A
simple DS18B20-PAR is used to measure the ambient temperature, which can provide a test accuracy of ±0.5°C in the temperature range of -10°C to +85°C. In this system, the required operating temperature range is +12°C to +38°C (+55°F to +100°F). The temperature test resolution of the chip is 9 to 12 bits, which can be selected by the user. For the resolution selection, please refer to the following content. In other applications, the unique 64-bit ID contained in each DS18B20 can support multiple DS18B20s connected to the 1-Wire network.
Although only one 1-Wire device is used in the system, the 1-Wire bus is designed to work with one master and multiple slaves, that is, multi-point operation. In this application, a DS18B20 is selected for temperature measurement. Maxim can also provide a variety of devices with similar functions. For example, when it is necessary to detect the temperature of multiple locations, the DS28EA00 can be used, which can simplify the physical location identification of 1-Wire devices in the 1-Wire network.
In temperature monitoring applications, bit-by-bit control is performed through a single port line to achieve communication on the 1-Wire bus. The software that implements this function can be found in application note 3769, "Building a 1-Wire Temperature Recorder Using the MAXQ3210." This software is written specifically for the MAXQ3210 and DS1822 Econo 1-Wire digital thermometer. In this application, only the 9-bit resolution in the original software needs to be changed to 10 bits. Application Note 3769 also provides a reference design for 1-Wire and its application.
The default debug functions of these 5 pins can be disabled by setting the control bits TAP and RSTD to the appropriate levels (0 and 1, respectively), and they can be used as normal pins and no longer used for debug functions. In this design, the final debug application is the display part, because they require a large number of I/O pins, but the functions are relatively simple and only require a small amount of debugging work.
The assembler inserts a long time delay (about 5 seconds) before the instruction disables the five debug control signals. This delay allows the debug board to still have control of the processor before disabling debug control. Thus, the debug board can control the device when necessary.
In this application, no multiplexer is used, and a 4-bit, 7-segment LED is required. Not including the decimal point, a total of 28 independent signal lines (4 bits x 7 segments) are required. Obviously, the MAXQ3212 cannot provide so many port signals without other circuitry. Therefore, we chose the ICM7218 to solve this problem. Its internal multiplexer can provide up to 8-bit display, and it can directly drive the LED display without additional current limiting resistors. It can be connected to the processor simply through 8-bit signals and 2-way control (mode, write operation).
When the key is detected, the LED displays the current set point. To help indicate that the temperature threshold is being displayed, the microcontroller turns on the last decimal point (which is normally off). If the key is held down long enough, the temperature will increase or decrease by approximately 0.5°F per second. When the desired temperature is reached, the user can release the key, and the new temperature threshold is immediately established. The display then returns to the ambient temperature value with the last decimal point off.
Temperature high significant bit
Temperature LSB
The resolution of this temperature sensor can be configured by the user to 9, 10, 11, or 12 bits, corresponding to temperature resolutions of 0.5°C, 0.25°C, 0.125°C, and 0.0625°C. The default resolution of the DS18B20 when powered on is 12 bits, which is initialized to 10 bits in this application. At this time, the first and 0 bits (2-3, 2-4) are meaningless, and the minimum temperature value that can be distinguished is 0.25°C.
In this application, the temperature is displayed in Fahrenheit. The following equation is used for conversion:
Fahrenheit = (Celsius × 1.8) + 32 (Equation 1)
Because the temperature is expressed in decimal form and needs to be multiplied by 1.8 when converting, the calculation is performed in binary. When performing real number multiplication, it is necessary to minimize the calculation error without wasting processor resources. When the DS18B20 is initialized, the resolution of the temperature value is set to 10 bits, so the first and 0 bits are meaningless. The remaining 2 bits (bits 3 and 2) of the fractional temperature provide a resolution of 0.25°C (0.45°F). Because the MAXQ3212 accumulator has a byte width of 8 bits, it is convenient to use one byte for the fractional temperature, and the multiplier can contain 6 bits of fractional information. As can be seen below, 99.61% of the range of 0.8 to 0.8 can be approximated with 6 bits of fractional information.
2-1 = 0.500000 => 62.50% of 0.8
2-2 = 0.250000 + 0.50000 = 0.750000 => 93.7% of
0.8 2-5 = 0.031250 + 0.0750000 = 0.781250 => 97.65% of 0.8
2-6 = 0.015625 + 0.781250 = 0.796875 => 99.61% of 0.8
Converting Fahrenheit data with this precision is sufficient to meet the accuracy requirements of this temperature sensor.
As an example, we can calculate the measured temperature +24.2510, (018.116) degrees Celsius, which can be expressed as:
Temperature High Significant Bit
Temperature LSB
Expressed another way, the value above can be expressed as 00000001 1000.01xx2, which is multiplied by 1.810. Converting 1.810 to binary, using 6 bits to represent the decimal, converts the result to the constant 0001.1100112. The conversion is as follows:
0000s0 011000.012 = 006116
× 00000000 01.1100112 = 007316
-----------------------
00101011 .100100112 = 2B9316
+ 00100000 .000000002 = 32.010
-----------------------
01001011 .100100112 = 4B9316 = 75.57421910
As you can see, 75.574219 is an accurate result. If you remove two decimal places from this result, you get 75.5°F, which is within the 0.15°F accuracy of a floating point calculator. This is more than accurate enough for this application.
Keywords:MAXQ3212
Reference address:Designing a Digital Temperature Monitor Using the MAXQ3212 Microcontroller
introduction
Many applications require temperature regulation or control, for example, using a light bulb to raise the temperature of a small enclosed space when the ambient temperature is too low or to dry wet paint or similar items. In most cases, a closed-loop temperature control system can be formed by using temperature sensing, power switches, and a heating source.This application note describes how to design such a control system or temperature monitor using a MAXQ microcontroller. Considering the functions of the MAXQ3212 and its simple design, low price, and the availability of a low-cost development environment, the MAXQ3210 evaluation kit (MAXQ3210-KIT), we chose this device as the system controller. The development environment used in this article is MAX-IDE version 1.0 and the MAXQ3210 simulation development kit version A.
System Design Detailed Description
Overview
The implementation of this digital temperature monitoring system is very simple. Figure 1 is the circuit diagram of the system. The DS18B20 1-Wire® digital temperature sensor is used to detect the ambient temperature. The system compares this temperature with the temperature threshold set by the user. If the temperature is lower than the threshold set by the user, the relay will generate a control signal. Normally, the system indicates the ambient temperature through a 4-digit LED display. When the user sets the temperature, the LED is used to display the user's setting value.The MAXQ3212 is used as the system controller. Two pushbutton switches are connected to the pins of the processor configured as input ports to implement the user interface function (setting up and down adjustment). Another microprocessor port is used as a signal output to control the relay action.
Figure 1. System Circuit Diagram
A 4-digit, 7-segment LED display is used as the system display to ensure that it provides effective display in various lighting environments without the need for an additional system backlight.
To simplify the interface design between the processor and the display and provide the necessary drive current and multiplexing switch, this system uses Maxim's 8-bit LED display driver ICM7218AIPI. This device contains all the circuits that directly connect to the microcontroller and the common anode LED display. The LED driver can drive up to 8 digits, but only 4 digits are used in this system. No external current limiting resistors are required to drive each segment of the 7-segment display.
The system output controls a standard electromechanical relay to switch the AC power to any load, which can be set according to the power supply requirements of the load. The system uses a relay that can switch 8A current and the coil voltage is exactly the 5V system supply voltage. Of course, the relay can operate under any conditions that do not exceed the rated voltage or current of the final drive FET (BS170).
Considering the feasibility of this system implementation, no accurate system simulation or optimization of the closed-loop performance of the system is required. A simple comparison of the actual temperature with the required temperature threshold is the only output switching rule. The software subroutine Relay_Switch can be modified to achieve the requirements of the actual system. A
simple DS18B20-PAR is used to measure the ambient temperature, which can provide a test accuracy of ±0.5°C in the temperature range of -10°C to +85°C. In this system, the required operating temperature range is +12°C to +38°C (+55°F to +100°F). The temperature test resolution of the chip is 9 to 12 bits, which can be selected by the user. For the resolution selection, please refer to the following content. In other applications, the unique 64-bit ID contained in each DS18B20 can support multiple DS18B20s connected to the 1-Wire network.
1-Wire Interface
Maxim's 1-Wire bus uses a unique serial communication interface that requires only one signal line and ground line for communication. This interface can communicate with 1-Wire devices through a pin of the microcontroller. The interface also has a power supply function, called parasitic power, which can work without local power supply of the 1-Wire device using the 1-Wire signal line. In this system design, the interface design is not important, but the remote temperature measurement is the key.Although only one 1-Wire device is used in the system, the 1-Wire bus is designed to work with one master and multiple slaves, that is, multi-point operation. In this application, a DS18B20 is selected for temperature measurement. Maxim can also provide a variety of devices with similar functions. For example, when it is necessary to detect the temperature of multiple locations, the DS28EA00 can be used, which can simplify the physical location identification of 1-Wire devices in the 1-Wire network.
In temperature monitoring applications, bit-by-bit control is performed through a single port line to achieve communication on the 1-Wire bus. The software that implements this function can be found in application note 3769, "Building a 1-Wire Temperature Recorder Using the MAXQ3210." This software is written specifically for the MAXQ3210 and DS1822 Econo 1-Wire digital thermometer. In this application, only the 9-bit resolution in the original software needs to be changed to 10 bits. Application Note 3769 also provides a reference design for 1-Wire and its application.
MAXQ3212 I/O Pinouts
The MAXQ3212 has 15 port pins available: 8 on port 0 and 7 on port 1. A minimum of 10 signal lines (pins) are required to communicate with the ICM7218 display driver, and 4 pins are used for the temperature setting up and down, relay driving, and communication with the DS18B20, which takes up a total of 14 pins. By default, 4 of the MAXQ3212's 15 pins are used for the JTAG interface (P1.0, P1.2, P1.3, P1.4), and 1 is used as a reset input (P1.1). Although these 5 signals control debug functions, they are also used for other functions. Special considerations are required throughout the debugging process.The default debug functions of these 5 pins can be disabled by setting the control bits TAP and RSTD to the appropriate levels (0 and 1, respectively), and they can be used as normal pins and no longer used for debug functions. In this design, the final debug application is the display part, because they require a large number of I/O pins, but the functions are relatively simple and only require a small amount of debugging work.
The assembler inserts a long time delay (about 5 seconds) before the instruction disables the five debug control signals. This delay allows the debug board to still have control of the processor before disabling debug control. Thus, the debug board can control the device when necessary.
Monitor Selection
The main considerations for selecting a display are whether the temperature monitor is used indoors or outdoors, and the brightness of the light. The goal is to be able to see the LED display clearly under all lighting conditions except for strong light conditions (such as outdoor direct sunlight). Simple colored lights are usually sufficient to provide the necessary display contrast and visibility. LED displays do not require additional circuitry, such as backlight circuitry.In this application, no multiplexer is used, and a 4-bit, 7-segment LED is required. Not including the decimal point, a total of 28 independent signal lines (4 bits x 7 segments) are required. Obviously, the MAXQ3212 cannot provide so many port signals without other circuitry. Therefore, we chose the ICM7218 to solve this problem. Its internal multiplexer can provide up to 8-bit display, and it can directly drive the LED display without additional current limiting resistors. It can be connected to the processor simply through 8-bit signals and 2-way control (mode, write operation).
User input threshold setting
Given the port resources of the MAXQ3212, it is not possible to provide a parallel interface for user input of temperature thresholds. Therefore, a simple up and down adjustment key is used to increase or decrease the temperature threshold. When the system is initially powered on, the software sets the temperature to a default value of +72.5°F and stores this value in the MAXQ3212 EEPROM. If the user increases or decreases the temperature set point, the new temperature value is stored in this EEPROM. Since the EEPROM is nonvolatile, the data is not lost even if the power is lost.When the key is detected, the LED displays the current set point. To help indicate that the temperature threshold is being displayed, the microcontroller turns on the last decimal point (which is normally off). If the key is held down long enough, the temperature will increase or decrease by approximately 0.5°F per second. When the desired temperature is reached, the user can release the key, and the new temperature threshold is immediately established. The display then returns to the ambient temperature value with the last decimal point off.
Temperature Conversion
In this application, the temperature is converted from Celsius to Fahrenheit using software. Execute the "Temperature Conversion" command of the DS18B20, and the 16-bit (with sign bit) result is stored in the temperature sensor register in the following way.Temperature high significant bit
Bit 15 | Bit 14 | Bit 13 | Bit 12 | Bit 11 | Bit 10 | Bit 9 | Bit 8 |
Sign | Sign | Sign | Sign | Sign | 26 | 25 | twenty four |
Temperature LSB
Bit 7 | Bit 6 | Bit 5 | Bit 4 | Bit 3 | Bit 2 | Bit 1 | Bit 0 |
twenty three | twenty two | twenty one | 20 | 2-1 | 2-2 | 2-3 | 2-4 |
The resolution of this temperature sensor can be configured by the user to 9, 10, 11, or 12 bits, corresponding to temperature resolutions of 0.5°C, 0.25°C, 0.125°C, and 0.0625°C. The default resolution of the DS18B20 when powered on is 12 bits, which is initialized to 10 bits in this application. At this time, the first and 0 bits (2-3, 2-4) are meaningless, and the minimum temperature value that can be distinguished is 0.25°C.
In this application, the temperature is displayed in Fahrenheit. The following equation is used for conversion:
Fahrenheit = (Celsius × 1.8) + 32 (Equation 1)
Because the temperature is expressed in decimal form and needs to be multiplied by 1.8 when converting, the calculation is performed in binary. When performing real number multiplication, it is necessary to minimize the calculation error without wasting processor resources. When the DS18B20 is initialized, the resolution of the temperature value is set to 10 bits, so the first and 0 bits are meaningless. The remaining 2 bits (bits 3 and 2) of the fractional temperature provide a resolution of 0.25°C (0.45°F). Because the MAXQ3212 accumulator has a byte width of 8 bits, it is convenient to use one byte for the fractional temperature, and the multiplier can contain 6 bits of fractional information. As can be seen below, 99.61% of the range of 0.8 to 0.8 can be approximated with 6 bits of fractional information.
2-1 = 0.500000 => 62.50% of 0.8
2-2 = 0.250000 + 0.50000 = 0.750000 => 93.7% of
0.8 2-5 = 0.031250 + 0.0750000 = 0.781250 => 97.65% of 0.8
2-6 = 0.015625 + 0.781250 = 0.796875 => 99.61% of 0.8
Converting Fahrenheit data with this precision is sufficient to meet the accuracy requirements of this temperature sensor.
As an example, we can calculate the measured temperature +24.2510, (018.116) degrees Celsius, which can be expressed as:
Temperature High Significant Bit
Bit 15 | Bit 14 | Bit 13 | Bit 12 | Bit 11 | Bit 10 | Bit 9 | Bit 8 |
0 (sign) | 0 (sign) | 0 (sign) | 0 (sign) | 0 (sign) | 0 | 0 | 1 |
Temperature LSB
Bit 7 | Bit 6 | Bit 5 | Bit 4 | Bit 3 | Bit 2 | Bit 1 | Bit 0 |
1 | 0 | 0 | 0 | 0 | 1 | x | x |
Expressed another way, the value above can be expressed as 00000001 1000.01xx2, which is multiplied by 1.810. Converting 1.810 to binary, using 6 bits to represent the decimal, converts the result to the constant 0001.1100112. The conversion is as follows:
0000s0 011000.012 = 006116
× 00000000 01.1100112 = 007316
-----------------------
00101011 .100100112 = 2B9316
+ 00100000 .000000002 = 32.010
-----------------------
01001011 .100100112 = 4B9316 = 75.57421910
As you can see, 75.574219 is an accurate result. If you remove two decimal places from this result, you get 75.5°F, which is within the 0.15°F accuracy of a floating point calculator. This is more than accurate enough for this application.
Dual FET coil drive
This application uses two field-effect transistors (FETs) connected to the processor's output port to control the relay switch. The MAXQ3212 port's reset default state is a weak pull-up, high level. Therefore, its port pin is high at power-up until the application software changes its state. If an n-channel FET (BS-170) is used to control the power supply to the relay coil, the default state of this port will trigger the relay when the processor is powered up. Until the application software resets it to 0. This state is undesirable because the relay is mistakenly triggered, resulting in an unwanted action. To solve this problem, the circuit uses two FETs in series to control the relay action together, and the default state after the processor is powered up will not trigger the relay.Routines
The software accompanying this application can be downloaded from: Download (ZIP) and contains the source code files: Thermostat.asm, 1-Wire.asm, BCD.asm, ThermDisp.asm, and the header file maxq3120.inc, which contains the register definitions for the MAXQ3210/MAXQ3212. The zip file also contains the MAX-IDE project file Thermostat.prj and the loadable hex file Thermostat.hex. Unzip these zip files to a directory to compile and run the MAXQ3210 EV kit software. On September 12, 2007, another file (Temp3Gerber.zip) was added to the an3965_sw.zip program file. The added files include the Gerber data, training data, and a parts list for a two-layer printed circuit board to implement this design.in conclusion
The MAXQ3212 is a versatile, high-performance RISC processor that is small, low-cost, and provides powerful functional support, making it particularly suitable for mass-produced applications. This application note introduces a digital temperature controller based on the MAXQ3212 RISC microcontroller. The detected ambient temperature is compared with the user-set temperature threshold by the MAXQ3212 for relay control. The ambient temperature is detected using a DS18B20 1-Wire temperature sensor and displayed on a 4-digit, 7-segment LED display driven by Maxim's 8-pin LED display driver ICM7218. The selected microcontroller and highly integrated display driver greatly reduce the number of components in the system.
Previous article:Building a Remote Key Based on the MAXQ3212
Next article:Implementing a JTAG Loading Master for the MAXQ2000 Microcontroller
Recommended Content
Latest Analog Electronics Articles
- High signal-to-noise ratio MEMS microphone drives artificial intelligence interaction
- Advantages of using a differential-to-single-ended RF amplifier in a transmit signal chain design
- ON Semiconductor CEO Appears at Munich Electronica Show and Launches Treo Platform
- ON Semiconductor Launches Industry-Leading Analog and Mixed-Signal Platform
- Analog Devices ADAQ7767-1 μModule DAQ Solution for Rapid Development of Precision Data Acquisition Systems Now Available at Mouser
- Domestic high-precision, high-speed ADC chips are on the rise
- Microcontrollers that combine Hi-Fi, intelligence and USB multi-channel features – ushering in a new era of digital audio
- Using capacitive PGA, Naxin Micro launches high-precision multi-channel 24/16-bit Δ-Σ ADC
- Fully Differential Amplifier Provides High Voltage, Low Noise Signals for Precision Data Acquisition Signal Chain
MoreSelected Circuit Diagrams
MorePopular Articles
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
MoreDaily News
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
Guess you like
- Understanding the Rail-to-Rail Characteristics of Op Amps
- Married electricians, do you give your salary to your wife or manage it yourself?
- Ek314 How to upgrade Ubuntu 12.04 to 14.04?
- Does anyone know how to open a .brd file with AD?
- Say goodbye to quartz? One of the main characters in next week's TI live broadcast, CC2652RB, is a wireless MCU that does not require an external crystal oscillator
- How to calculate the input impedance of this full-bridge rectifier?
- Design of receiving circuit for radio remote control transmitter
- 【Portable Environmental Status Detector】Use of GPIO port
- How to Layout a Circuit Board for an Op Amp
- Research on Charging Method of Lead-acid Battery