• 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 » Low Power RF & Wireless Connectivity » Low Power RF Hardware & Tools Forum » ADC error
Share
Low Power RF & Wireless Connectivity
  • Forums
  • Announcements
  • Files
  • E2E Wiki
Options
  • Subscribe via RSS

Forums

ADC error

This question is answered
Lei Chen1
Posted by Lei Chen1
on Dec 27 2012 00:46 AM
Intellectual610 points

Please see the picture below,


I am converting a sine wave, the lowest voltage get "clipped off" and returned the highest possible ADC conversion number.

I am new in this field, is this a well known phenomenon that ADC tends to mistake the "close to 0V" as the "VREF" and return the highest possible number (for 12 bit, 4095)?  And how to deal with this?

Thanks!

Report Abuse
  • Reply
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
All Replies
  • Lei Chen1
    Posted by Lei Chen1
    on Dec 27 2012 02:37 AM
    Intellectual610 points

    Indeed, if I set any pin (for example, p0) as a single end input, and then use a wire to connect the ground pin to the p0, the ADC will return the highest possible number.  And if I set any two pins as the differential input, and then use a wire to connect these two pins, the ADC will return the highest possible number as well.

    This is done on the cc2510 mini development kit.  Really weird, why is that?   

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • BugKing
    Posted by BugKing
    on Dec 27 2012 09:54 AM
    Verified Answer
    Verified by Chatto
    Prodigy690 points

    Hello Lei Chen1,

    As the responder to your previous post noted, the ADC data is a signed value which you need to convert using Two's complement.  You may want to consult a digital textbook or even wikipedia for some basic two's complement information if you need it.   The MSB of a signed value indicates whether it is negative or positive (0=positive, 1=negative).

    You note the value is 4095, which tells me you are treating the number as an unsigned value, however when treated as a signed number a value of all ones (1111 1111 1111) is equivalent to -1, so the value you are getting is actually correct.  

    Regards,

    BK

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Lei Chen1
    Posted by Lei Chen1
    on Dec 27 2012 17:52 PM
    Intellectual610 points

    Hi, BugKing,

    Thanks for the reply!  And thank you for pointing out the error (ie, I treated a signed number as a unsigned number), which does explained it.

    I understand that the MSB is the sign bit, but I still don't know how to send a signed ADC data over the radio.

    So for example, if I write the following,

    int8 ADCH;

    SMPL_Send (linkID, &ADCH, 1);

    The IAR will give me an error saying that the int8 does not match the type of data that the radio send, which is unit8.  In another word, no matter how you format it, the negative number is a negative number, and if the radio can only send a positive number, how does it work?

    Thanks!

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Lei Chen1
    Posted by Lei Chen1
    on Dec 27 2012 18:26 PM
    Intellectual610 points

    I tried to cast the ADCH before sending it over the radio, using the following code,

    uint8_t uADCH = (uint8_t) ADCH;

    SMPL_Send (linkID, &uADCH, 1);

    But did not seem to work.

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Lei Chen1
    Posted by Lei Chen1
    on Dec 28 2012 07:45 AM
    Intellectual610 points

    Solved the problem finally,

    Quite simple actually, just add a sentence, "if adc<0, adc=0", so that "-1" will not be mistaken as the "111111111111".

    The sine wave I am sampling actually goes from 0V to 3V (well, at least that's what the function generator is supposed to do), so the ADC result should never goes below zero, although BugKing precisely pointed out the problem, I still do know why ADC went below zero.

    Well, quite a learning experience, and thanks everyone, now I have to figure out how to increase the sampling rate so that the sine wave will look smooth.

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Timothy Barr
    Posted by Timothy Barr
    on Dec 28 2012 13:11 PM
    Expert2505 points

    Try this

    uint8_t ADC_msg[2]

    u16 ADC_data

    ..

    ADC_msg[0] = (u8)(ADC_data >>8);

    ADC_msg[1] = (u8)(ADC_data & 0xFF);

    SMPL_Send (linkID, ADC_msg, 2);

     

    and on the receiving end:

    ADC_data = (u16)(ADC_msg[0] <<8  + ADC_msg[1]);

     

    Tim Barr

    Multitech Systems Inc

    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