I dont know how to move this thread from PSoC 3 "Device Programming" catagory to "PSoC 3 Architecture" Catagory. It is my sincere apology to all viewer, that I have made this mistake. Please help.
Don't worry about the placing of your question, we'll find it as long as you use a PSoC 3 entry, forum software is not capable of editing or re-positioning a post (to be true, forum software isn't capable of many things at all)..
There are some knowledge-base entries concerning your issue: Since ADC cannot be made totally error-free they always show some mismatching, but this can be calculated-off with some simple math.
Errors you find are
- Offset Error
- Gain error
- Temerature error
and probably some more I've forgotten. Each of these errors initially built into the chip can be minimized,
have a look aththis knowledge-base articles (I found them by typing "ADC error" into the field "Keyword search" at top of this page) http://www.cypress.com/?id=4&rID=43218
You are using the wrong GetResult, GetResult16, should be GetResult32,
see notes below for API (dont forget to decalre output as 32 bit) -
You also need to be careful with the input configuration. It decides how close to the rails your input signal can get.
When you config the DelSig the range is shown pictorialy
Hi Bob Marlowe
Thank you for your valuable time, interest and reply. I will defiantly consider it with tuning of my ADC.
Yes.. I got my answers from your post when I have gone (again and again) through component datasheet. My final result is attached here. Thanks again.
But still My question is what I have to do to get 0x0000 to 0xFFFF for 0v-5v.? (Vssa to Vdda) (my actual requirement). Thanks in advance.
Thank you for your reply. Can you suggest me the buffer mode.? It will be saving me from lot of pain. After seeing in snap as danaaknight suggested in above post, I think it will be Rail to Rail, Still it does not serve the purpose. Thanks in advance.
If you are looking for real R-R performance you have to bypass the buffer. If you are
not concerned or need the gain the buffer provides. Look at your current config,
R-R with G = 1, buffer enabled., if you look at the graphic its not R-R, its < R-R
performance. Does not allow you to get to ground or to Vdd with input to buffer.
I am getting a Keil error, "Build error: L251: RESTRICTED MODULE IN LIBRARY NOT SUPPORTED "
So I cannot run your code.
I could open it and compile free of any warning with Creator 3.0
Looks like my desktop Creator has to be reinstalled, compile on laptop fine.
I debugged, and changed/addeed code with this -
unsigned char buff[ 20 ]; // Buffer holding character conversion of ADC results in mV
unsigned char i = 0;
sprintf( buff, "%6d", ADC_DelSig_1_CountsTo_mVolts ( i32Output ) );
for ( i = 0; i < 6; LCD_Position( 1u, 10u + i ), LCD_PutChar( buff[ i ] ), i++ );
//LCD_PrintNumber( ADC_DelSig_1_CountsTo_mVolts (i32Output) );
And I get basically results you are looking for.
Note I do see values > 0xFFFF and have not measured to see if
input went outside CM range.
Hi Top Contributor(s)
Thanks for replying. You guys helping a lot.
I don't know what is going on.. But more I dig, more I got confused.
To be frank I needed to calculate some parameters from this ADC output result(some counter and a 16bit PWM). It requires 16-bit resolution, I tried for even 15 bit but my ultimate slope is not satisfactory. For 16-bit what ever buffer mode I try, I can not get full range of 16 bit (0-65535 for VSS to VDD). For the buffer bypass mode I got some -Ve value (as result is 32 bit signed, thanks for the point Dana) for VSS and 0x000101B5 for VDD. I have tried this by shorting the ADC Input pin directly to VSSA and VDDA. The value between this two point is OK and according to the current configuration. Is it like I am getting the desired result, but I am confused enough to get the conversation done...??
I believe that basic operation, with buffer bypassed, gives you
a range of Vss to Vdd and correct readings. Its when you go outside
CM range, in this case Vss - 100 mV > Vx > Vdd + 100 mV that your
readings go outside 0 - 0xFFFF.
So just saturate your readings, eg
Vx = ( Vx > 0xFFFF ) ? 0xFFFF : Vx; // Test for radings exceeding Vdd
Vx = ( Vx < 0 ) ? 0 : Vx; // Test for readings < 0
You can add the 100 mV into above tests is so desired, although that would
generate result < 0 or > 0xFFFF.
Thanks you, finally you saved me from days pain. I think this satisfy my requirements. Even if I am saturating results here, it does not affect my other application result. My counter slope (ultimate parameters depends on ADC value) is within the range with this settings.
Sorry for wrongly spelling your name.
Here with I am including the final concluded project example, in any case if someone need it. Please do comment if I have mistaken.