-
1. Re: ltage measurment Project simple problem..
JoMe_264151 Nov 27, 2011 2:19 AM (in response to userc_44408)Hi,
the C-language distinguishes strictly between signed and unsigned items. When you have a look at the API of your ADC ther is mentioned to use the ADC_Get16() - call to overcome problems with the sign-bit. Your var "result" is already a signed int.
Despite from the former used PSoC 1, you shoulod use for PSoC3 and 5 the given tpedefs
int16
uint16
int8
uint8
char8
int32
and uint32
which all you can +define or typedef for your PSAoC1 projects as well to maintain portability.
Your Creator-Libraries are rather olde, please consider an update (with the Cypress updeate Manager).
Have fun, happy coding
Bob
-
2. Re: ltage measurment Project simple problem..
gautamd_ Nov 27, 2011 10:03 AM (in response to userc_44408)Hi blueblood,
Here are my suggestions after testing your project:
1) First and foremost, please update to the latest version of PSoC Creator. The link is http://www.cypress.com/?id=2494&source=header . I updated the componentes in the project to the latest ones.
2) The variable used to store the ADC converted value "result" was declared as "int". Declaring it as an uint8 is better in this case as you are using it in single ended mode with the input varying from Vss to Vdd (0V - 5V). Using "int" is advisable when using ADC in differential mode where both negative and positive values are to be expected.
3) As is advised in the ADC Component datasheet, it is recommended to use the GetResult16( ) API when ADC is configured for 8 bits mode or higher and GetResult32( ) when ADC is configured for 16 bit mode or higher. When "result" is declared as "uint16" variable, there is no error due to rolling off of the ADC value when the input slightly exceeds 5.00V. The roll-over error persists when GetResult8( ) is used.
4) For the ADC to continuously measure the input voltage, the ADC conversion mode is set to "Continuous". The updating of LCD is done in an infinite loop { while(1) } after waiting for the conversion to end.
5) There are APIs which directly gives the counts in Volts, mVolts, and uVolts. The APIs are ADC_CountsTo_Volts( ), ADC_CountsTo_mVolts( ) and ADC_CountsTo_uVolts( ) respectively. You can use it to your advantage as it frees you from computing the Voltage explicitly.
6) When using these APIs, remember to set the right values for Vdda (as this is the reference). This can be done is .cydwr > System > Voltage Configuration. Set it to appropriate value as thje Vdda provided to the device.
-
3. Re: ltage measurment Project simple problem..
gautamd_ Nov 27, 2011 10:48 AM (in response to userc_44408)The ADC has input Buffer which provides gains of 1,2,4 and 8. The noise performance of this internal buffer is better than the one using PGA.
The modified project is attached. Please note that the project is modified using PSoC Creator 1.0
You'll be able to use if if you update to Creator 1.0
-
demo_adc.zip 251.4 K
-
-
4. Re: ltage measurment Project simple problem..
userc_44408 Nov 27, 2011 4:18 PM (in response to userc_44408)thanx dasg and bob !! it was really a great help !! i am going through learning phase of psoc and your help is immensly helpful !! thanx once again !! :)