Adc programming.

Thread Starter

prashanth20

Joined Dec 17, 2008
8
I have a thermocouple instrument with pic16f882 IC.
I dont know much about adc programming.
All i have learnt is, the millivolt i get is converted to counter.
The maximum counter in 10bit pic16f882 is 1024.

and i also dont know how to use lookup table.
Please guide me.

void adcvalue()
{
DelayUs(1);
GODONE = 1;
while(GODONE==1);
adh = ADRESH;
adl = ADRESL;
adh=adh<<8;
tval=adh|adl;

return tval;
}

THis is the function i have written to get value from adc.
how to convet this to the millvolt. I know how to display the value.
but i dont knwo how to design a formula to convert this counter to the value i wanted with the help of the look up table?

This is a R type thermocouple.
there are around 1760 values, should i put all the 1760 values into array and compare or is there any other way to do it


Please guide me
Thanks
Prashanth
 

t06afre

Joined May 11, 2009
5,934
Hi
Then doing AD conversion each bit will have bit weight equal to Vref/(2^n) there n is equal to number of bits.
As an example if I use 5 volt as Vref and 10 bit each bit will have a weight equal 5/(1024) or approx 4.88 mV. If I after conversion have a result equal to 0x2FA. The input voltage is 3.718 volt
 

Thread Starter

prashanth20

Joined Dec 17, 2008
8
Hi t06afre

Thanks for the reply.
but the values coming out of the sensor is not linear, so usage of 4.88 mV is not working and more over i have used OP07. which amplifies the value and send it to the PIC16f882 IC.

I tried this before, it is not working.
at 0 degree Celsius(from censor) it is showing 69 counter(not the converted value).

and at 1760 degree Celsius, it is showing around 289 counter.
how to change this counter to zero at zero degree cecius and 1024 at 1760 degree celcius??

Please guide me
Thanks
 

delmasli

Joined Sep 17, 2009
17
As far as I know thermocouples calibration line depends on cubic polynomials. A cubic polynomial is a polynomial of degree 3. It is better to read your thermocouple datasheet and write correct function in order to use arrays (1700pcs array). But you have to know that it is not so easy to amplify these kind of sensor's signal correctly. For this purpose specific products are being manufactured. For example Analog Devices produce J and K type thermocouple ICs named AD595 / AD595. These ICs make their own linearization and give amplified output. But this is still not enough. Also some techniques such as thermocouple signal filtering has to be done before amplifing the signal.
Read this thread:
http://forum.allaboutcircuits.com/showthread.php?t=27749

I have never used R type thermocouple but (it is strongly possible that) there could be special IC for R type thermocouples. You may look for that.


How to change this counter to zero at zero degree cecius and 1024 at 1760 degree celcius??

Please guide me
Thanks
If you insist on this tecnique, you need to write simple equation like y=ax+b. But I need to say that "amplifiing a themocouple signal by using standart Opamp, is not a proper way". y=ax+b function has to be used after correctly amplificated signal.
 
Last edited:
Top