1. Overall plan of the system
The MSP430 microcontroller MCU (Micro Controller Unit) is an ultra-low power 16-bit mixed signal processor launched by TI with rich on-chip peripherals and powerful functions. It includes a series of devices that can be used in different occasions. A significant difference between MSP430 and MCS-51 is that it integrates an analog-to-digital conversion (ADC) module on the chip, making A/D conversion easy to implement. Among them, the 13x, 14x, 43x, and 44x series devices of MSP430 all have built-in temperature sensors. Its output is sent to channel 10 of the ADC12 module, and then it is A/D converted, and then the temperature inside the chip can be measured. In this alarm system, the output of this temperature sensor is used to realize real-time temperature alarm.
Figure 1 Schematic diagram of temperature alarm system based on MSP430F449 embedded temperature sensor
The basic scheme of this system is as follows: Channel 10 of the ADC12 module measures the temperature of the chip. When the measured temperature is higher or lower than the preset alarm value, the LED is driven through the output of the I/O port to display the alarm status. The chip is in low power mode during the whole process. The principle of this system is relatively simple, and Figure 1 shows its simple schematic diagram.
2. Temperature measurement principle and process
of temperature sensor The temperature sensor embedded in MSP430 is actually a temperature diode whose output voltage changes with the ambient temperature. Table 1 shows some of its basic electrical characteristics. According to the information provided by TI, the output voltage of this temperature diode and the corresponding temperature are approximately in a simple linear relationship. The measured temperature can be calculated by formula (1):
(1) |
Where, T: measured temperature, unit: °C;
V
ST
: voltage measured by channel 10 of the ADC module, unit: mV;
V
0℃
: output voltage of the sensor at 0℃, unit: mV;
TC
SENSOR
: sensor voltage, i.e. the change of output voltage with temperature, unit: mV/℃. It is numerically equal to the increase of output voltage for every 1℃ increase of temperature.
For a 12-bit ADC module, VST can be obtained using the following A/D conversion formula:
(2) |
Among them, ADC12
CH10
: 12-bit A/D value of the temperature sensor measured by channel 10;
VR
+
: positive reference voltage, which can be internal reference VREF+, AVcc or external reference VeREF+, unit is mV;
VR-
: negative reference voltage, unit is mV. Usually VR-=AVss, in this case
,
the formula for VST is further simplified to:
(3) |
It can be seen from equations (1) and (3) that the corresponding temperature can be obtained by simply converting the result VST obtained by A/D conversion.
Table 1: MSP430 microcontroller temperature sensor electrical characteristics
parameter | Test conditions | Minimum | Typical Value | Maximum | unit |
V 0℃ | Vcc= 2.2V/3V | 986 - 5% | 986 | 986 + 5% | mV |
TC SENSOR | Vcc= 2.2V/3V,TA=0℃ | 3.55 -3% | 3.55 | 3.55 +3% | mV/℃ |
t SENSOR | Vcc= 2.2V/3V | 30 | μs |
3. Measurement error and its reduction method
It is easy to find that this temperature sensor has a large measurement error, which is also proved by the experiment. This will lead to a large probability of false alarm or missed alarm. Therefore, in order to use it practically, error correction must be performed to reduce these two probabilities. The main reasons for the error are as follows:
0℃ reference voltage error
As shown in Table 1,
the maximum error of
V
0℃
can reach 5%. So the maximum error caused by it is:
. Such a large error will undoubtedly lead to a high probability of false alarm or missed alarm, so it must be calibrated.
Let T RT represent room temperature and V RT represent the output voltage of the temperature sensor at room temperature. Then, from formula (1), we can get:
(4) |
Subtracting formula (4) from formula (1) yields:
(5) |
Because MSP430 is low power, its internal and external temperatures can be considered the same during a period of time when it is turned on. Therefore, we can use a thermometer to measure the room temperature TRT when the power is turned on, use the VST measured when the power is turned on as VRT , and then substitute VRT and TRT into formula (5) to calculate the temperature. This eliminates (or at least reduces) the measurement error caused by inaccurate V0 ℃ , thereby reducing the probability of false alarms and missed alarms.
Sensor voltage error
For industrial standards, the operating temperature range is: -20℃ ~ +85℃. For an actual system, most of the time it works between 0℃ ~ +50℃. Therefore, using it as a reference will lead to a large accumulation error. As can be seen from Table 1, the maximum error introduced by the sensor voltage is about. If the temperature to be measured is 50℃ and 0℃ is used as a reference, the maximum error is: ℃; and if room temperature (assuming TRT = 25℃) is used as a reference, the error is: ℃, which is half of that when 0℃ is used as a reference. Therefore, using room temperature as a temperature reference is a better solution to reduce the accumulation error. However, the error introduced by the sensor voltage is relatively small.
Error introduced by A/D conversion
From the chip data, it can be seen that for 12-bit A/D, the error introduced by leakage current
is 1LSB, which can be ignored. However, the influence of ripple and noise pulse on the power line and ground line caused by poor wiring technology and power supply and ground lines on the conversion results cannot be ignored. As shown in Figure 1, if the digital ground DVss and the analog ground AVss are powered separately, a pair of diodes connected in reverse phase and parallel can be connected between these two points to eliminate the voltage difference of 700mV. In addition, if the reference voltage (VR
+
- VR-
)
is small, the influence of ripple will become more obvious, thus affecting the conversion accuracy. Therefore, the clean and noise-free power supply has a great influence on the accuracy of A/D conversion. Of course, it is better to use a larger (
VR+
- VR-
)
when possible
. Also, try not to use the internal reference, which is not very stable and will affect the accuracy of the conversion. Carefully arranging the bypass capacitors of each ground point is also very useful to reduce the influence of noise. Figure 1 shows a typical decoupling capacitor configuration. Connecting a 10uF tantalum capacitor and a 0.1uF ceramic capacitor in parallel to the chip's power supply and external reference voltage (not shown) pins can effectively suppress noise.
Measuring temperature with an embedded temperature sensor is affected by many factors. In addition to the methods discussed above, there are also general methods to reduce errors, such as averaging multiple measurements. Therefore, it is necessary to consider all factors comprehensively to achieve satisfactory results.
4. Software Description
Another outstanding advantage of MSP430 is that it is easy to write programs in C language and the compilation efficiency is very high. The following is a brief description of the software implementation of this system using MSP430F449 as an example. Figure 3 shows the program flow.
#include "msp430x44x.h" // Include header files
#include
#define Trt 25 //Pre-measured room temperature #define
Th 50 //High temperature alarm temperature
#define Tl 0 //Low temperature alarm temperature
int i=0, k=0,Vrt; //Define global variables
int ADC_Result[16];
float T; //Measured temperature
void init(void); //Initialization function
void ADC12(void); //A/D conversion function
void Alarm(float t); //Alarm processing function
void init(void)
{
TACTL=TASSEL1+TACLR+MC_1; //Timer initialization, working in "up" mode
CCTL0|=CCIE; //Enable CCR0 interrupt
CCR0=0x0FF; //Set timing value
_EINT(); //Open interrupt
P2DIR|=BIT0+BIT1; //P2.0 and P2.1 are alarm outputs;
}
void ADC12(void)
{
ADC12CTL0 &=~ ENC; //First reset the ADC conversion enable when setting
ADC12CTL0 = ADC12ON+REF2_5V+SHT0_8; //Use internal 2.5V reference, turn on channel 10 REFON automatically turns on
ADC12CTL1 = SHP+ADC12SSEL_2; //Rising edge sampling, main clock, MEM0
ADC12MCTL0 = EOS + INCH_10+SREF_1; //Select channel 10, Vref+ is the reference voltage, and measure temperature
ADC12CTL0 |= ENC;
ADC12CTL0 |= ADC12SC; //Start conversion
if ((ADC12IFG & BIT0)==1) //If the conversion is completed, read the data
ADC_Result[i]=ADC12MEM0;
}
void Alarm(float t)
{
if(t>=Th)
P2OUT|=BIT1; //High temperature alarm
else if(t<=Tl)
P2OUT|=BIT0; //Low temperature alarm
else
P2OUT&=~(BIT0+BIT1); //No alarm
}
interrupt[TIMERA0_VECTOR] void Timer_A (void) //Interrupt processing subroutine //
{
int ADC_Sum=0;
float Vst;
for (i=0;i++;i<16) //Perform 16 consecutive conversions to improve accuracy
{
ADC12();
ADC_Sum +=ADC_Result[i]; //Sum
i++;
}
ADC_Sum>>=4; //Shift ADC_Sum right by 4 bits, which is equivalent to dividing by 16. Get the average result;
Vst=( ADC_Sum /4095.0)*2500; //Complete the conversion and get the voltage value
k++;
#ifndef Trt
T=(Vst-986)/3.35; //Measure the temperature with 0 degrees as the reference
#else
if (k==1) Vrt=Vst; //If Trt is defined, the first conversion result is used as Vrt at room temperature
T=(Vst-Vrt)/3.35+Trt; //Measure the temperature with room temperature as the reference
#endif
Alarm(T); //Alarm processing
}
void main (void)
{
init(); //Initialize
LPM1; //Enter low power mode 1;
}
5. Conclusion
This article only describes the alarm part. If an LCD is added, the temperature can be displayed in real time, and a keyboard can be added to preset the room temperature and alarm temperature. If the above program is improved, it will be a practical system. Because these two parts are relatively simple and mature, they are not discussed further in this article.
Previous article:Design of variable signal source based on AT27C1024
Next article:A new intelligent control system for guided bombs
- Popular Resources
- Popular amplifiers
- Molex leverages SAP solutions to drive smart supply chain collaboration
- Pickering Launches New Future-Proof PXIe Single-Slot Controller for High-Performance Test and Measurement Applications
- CGD and Qorvo to jointly revolutionize motor control solutions
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Nidec Intelligent Motion is the first to launch an electric clutch ECU for two-wheeled vehicles
- Bosch and Tsinghua University renew cooperation agreement on artificial intelligence research to jointly promote the development of artificial intelligence in the industrial field
- GigaDevice unveils new MCU products, deeply unlocking industrial application scenarios with diversified products and solutions
- Advantech: Investing in Edge AI Innovation to Drive an Intelligent Future
- CGD and QORVO will revolutionize motor control solutions
- 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
- 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
- [MM32 eMiniBoard Review] Part 1: Unboxing
- IGBT DC voltage and current stabilizing power supply equipment solution requirements, seeking cooperation
- These tools can help you quickly understand ADI data converter products!
- ADI officially acquired Maxim's old memories
- [Experimental Guide] How to view the number of GPIO added on the FPGA side of the SoC FPGA system
- Looking for a book Yuan Diwen "High Frequency Communication Circuit Design"
- Watch the video, participate in the NXP quiz, and win wonderful gifts!
- Competition Sharing 4: RSL10 Bluetooth SoC BME680 Sensor Data Collection
- [Analog Electronics Course Selection Test] + TI High Precision Laboratory
- Registration has ended | GigaDevice GD32E231 DIY Contest! 100 development boards free to try + great gifts!