Issue with ADC

Discussion in 'Embedded Systems and Microcontrollers' started by markdem, Aug 21, 2016.

  1. markdem

    Thread Starter Member

    Jul 31, 2013
    73
    38
    Hi All,

    I have having quite a strange issue that I simply can't get my head around.

    I am measuring 4 MCP9700 temperature sensors (same as a TMP35) with a PIC16F877A. (I know it is old, but I am tiring to use up some stock on simple jobs like this).
    The following is the output I am getting.
    First number is the channel, the next numbers are the raw ADC reading (using 10 bits).

    0 166 164 165 166 166 164 165 165 165 166 166 165 165 166 165 165 165 166 166 165 165 166 166 165 166 164 165 166 166 165 165 166 164 165
    min:164 max:166 delta:2 avg:330 temp:17.3

    1 170 170 170 169 169 170 170 169 171 170 169 169 171 170 169 169 170 170 170 170 169 169 169 169 169 171 169 171 171 170 170 170 170 170
    min:169 max:171 delta:2 avg:339 temp:18.9

    2 165 166 165 167 167 166 165 165 165 167 166 166 166 165 165 165 167 166 166 166 166 165 165 167 167 166 166 166 166 165 165 167 166 166
    min:165 max:167 delta:2 avg:331 temp:17.3

    3 180 182 188 192 190 197 197 201 203 207 214 218 221 225 227 230 235 239 248 250 254 260 259 262 264 262 265 265 266 266 268 269 271 274
    min:180 max:274 delta:94 avg:468 temp:44.8

    As you may notice, first 3 are fine, in fact I think my design skills are getting better judging by the numbers :)
    It is the last one that is a issue. It is always high and wild.
    The other thing I notice is that the readings go up almost each time in the 34 times I read it. It will always start low, then go up. I have also tried to just keep reading AN4 (ch3) and the ADC reading will go up to about 500 before settling down.
    I have a 4.094 VREF so that would mean the voltage would need to be about 2 volts. Looking at the pin with my scope, there is a little noise, but nothing that high.

    I have tried to swap sensors around, problem stays on ch3.
    I have tried swapping PICs, same thing.
    If I measure the voltage, it looks about the same as the others at about 650mv.

    Code is the same for all 4 sensors in a for loop so I can't see how that would have anything to do with it. Infact, even if I hardcode each loop to only read AN4, the reading coming back are always high like above.

    I would post my code, but I am not sure how to keep the formatting.

    Can anyone think of something I am not?

    Thanks
     
  2. markdem

    Thread Starter Member

    Jul 31, 2013
    73
    38
    Ignore above, found issue with connection.

    Thanks anyway.
     
Loading...