• Join
  • Sign In with my.TI Login
Texas Instruments
  • Products
  • Applications
  • Tools & Software
  • Support & Community
  • Sample & Buy
  • About TI
Sample & Purchase Cart Sample & Purchase Cart
  • Search
  • Advanced
TI E2E™ Community
  • Support Forums
  • Blogs
  • Groups
  • Videos
  • 简体中文
  • More ...
TI Home » TI E2E Community » Support Forums » Microcontrollers » MSP430™ Microcontrollers » MSP430 Ultra-Low Power 16-bit Microcontroller Forum » LM35DZ and ADC10 problem
Share
MSP430™ Microcontrollers
  • Forum
  • Announcements
  • E2E Wiki
Options
  • Subscribe via RSS
MSP430 Resources
  • MSP430 Product Folder
  • MSP-EXP430G2 - MSP430 LaunchPad Value Line Development kit
  • MSP430 Getting Started Guide
  • MSP430 Microcontroller Projects
  • More Resources >
  • Forums

    LM35DZ and ADC10 problem

    This question is not answered
    M. Emre Ture
    Posted by M. Emre Ture
    on Apr 01 2012 06:23 AM
    Prodigy30 points

    Hello All,

    I've a strange problem with ADC10 module of MSP430G2553 when using LM35DZ. The code below works as it's supposed to but when i change ADC input channel other than INCH_0, i get a constant reading of 2.6 Volts.

        ADC10CTL0 = SREF_1 + ADC10SHT_3 + REFON + ADC10ON;  // Vref = 1,5V + SHT = x64
        ADC10CTL1 = INCH_0 + ADC10DIV_3;
        ADC10AE0 = BIT0;

    When using INCH_0 i get a reding of appr. 230 mVolts which is correct. But when i change the code as follows (x is between 1 and 7) i get a constant reading of 2.6 Volts.

        ADC10CTL0 = SREF_1 + ADC10SHT_3 + REFON + ADC10ON;  // Vref = 1,5V + SHT = x64
        ADC10CTL1 = INCH_x + ADC10DIV_3;
        ADC10AE0 = BITx;

    When INCH_0 pin is floating, raw readings change between 490 and 550. And when INCH_x (x is between 1 and 7 again) is floating, raw readings are always 1023.

    When i connect another analog source (such as batteries between 1.0 V and 1.5 V) i always get correct readings no matter which ADC input channel i use.

    Probably this is a ADC10 settings issue. Could anyone tell me what i'm missing?

    Thanks in advance,

    Emre.

    ADC10 MSP430x2xx MSP430g2553 LM35DZ
    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    All Replies
    • Roberto Romano
      Posted by Roberto Romano
      on Apr 01 2012 12:01 PM
      Mastermind6840 points

       Hi, Are you setting Direction to Input? Which voltage is measured when pin are floating? 1023 is the full scale reading so if the pin is set to output or REN enable a resistor as pullup may be this value happen. Batteries force input to the internal voltage sinking the pullup weak current.

       From your chunk of code and writing no more than this can be extracted, please tell us if this confirm or more detailed description and full code initializing port are necessary to formulate some possible source of issue.

       I think ADC has no issue at all.

       Regards

       Roberto.

       Regards

       Roberto


       Please login & click    Verify Answer    if this post answered your question.

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • M. Emre Ture
      Posted by M. Emre Ture
      on Apr 01 2012 13:49 PM
      Prodigy30 points

      Thank you for your reply Roberto,

      After i read your message, i checked the P1 registers in debug mode and found out that P1IN has a default value of 0x0E which means P1IN.1, P1IN.2 and P1IN.3 are 1 and other pins are 0.

      When Vout of LM35DZ is connected to pins 0, 4, 5, 6 and 7 the readings are correct. But when it's connected to pins 1, 2 or 3 the reading are always 2.6 Volts (measured by a voltmeter since reference voltage of ADC10 is 1.5 Volts)

      I understand that the problem will be solved when P1IN is set to 0x00. How can i do that?

      The full code is as follows. Comments are not in English but since the code is short, i hope you don't mind.

      #include "..\hd44780\hd44780.h"

      volatile float sicaklik = 0;

      int _system_pre_init(void)
      {
          WDTCTL = WDT_ADLY_250;    //Watchdog timer zaman aralığı 250 milisaniye.
          BCSCTL1 = CALBC1_1MHZ;    //BSC 1 MHz.
          DCOCTL = CALDCO_1MHZ;    //DCO 1 MHz.
          //BCSCTL3 |= BIT2;        //Kristal osilatör kondansatörü 6 pF.
          return(1);
      }

      void main (void)
      {
          __delay_cycles(1000000);        //Kristal ve LCD Display'in başlamasını bekle.
          hd44780_Init();                //LCD Display'i başlat.
          ADC10CTL0 = SREF_1 + ADC10SHT_3 + REFON + ADC10ON;  // Vref = 1,5V + SHT = x64
          ADC10CTL1 = INCH_0 + ADC10DIV_3;
          ADC10AE0 = BIT0;
          IE1 |= WDTIE;                //Watchdog timer için interrupt enable.
          IFG1 &= ~WDTIFG;            //Hemen interrupt oluşmasını engellemek için flag'i temizle.
          LCD_Cursor(0,0);
          LCD_Print(" LM35DZ isi sensoru ");
          _BIS_SR(LPM3_bits + GIE);    //Düşük güç moduna gir ve interrupt'ları enable.
          while(1)    //Bu döngü hiç işletilmeyecek.
          {
              LCD_Cursor(0,0);
              LCD_Print("Never Executed");
          }
      }

      #pragma vector=WDT_VECTOR
      __interrupt void WDT_ISR (void)
      {
          static unsigned int adc[11] = {0,0,0,0,0,0,0,0,0,0};
          static int count = 0;
          LCD_Cursor(count, 3);
          LCD_Print(" o");
          ADC10CTL0 |= ENC + ADC10SC;   // ADC dönüşümünü başlat
          while(ADC10CTL1 & ADC10BUSY);
          adc[count++] = ADC10MEM;
          if (count == 10)
          {
              count = 0;
              adc[10] = (adc[0] + adc[1] + adc[2] + adc[3] + adc[4] + adc[5] + adc[6] + adc[7] + adc[8] + adc[9]) / 10;
              sicaklik = (adc[10] / 1024.0f) * 1500.0f;
              LCD_Cursor(0,1);
              LCD_PrintInt((int)sicaklik, 4);
              LCD_Print(" - ");
              LCD_PrintInt(sicaklik / 10,0);
              LCD_Print(",");
              LCD_PrintInt((int)sicaklik % 10,0);
              LCD_Print("ßC");
              LCD_Cursor(0,2);
              LCD_PrintInt(adc[10], 0);
              LCD_Print("   ");
          }
          //IFG1 &= ~WDTIFG;
      }//WDT ISR


      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Jens-Michael Gross
      Posted by Jens-Michael Gross
      on Apr 03 2012 07:17 AM
      Guru139900 points

      M. Emre Ture
      I understand that the problem will be solved when P1IN is set to 0x00. How can i do that?

      P1IN.x is 1 because the voltage on the pin is above the high threshold voltage ~2.3V).
      P1IN only reflects the digital input state, it does not create it. So the voltage comes from outside. Unless you activated the internal pullups or switched this pin to output mode. I don't see you doing this, so the voltage mus tcome from outside (external pullups?)

      _____________________________________
      Before posting bug reports or ask for help, do at least quick scan over this article. It applies to any kind of problem reporting. On any forum. And/or look here.
      If you cannot discuss your problem in the public, feel free to start a private conversation: click on my name and then 'start conversation'. But please do so only if you really cannot do it in a public thread, as I usually read all threads. And I prefer to answer where others can profit from it (or contribute to it) too.

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • M. Emre Ture
      Posted by M. Emre Ture
      on Apr 03 2012 13:41 PM
      Prodigy30 points

      One of the instructors from www.mcu-turkey.com has told me the source of the problem and its solution. You are absolutely right; there's voltage on pins P1.1, P1.2 and P1.3 and their source is launchpad itself!

      Unlike other pins, P1.1, P1.2 and P1.3 are special. P1.1 and P1.2 are connected to TXD and RXD. P1.3 is connected to S2 with a pull-up resistor. Low analog sources such as LM35DZ produces cannot suppress the voltage on P1.1, P1.2 and P1.3

      The solution is simply to disconnect the RXD and TXD jumpers in order to use P1.1 and P1.2. The pull-up resistor should be removed to use P1.3 but this doesn't seem to be a good idea since it doesn't have a jumper. As far as I know launchpad rev 1.5 doesn't include a pull-up resistor connected to S2. I'm using rev 1.4.

      Best regards,

      Emre.

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Jens-Michael Gross
      Posted by Jens-Michael Gross
      on Apr 04 2012 11:38 AM
      Guru139900 points

      M. Emre Ture
      The pull-up resistor should be removed to use P1.3 but this doesn't seem to be a good idea since it doesn't have a jumper.

      If you need it for a software that uses the button, the software can enable the internal pullup instead. So the external one isn't really needed at all. Just the demo code doesn't set the internal pullup, so it won't work unchanged without the external one.

      _____________________________________
      Before posting bug reports or ask for help, do at least quick scan over this article. It applies to any kind of problem reporting. On any forum. And/or look here.
      If you cannot discuss your problem in the public, feel free to start a private conversation: click on my name and then 'start conversation'. But please do so only if you really cannot do it in a public thread, as I usually read all threads. And I prefer to answer where others can profit from it (or contribute to it) too.

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    TI E2E™ Community
    • Support Forums
    • Blogs
    • Videos
    • Groups
    • Site Support & Feedback
    • Settings
    TI E2E™ Community Groups
    • TI University Program
    • Make the Switch
    • Microcontroller Projects
    • Motor Drive & Control
    Other Communities
    • Deyisupport
    • Designsomething.org
    • beagleboard.org
    • TI on Element 14
    • TI on TechXchangeSM
    Other Technical & Support Resources
    • WEBENCH® Design Center
    • Product Information Centers
    • Technical Documents
    • TI Design Network
    • TI Technical Articles
    • TI Training

    All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.

    Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms of Use of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms of Use of this site. TI, its suppliers and providers of content reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

    Follow Us Texas Instruments on Facebook Texas Instruments on Twitter Texas Instruments on LinkedIn Texas Instruments on Google+
    TI Worldwide | Contact Us | my.TI Login | Site Map | Corporate Citizenship | mobile m.ti.com (Mobile Version)

    TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs and
    embedded processors, along with software, tools and the industry’s largest sales/support staff.

    © Copyright 1995-2013 Texas Instruments Incorporated. All rights reserved.
    Trademarks | Privacy Policy | Terms of Use