CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

RTD PT100
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Jim90



Joined: 27 Apr 2013
Posts: 55

View user's profile Send private message

RTD PT100
PostPosted: Wed Feb 05, 2014 5:41 pm     Reply with quote

I recently bought a thin film pt100 temperature sensor and i am trying to measure the temperature value.

I built a voltage divider (100ohm + RTD PT100) and in the middle of the two i connect the received value which is going to the microcontroller (measure the temperature value).

The code which i am using is presented below:
Code:

while(1)
{
         float value;
         value = read_adc();   
         printf("VALUE:%fl\n",value);
         delay_ms(1000);
}


My problem is that i receiving very high values. I don't understand what is going wrong ?
temtronic



Joined: 01 Jul 2010
Posts: 9225
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Feb 05, 2014 6:45 pm     Reply with quote

'very high values' is not a good description to go on.
Typical RTD PT100 devices are 100r@0*C, 138r@100*C, if we assume a Vref of the ADC section to be 5.000 ( PIC power supply), the range is 2.50 to 2.89 volts.

You should tell us the temperature of the sensor and the raw ADC bits.

Also be aware that actual wiring of the sensor, board layout, etc. have a very important part in accurate measurements. Also RTDs are NOT linear devices so you need to do some 'math' to get the best results.

http://www.picotech.com/applications/pt100.html is one quick random 'google' for more information that should be useful.
You don't tell us what PIC, which ADC setup (8 bit, 10 bit, ??), conversion rate, etc. All this is important to know....

hth
jay
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Thu Feb 06, 2014 5:15 am     Reply with quote

You don't tell us which way up your divider is wired.
I'm assuming RTD to GND, 100R to +5V.
Have you read the data sheet for the RTD?
If it's thin film it could be getting hot.
Give us more to go on.

Mike
Jim90



Joined: 27 Apr 2013
Posts: 55

View user's profile Send private message

RTD PT100
PostPosted: Thu Feb 06, 2014 7:19 am     Reply with quote

I use dspic33fj128gp802 with voltage Supply equal to 3.3V and ADC: 10 bits

I put a 200ohm resistor in series with rtp and in the middle is connected it to the adc input.(At one side of the resistor i connect a supply and at one side of the rtp i connect ground).

I know that i need to do some maths so to receive the correct value but i have little confusion what exactly i need to do.

I am waiting for your respond.
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Thu Feb 06, 2014 9:31 am     Reply with quote

Is this what your circuit looks like?
Code:
              100R           200R
 +3V3 _______WWWWW__________WWWWW______ Analogue I/P
                        |
                        |
                        |
 GND  _______WWWWW______|
              RTD

If it is, 10 bit ADC max reading is 1023.

So if ADC gives ADC_reading. Then calculate RTD resistance from:-
RTD/100 = ADC_reading/(1023-ADC_reading)

Which rearranges to:-
RTD = 100 * ADC_reading/(1023-ADC_reading)


For most RTDs, resistance is approximately proportion to absolute temperature.

So Absolute_Temperature = 273*(RTD/100)

OR in Celsius

Temperature_in_Celsius = Absolute_Temperature - 273
= 273*(RTD/100) - 273
= 273*(RTD/100 -1 )

Job done

Mike

PS If you work in tenths/hundreths of a degree you can use integers throughout and avoid fp maths.
Jim90



Joined: 27 Apr 2013
Posts: 55

View user's profile Send private message

RTD PT100
PostPosted: Thu Feb 06, 2014 12:15 pm     Reply with quote

My circuit is :

200R RTD
+3V3 _______WWWWW__________WWWWW______ GND
|
|
|
dspic33

What are the necessary calculations for the above circuit?
Jim90



Joined: 27 Apr 2013
Posts: 55

View user's profile Send private message

RTD PT100
PostPosted: Thu Feb 06, 2014 12:16 pm     Reply with quote

200R RTD
+3V3 _______WWWWW__________WWWWW______ GND
|
|
|
dspic33



Now is clear Smile . Sorry for the confusion.
temtronic



Joined: 01 Jul 2010
Posts: 9225
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Feb 06, 2014 12:29 pm     Reply with quote

basic OHMs law voltage divider

Vout=(rtd/(rtd+200)) * Vin

rtd=+-100r@0*c
vin=3.3

Of course you must measure vin (it won't be 3.3), rtd value varies according to temperature obviously.

Simple test is to freeze the sensor then let it warm up, measure ADC input and record ADC bits on a chart, say every 10 seconds.

hth
jay
Jim90



Joined: 27 Apr 2013
Posts: 55

View user's profile Send private message

RTD PT100
PostPosted: Tue Feb 11, 2014 5:03 pm     Reply with quote

I changed the circuit and I did it as Mike Walne presented.

My confusion is that the Mike Walne and the temtronic explained different ways to processing the input signal.


Can you make it more clear please?
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

Re: RTD PT100
PostPosted: Tue Feb 11, 2014 5:15 pm     Reply with quote

Jim90 wrote:
I changed the circuit and I did it as Mike Walne presented.

My confusion is that the Mike Walne and the temtronic explained different ways to processing the input signal.


Can you make it more clear please?

Without having seen a clear schematic I was guessing at your voltage divider circuit.
I assumed your rdt was in series with 100R and calculated accordingly.
I also assumed that you're using the 3V3 supply as Vref for the ADC.

temtronic's maths is equivalent to mine but using the 200R which you later told us about.

In order to help you further we need to know exactly what you are doing.

Mike
Jim90



Joined: 27 Apr 2013
Posts: 55

View user's profile Send private message

RTD PT100
PostPosted: Sun Feb 16, 2014 3:45 pm     Reply with quote

I came back to continue the project. I use the following circuit:

http://obrazki.elektroda.pl/1446047100_1392586975_thumb.jpg

The Vout = (RTD*VCC)/(RTD+R)
where VCC=3.3v and R=10K


According the following link :


http://www.michshur.co.il/image/users/190375/ftp/my_files/Files/TD_TV_PT1A.pdf?id=8609087


for temperature : -10 c -->R=96.09 and with the use of the Vout equation V=2,98
for temperature: 110c -->R=-->V=3,083

for a 12 bits adc (1023) 120/1023 = 0,111.


what is the next step???
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

Re: RTD PT100
PostPosted: Sun Feb 16, 2014 6:01 pm     Reply with quote

Jim90 wrote:
I came back to continue the project. I use the following circuit:

The Vout = (RTD*VCC)/(RTD+R)
where VCC=3.3v and R=10K

According the following link :

for temperature : -10 c -->R=96.09 and with the use of the Vout equation V=2,98
for temperature: 110c -->R=-->V=3,083

There's something wrong with your calculator.

Mike
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Sun Feb 16, 2014 8:42 pm     Reply with quote

i suggest using external analog processing of the sensor data, and
an external precision 2.5 volt ADC ref. like the lm4040, since if your last post were correct, it shows you are trying to map a 120 degree span into 127 bits. with a reasonable assumed uncertainty of any single ADC count,
of +/-1 bit, you won't resolve any less than 4 degrees on average.

unless your pic power supply is providing a highly accurate and compliant 3.3v, your accuracy is also never going to make you happy either.


your problem is in circuit design, or lack of.
Direct reading an RTD, unless the temp range is extremely wide, is tough with only 10 to 12 bits of conversion,..l..

analog processing is the cheaper way to get better resolution, rather than using a lot more expensive bits of external ADC to achieve the same ends.
Jim90



Joined: 27 Apr 2013
Posts: 55

View user's profile Send private message

RTD PT100
PostPosted: Mon Feb 17, 2014 12:44 pm     Reply with quote

You are right Mike Walne,

the values are :

for temperature : -10 c -->R=96.09 and with the use of the Vout equation V=0.031
for temperature: 110c --->V=0.046.


asmboy i don't want to use an external adc.

these values look like ok?


(to be honest i expect to receive something like 0.3 instead of 0.03 )
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Mon Feb 17, 2014 1:39 pm     Reply with quote

you might google this phase and look at the images:

rtd schematic

with a 10bit adc - you are simply not going to resolve the temperature range you hope for, or with a noise level in the readings you get, to want to brag about it . at least not with the simple circuit you hope to use.

to work well with so few bits you need a constant current source for the RTD and analog gain. Its just math.........
over and out Very Happy Very Happy Very Happy

BTW: (1023) 120/1023 = 0,111.

actually there is general agreement on this forum anyway,
that 1024 is 10 bits worth not 12

i think 1024 is 12 bits only on ATMEL MCUS Laughing Laughing Laughing Laughing
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group