I'm trying to get temperature readings from a thermocouple, using INA128 op.amp. connected to pic16f88. The problem is that although I get readings that seem to be valid, every now and then (10 to 20% of the reading, with irregular intervals) are erratic. The erronous readings are always smaller than the correct ones, typically about 1/4 of the real values (i.e. if I should get values around 400, I get every now and then values of about 100). The op.amp. is connected to the porta.2 pin.
My configuration is like this:
And the code that reads A/D looks like this:Code:OPTION_REG.7 = 0 'enable portb pullups TRISA = %00000100 'set porta pin 2 as inputs TRISB = %01110011 'set portb pins 2,3,7 as output OSCCON =%01101100 'set internal osc at 4 mhz w/freq stable OSCTUNE = 0 'internal osc. running at factory calibration CMCON = 7 'comparators off ANSEL = 4 'porta.2 AD-input, others digital ADCON0 = %01010000 ADCON1 = %10000000 PIE1 = 0 'disable all interrupts INTCON = 0 ' -"-
Is there something wrong in my configuration/code? Thanks!Code:readAD: 'Do the AD-conversion adcon0.0 = 1 'turn on AD-converter pauseus 20 ADCON0.2 = 1 'Start AD-conversion notdone: if ADCON0.2 = 1 then notdone 'wait for low on bit-2 of ADCON0, ' = conversion finished ADresult.highbyte = ADRESH 'move HIGH byte of result to ADresult ADresult.lowbyte = ADRESL 'move LOW byte of result to ADresult return




Bookmarks