ltage measurment Project simple problem..

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Hello !! I have made a simple demo project of voltage measurment upto 5 volts in psoc.. it is working fine upto 2.49 volts.. but when i increase the voltage level greater then that voltage goes in negative values..

   

that means for 0 < Voltage < 2.499 volts, it displays proper values on lcd.. but for 2.5 volts it shows -2.5 volts and starts gradually decreasing as i increase voltage further.. for 5 volts it shows exact 0 on lcd..

   

so i made simple conversion logic to add simple 5 volts for values in between 2.5 to 5 volts to display it properly on lcd..

   

i am using psoc dev kit on 5 volts.. why i am facing that problem any guess ??

   

i have attached the peoject along this post..

0 Likes
4 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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

0 Likes
Anonymous
Not applicable

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.

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

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

0 Likes
Anonymous
Not applicable

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 !! 🙂

0 Likes