Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Float to Int conversion of PT100 Polynomial

Status
Not open for further replies.

scorrpeio

Full Member level 5
Joined
Dec 26, 2006
Messages
286
Helped
10
Reputation
20
Reaction score
9
Trophy points
1,298
Activity points
3,496
Hello,

I am using PT100 sensor in my project to read temperature.
My requirement is to calculate the temperature value in the form XXX.X degree C.

The polynomial to be used is...

TEMP = -246.538 + 2.3753 R + 0.000886 R*R + 15342.296 R*R*R*R* 10^-13

The 'R' is what I calculate from ADC count. (R is already multiplied by 100 to bring it to integer format)

Now, I am using MSP430F5418A MCU and CCS4 compiler.

I have already got info in other threads on this webportal about the floats and problems associated with it. So, I am not interested in using float.

Now, I am thinking to convert the whole polynomial to the integer format first and calculate temperature value.
Then, convert the temp value to char string and insert the decimal point in the string and display it.

But,

I dont know, if I can implement the following integer converted polynomial in the CCS4.0

TEMP = -246538* 10^-3 + 23753 R * 10^-4 + 0000886 R*R *10^-6+ 15342296 R*R*R*R* 10^-13 * 10^-3

Can I use this polynomial without 10^-k factor and then finally insert the decimal point based on k value?
 

I am not interested in using float.
Then you can hardly avoid to get involved with binary fixed point numbers.

Decimal (10^k) factors are suitable for pencil and paper solutions but not well understood by C compilers. At the end of the day, you'll possibly come to the conclusion that float numbers are the simpler and less error-prone method.

The largest integer format supported by your compiler will be probably long int (32 Bit). So if you have an expression like R*R*R*R, multiply and binary shift (scaling with 2^n) has to be performed alternatingly to keep the 32 Bit number range. Possible of course, but no fun at all.
 
You can, if (say) you multiply each term by 10^6 and then calculate for TEMP. Your result will be a large value and you can insert the decimal point accordingly (i.e. divide the result down).
By the way, floating point can be ok if you have a fast processor and lots of memory, which it looks like your processor does.

EDIT: Sorry I didn't see the last post, but yes, you're likely to hit a 32-bit limit with some of the terms, so a math library may
be more appropriate (and then just use floating point).
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top