rebeltaz 36 Posted April 20, 2013 Share Posted April 20, 2013 I am trying to use the msp430g2553's built in temperature sensor to measure the ambient temprature surrounding the device, but the temperature seems to very from between 7 to 10 degrees higher than the temprature measured by a seperate self-contained digital thermometer placed directly beisde the msp. In cas it matters, the code I am using is: void ConfigADC(void) { /* Configure ADC Temp Sensor Channel */ ADC10CTL1 = INCH_10 + ADC10DIV_3; // Temp Sensor ADC10CLK/4 ADC10CTL0 = SREF_1 + ADC10SHT_3 + REFON + ADC10ON; __delay_cycles(1000); // Wait for ADC Ref to settle } inline void take_temp(void) { unsigned int adc; // take temperature reading ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start while (!(ADC10CTL0 & ADC10IFG)); adc = ADC10MEM; temp = (((48724L * adc) - 30634388L) >> 16); // formula from http://forum.43oh.com/topic/1954-using-the-internal-temperature-sensor/ while (ADC10CTL0 & ADC10BUSY); // wait for non-busy ADC10CTL0 &= ~ENC; ADC10CTL0 &= ~ADC10IFG; } thanks... Quote Link to post Share on other sites
tripwire 139 Posted April 20, 2013 Share Posted April 20, 2013 It looks like you're not using the temperature sensor calibration values stored in info A on the 2553. I'm not sure if that's sufficient to cause the inaccuracy you're seeing, but it's worth a shot. The calibration values are mentioned in chapter 24 of the MSP430x2xx Family User's Guide and also on page 15 of the 2553 datasheet: The temperature sensor is calibrated using the internal voltage references. At VREF2_5 = 0 and 1, the12-bit conversion result at 30 nemetila 1 Quote Link to post Share on other sites
nemetila 12 Posted April 20, 2013 Share Posted April 20, 2013 1. Every 2553 MCUs have different tempereture caracteristics. The datasheet says: VSensor,typ = TCSensor (273 + T [ Quote Link to post Share on other sites
tripwire 139 Posted April 20, 2013 Share Posted April 20, 2013 I tested out B.Noll's code on my 2553, first with the typical slope/offset values from the linked post and then with the factory-set calibration values. The difference was about 1 Quote Link to post Share on other sites
rebeltaz 36 Posted April 21, 2013 Author Share Posted April 21, 2013 I tested out B.Noll's code on my 2553, first with the typical slope/offset values from the linked post and then with the factory-set calibration values. The difference was about 1 Quote Link to post Share on other sites
jpnorair 340 Posted April 21, 2013 Share Posted April 21, 2013 Barring that, I wouldn't think that the chip could be +10 degrees hotter than then surrounding air, It probably shouldn't be, so maybe you just need to subtract by a constant. You can try reading the temperature at different clock speeds to see if it is different. Quote Link to post Share on other sites
tripwire 139 Posted April 21, 2013 Share Posted April 21, 2013 Sorry, I should have been a bit clearer in my last post. If you use the formula I posted it will make your readings even higher - it's based on the calibration values specific to the chip I have here. I was trying to find out whether the conversion formula based on typical values could differ significantly from the calibrated version. On my chip the difference was a couple of degrees at most - not enough to account for the difference you're seeing. Having said that, maybe my chip just happens to produce results that are quite close to the typical ones in the datasheet... Do you have any way of inspecting the flash memory of your chip? The debugger in CCS can do that, if that's what you're using. If you can grab the contents of flash from 0x10C0 to 0x10FF (Info A memory block) we'll be able to see the calibration values for your chip. Also, what clock speed are you running the msp430 at? Quote Link to post Share on other sites
rebeltaz 36 Posted April 21, 2013 Author Share Posted April 21, 2013 Do you have any way of inspecting the flash memory of your chip? The debugger in CCS can do that, if that's what you're using. If you can grab the contents of flash from 0x10C0 to 0x10FF (Info A memory block) we'll be able to see the calibration values for your chip. Also, what clock speed are you running the msp430 at? I am using CCS, but in Linux. I can load it up in VirtualBox and see if I can figure out how to get that and I'll report back. Quote Link to post Share on other sites
oPossum 1,083 Posted April 22, 2013 Share Posted April 22, 2013 The tags in info segment A can be displayed with this code: http://forum.43oh.com/topic/2026-tlv-data-calibration-parse-and-display/ The only G series chips I have seen with temperature cal is the G2452. Here is code that will read the cal data and use it: http://forum.43oh.com/topic/2027-how-to-use-temperature-calibration-data/ tripwire 1 Quote Link to post Share on other sites
tripwire 139 Posted April 22, 2013 Share Posted April 22, 2013 The only G series chips I have seen with temperature cal is the G2452. The 2553 has it too. Thanks for the TLV code! EDIT: I've just been reading the threads oPossum linked and it seems that the 2553 didn't always have temperature calibration values (they were zeroed). Mine does have valid data, so perhaps TI only started calibrating them sometime in the last year or so. Quote Link to post Share on other sites
rebeltaz 36 Posted April 22, 2013 Author Share Posted April 22, 2013 Thank you both. Hmm... I originally tried to compile this for the 2452, but it wouldn't program to that chip... I wonder if that might work better? I don't know.. but I will try to get those values as soon as I get a chance. If y'all happen across my other thread, you'll see that I am working on a more pressing issue with this project Quote Link to post Share on other sites
rebeltaz 36 Posted April 28, 2013 Author Share Posted April 28, 2013 I tried this on a 2452 tonight and I still get a temperature that is anywhere between 7 to 13 degrees hotter than the surrounding air. And the chip feels as cool as a cucumber... I am just going to reuse the code that I used on my Coffee Pot Fish Tank and use an external temperature sensor, since that seems to read much closer to right. I was re-going over that code tonight and, just for my own curiosity, can anyone explain how this formula is able to display the temperature in one degree steps? I would think that, since the loop breaks once the raw analog input is greater than any one of the values stored in the table and performs the same calculation on the result, the temperature reading could only be one of (in my case) 40 possible values (20 in the original). Rather than repost the code here, I will just link to the original thread: http://forum.43oh.com/topic/2004-thermistor-code-for-msp430/ I tried asking for help there a long time ago (I since figured that out on my own0 but I never got a response, so I thought I'd try here. Quote Link to post Share on other sites
oPossum 1,083 Posted April 28, 2013 Share Posted April 28, 2013 It does linear interpolation... int realtemp = temptable[i-1][1] + (rawtemp - temptable[i-1][0]) * (temptable[i][1] - temptable[i-1][1]) / (temptable[i][0] - temptable[i-1][0]); bluehash 1 Quote Link to post Share on other sites
rebeltaz 36 Posted April 28, 2013 Author Share Posted April 28, 2013 It does linear interpolation... int realtemp = temptable[i-1][1] + (rawtemp - temptable[i-1][0]) * (temptable[i][1] - temptable[i-1][1]) / (temptable[i][0] - temptable[i-1][0]); Oh... well why didn't you say so!? I guess I am off to read https://en.wikipedia.org/wiki/Linear_interpolation ... lol Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.