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

PSoC™ 5, 3 & 1 Forum Discussions

DzNg_1446756
Level 3
Level 3
First like received First like given

I have a sensor that outputs a voltage between 0 and 3V.  When I use Delta Sigma, the reading from my PSoC is compared with a volt meter.  The result is not the same as the volt meter, it may be off by 5-10 mV some times, but I just want to prove the concept, and I'm just glad that it has some reading.

   

However, when I remove the sensor, the reading still says 200mV instead of zero.  What am I doing wrong?

   

Here is the code snippet of the sensor reading function:

   

 

   

void handleRead(uint8 *buf, uint8 len) {
    int16 adcResult = 0;
    int16 mVolts = 0;

   


    if(ADC_IsEndConversion(ADC_RETURN_STATUS) != 0) {
        adcResult = ADC_GetResult16();
        if (((int16)adcResult) < 0) {
            adcResult = 0u;
        } else if (((int16)adcResult) > 16383) {
            adcResult = 16383;
        }
        mVolts = ADC_CountsTo_mVolts(adcResult);
        printf("sensor read: %d\n", mVolts);
    }
    memcpy(buf, &mVolts, len);
}

0 Likes
6 Replies
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted
        Is ADC input left floating? What voltage it shows when it is shorted?   
0 Likes

The ADC input is configured to be one of the GPIO pins, which is connected to the input voltage of the sensor when present.

   

Should I short the GPIO pin to ground to see what voltage it reads?

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

The pin is high-z, this will allow for any voltage when left open. Set to a defined level between GND and Vdda. Use a porentiometer to check the ADC.

   

 

   

Bob

0 Likes
DzNg_1446756
Level 3
Level 3
First like received First like given

Do we need a potentiometer to measure the output voltage of a sensor?  How about a 10k resistor between the ADC pin and ground? 

0 Likes
Anonymous
Not applicable

No you don't need a potentiometer to measure the sensor output voltage. But in order to test the zero voltage when the sensor is removed the input must be connected to ground voltage, and in order to test the performance of the ADC a potentiometer is very useful.

   

A 10k between the ADC pin and ground will make the voltage 0 when the sensor is removed, but it will also load the sensor output a little, and lower the signal a fraction. Probably not a noticeable fraction unless your sensor is very precise and stable.

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

"Do we need a potentiometer to measure the output voltage of a sensor?" No, but you can simulate a sensor with a poti.

   

"How about a 10k resistor between the ADC pin and ground?" Will connect the pin to GND.

   

 

   

Bob

0 Likes