1 2 Previous Next 23 Replies Latest reply on Apr 15, 2018 1:13 PM by user_49271930

    measuring voltage across potentiometer

    tomer.cccp_2937441

      hello I am trying to meassure voltage across potentiometer how ever i get the wrong voltage (and get even negetiv Voltage ) that displayes on the LCD , here is the code and top design :

       

      top_desigb_ADC.pngmain_code_ADC.png

       

      any ideas why am i getting the wrong voltage ?

        • 1. Re: measuring voltage across potentiometer
          bob.marlowe

          Try with debugger to check if values are really negative.

          Try using "%ld" format in sprintf()

           

          Bob

          • 2. Re: measuring voltage across potentiometer
            tomer.cccp_2937441

            i did not undestand what do you mean . and what do you mean ?

            • 3. Re: measuring voltage across potentiometer
              bob.marlowe

              Can you please post your complete project so that we all can have a look at all of your settings. To do so, use

              Creator->File->Create Workspace Bundle (minimal)

              and attach the resulting file.

               

              Bob

              1 of 1 people found this helpful
              • 4. Re: measuring voltage across potentiometer
                tomer.cccp_2937441

                hi bob i cant find the attach file butten

                • 5. Re: measuring voltage across potentiometer
                  bob.marlowe

                  Click on "Use advanced Editor" (upper right hand corner) and an "Attach" will come up (at lower right corner).

                  Which Cypress kit are you using? CY8CKIT-???

                   

                  Bob

                  • 7. Re: measuring voltage across potentiometer
                    bob.marlowe

                    I cannot see where your potentiometer is connected to, but I assume beween GND and +5V.

                    The ADC is configured for an input range of 1 to 2V which will give unpredictable results when overflown. You cold try setting the input range to 6*Vref.

                     

                    Bob

                    • 8. Re: measuring voltage across potentiometer
                      tomer.cccp_2937441

                      i tried changing to 6Vref yet the voltage is still in correct

                      • 9. Re: measuring voltage across potentiometer
                        chrisvn_1477726

                        Hi. I am not sure why you are using the DAC. This would cause you to get negative results, depending on the DAC output voltage and the measured voltage.

                         

                        To check your setup and program, try using the ADC in single ended mode and check the measurement range as defined in the component configuration.

                         

                        I use an ADC in just about with every design and have no issues, from sine wave measurement for RMS values to 9 mux inputs into the ADC for various external measurements and oversampling to get 4 additional bits of resolution for PT100 temperature measurements with wire length compensation.

                         

                        Regards

                        Chris

                        • 10. Re: measuring voltage across potentiometer
                          tomer.cccp_2937441

                          hi I tried what you said and put the ADC on single ended and wrote this code :

                           

                          /*******************************************************************************

                          * File Name: main.c

                          *

                          * Version: 2.20

                          *

                          * Description:

                          *   This is a source code for example project of ADC single ended mode.

                          *

                          *   Variable resistor(pot) is connected to +ve input of ADC using the I/O pin.

                          *   P0.0. When voltage to positive terminal of ADC is 0, the output displayed

                          *   on the LCD pannel is 0x0000. As voltage on positive terminal goes on

                          *   increasing, the  converted value goes on increasing from 0x0000 and reaches

                          *   0xFFFF when voltage becomes 1.024V. Futher increase in voltage value,

                          *   doesn't cause any changes to values displayed in the LCD.

                          *

                          * Hardware Connections:

                          *  Connect analog input from Variable resistor to port P0[0] of DVK1 board.

                          *

                          ********************************************************************************

                          * Copyright 2012-2015, Cypress Semiconductor Corporation. All rights reserved.

                          * This software is owned by Cypress Semiconductor Corporation and is protected

                          * by and subject to worldwide patent and copyright laws and treaties.

                          * Therefore, you may use this software only as provided in the license agreement

                          * accompanying the software package from which you obtained this software.

                          * CYPRESS AND ITS SUPPLIERS MAKE NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,

                          * WITH REGARD TO THIS SOFTWARE, INCLUDING, BUT NOT LIMITED TO, NONINFRINGEMENT,

                          * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.

                          *******************************************************************************/

                           

                           

                          #include <project.h>

                          #include<stdio.h>

                           

                           

                           

                           

                          /*******************************************************************************

                          * Function Name: main

                          ********************************************************************************

                          *

                          * Summary:

                          *  main() performs following functions:

                          *  1: Initializes the LCD

                          *  2: Starts ADC

                          *  3: Starts ADC converstion.

                          *  4: Gets the converted result and displays it in LCD.

                          *

                          * Parameters:

                          *  None.

                          *

                          * Return:

                          *  None.

                          *

                          *******************************************************************************/

                          int main()

                          {

                              int32 output;

                           

                           

                              /* Start the components */

                           

                           

                              LCD_Start();

                              ADC_DelSig_1_Start();

                           

                           

                              /* Start the ADC conversion */

                              ADC_DelSig_1_StartConvert();

                           

                           

                              /* Display the value of ADC output on LCD */

                              LCD_Position(0u, 0u);

                              LCD_PrintString("ADC_Output");

                           

                           

                              for(;;)

                              {

                                  if(ADC_DelSig_1_IsEndConversion(ADC_DelSig_1_RETURN_STATUS))

                                  {

                                      output = ADC_DelSig_1_GetResult32();

                                    

                                      /* Saturate ADC result to positive numbers. */

                                      if(output < 0)

                                      {

                                          output = 0;

                                        //  CyDelay(100u);

                                      }

                                     LCD_Position(1u, 0u);

                                     LCD_PrintInt16((uint16)output);

                                        CyDelay(500u);

                                 // LCD_Char_PrintNumber((uint16)output);

                                //  LCD_Char_PrintU32Number((uint32) output);

                                  }

                              }

                          }

                           

                           

                           

                           

                          /* [] END OF FILE */

                           

                           

                           

                          and the problem is that i get wrong numers again , and it is written in ASCII code

                          • 11. Re: measuring voltage across potentiometer
                            chrisvn_1477726

                            Hi

                             

                            A few questions.

                            • For how many bits is the ADC set up?
                            • What conversion rate is selected?
                            • What input range is selected?
                            • What buffer gain is selected?
                            • In your design wide resources, what voltages are selected?
                            • Please post some of the results so I can see what you mean by wrong values that you get.

                             

                            Actually, please post your project, then I have all the info.

                             

                            If I get  a chance, I will put the code on one of my kits to see what I get.

                             

                            Chris

                            • 12. Re: measuring voltage across potentiometer
                              chrisvn_1477726

                              Hi

                               

                              As part of the CY8CKit -050 download, there is also a nice example of the DeltaSigma ADC usage, with filtering and display.

                               

                              Regards

                              Chris

                              • 14. Re: measuring voltage across potentiometer
                                user_49271930

                                It seems necessary to use LCD_PrintInt32 and input range = Vssa to Vdda.

                                1 2 Previous Next