4 Replies Latest reply on Nov 27, 2011 4:18 PM by userc_44408

    ltage measurment Project simple problem..

      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..

        • 1. Re: ltage measurment Project simple problem..



          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














          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



          • 2. Re: ltage measurment Project simple problem..

            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..

              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

              • 4. Re: ltage measurment Project simple problem..

                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 !! :)