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?
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?
In reply to Lei Chen1:
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.
In reply to 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,
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?
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.
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.
ADC_msg = (u8)(ADC_data >>8);
ADC_msg = (u8)(ADC_data & 0xFF);
SMPL_Send (linkID, ADC_msg, 2);
and on the receiving end:
ADC_data = (u16)(ADC_msg <<8 + ADC_msg);
Multitech Systems Inc
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.
TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs andembedded processors, along with software, tools and the industry’s largest sales/support staff.