7 Replies Latest reply on Jul 3, 2018 10:48 AM by jogr_3357391

    ADC values don't follow the inputs?

    jogr_3357391

      My project has a couple of thermistors along with a few other analog values that need monitoring. All associated pins are high-Z Analog inputs with high initial drive (tried both), fed into a ADC_SAR_SEQ_P4_v2_50.
      Now, I thought this would be a slam-dunk. I followed a number of examples - most of them agreed, so I made my project look like those.

       

      But after starting a conversion and waiting for completion, I don't see any meaningful change in the data. I can measure voltage where the thermister comes into the board, and it is indeed changing.

       

      I thought perhaps I needed external terminal for the pins, but it didn't seem to matter, and other examples don't typically use it. I'm not using a hardware trigger - documentation for ADC_Start() indicates it's a substitute ( ADC_FW_TRIGGER), and ADC_IsEndConversion() seems entirely happy.

       

      I've uploaded an archive of the case where there are no external terminals for the pins, though that doesn't seem to matter.

       

      I am in a quandary - can anyone tell me what bit I have messed up?

      Thanks,
      John

        • 1. Re: ADC values don't follow the inputs?
          jogr_3357391

          I have since realized that the "external terminal" is a cosmetic feature that allows the schematic to illustrate external components such as voltage dividers and such. That point has eluded me for the month or so that I've been dealing with this platform.

          • 2. Re: ADC values don't follow the inputs?
            rajivv_36

            John,

             

            1. Opamp doesn't seem to be enabled. Please use the API Opamp_Start().

            2. ADC is configured with hardware trigger. So, StartConvert() API executes one conversion. But, in the function read_adc() multiple conversion is being expected with a single StartConvert() function call. Is the code getting stuck in line 64 of adc.c file (observed in debugging mode)?

             

            - Rajiv 

            • 3. Re: ADC values don't follow the inputs?
              jogr_3357391

              Ooops - I'll enable the opamp, but that explains perhaps one of five channels.
              If I understand the documentation and code properly,  I anticipate one conversion, on all five channels, with one call to StartConvert(). The subsequent call to IsEndConversion() returns as expected, perhaps a bit too quickly, but that's speculation.
              Thank you.

              • 4. Re: ADC values don't follow the inputs?
                rajivv_36

                You are right on conversion of all channels with single call to the function StartConvert(). However, IsEndConversion() function will clear EOS_INTR bit in INTR register, once the result is available. So, in the next call to this function, it loops forever checking for EOS_INTR, as the conversion is not initiated again.

                 

                -Rajiv

                • 5. Re: ADC values don't follow the inputs?
                  jogr_3357391

                  "loops forever" implies that control never returns to the calling function, which is not the case.  IsEndConversion() does not hang.
                  Thanks,
                  John

                  • 6. Re: ADC values don't follow the inputs?
                    rajivv_36

                    My bad. In the while loop in line 71 of adc.c file, the condition check is !status. Do while loop will run only once as the argument is TEC_ADC_WAIT_FOR_RESULT to the function IsEndConversion(). In that case, "attempts" variable will not have any impact.

                     

                    -Rajiv

                    • 7. Re: ADC values don't follow the inputs?
                      jogr_3357391

                      In a completely unanticipated turn of events, I _wasn't_ to blame. I tested one of the thermisters, and measured different voltages at different temperatures. It turned out that was the thermister behind the opamp, so that input was not valid. And the hardware engineer determined that the other thermister was not wired correctly. Now I get changing values when I vary the temperature at the thermisters.
                      Problem solved. John absolved.

                       

                      Thanks to all for reading, and thanks to Rajiv for replying. I do appreciate it.
                      John