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.

solving polynomial in mcu

Status
Not open for further replies.

shaz

Member level 4
Member level 4
Joined
Mar 9, 2005
Messages
70
Helped
10
Reputation
20
Reaction score
6
Trophy points
1,288
Activity points
1,995
hi, for thermocouple linearization i learned i need to use polynomials which can give me correct results, for example, in case of R-TYPE thermocouple for temperature lying between 250-1200 Celcius,

Temp.= 1.334584505E+01 + 1.472644573E+02 x V + -1.844024844E+01 x V^2 + 4.031129726E+00 x V^3 + -6.249428360E-01 x V^4 + 6.468412046E-02 x V^5 + -4.458750426E-03 x V^6 + 1.994710149E-04 x V^7 + -5.313401790E-06 x V^8 + 6.481976217E-08 x V^9 + 0.000000000E+00 x V^10

where V is thermocouple EMF voltage in mV

lets say voltage read is V=6.157mV, then temperature is, (using above equation)

Temp.= 1.334584505E+01 + 1.472644573E+02 x 6.157 + -1.844024844E+01 x 6.157^2 + 4.031129726E+00 x 6.157^3 + -6.249428360E-01 x 6.157^4 + 6.468412046E-02 x 6.157^5 + -4.458750426E-03 x 6.157^6 + 1.994710149E-04 x 6.157^7 + -5.313401790E-06 x 6.157^8 + 6.481976217E-08 x 6.157^9 + 0.000000000E+00 x 6.157^10

=> Temp = 649.9 'Celcius ~ 650 'Celcius

(for refrence i'm attaching R-type thermocouple output chart, linearization coefficents are also given in it, at bottom)

friends please advise me how can i solve this polynomial in C programming of micro-controller because using assembly it seems to be something like impossible. I can use Hi-tech C (if i plan to use PIC micro-controller PIC16F877) or Keil C51 (if i plan to use 8051 core micro-controller, like 89c52), which one do u advise.

i'll honour any help, any suggestion you advise.

thanks
 

Re: solviing polynomial in mcu

Pre-compute a table for all possible ADC readings you have, for example:

8bit ADC will give a 256byte table.
 

future thanks, but that wont help cause i'm using different types of thermocouples and R-type (which i discribed above itself goes upto 1768 degree celcilus which can only be handled by a 12-bit adc, (consediring resoultion=1) so feeding so many values i don't think so it's possible.
 

Please see Application note from MicroConverter from Analog Device. They have source code and document in MCS-51.
 

BabyTiger can u please provide the link
 

Search google for :
numerical method to solve polynom
 

shaz said:
future thanks, but that wont help cause i'm using different types of thermocouples and R-type (which i discribed above itself goes upto 1768 degree celcilus which can only be handled by a 12-bit adc, (consediring resoultion=1) so feeding so many values i don't think so it's possible.

Shaz - Use double table for lookup. Use the lower ADC value on one table and upper ADC value on another. Merge the result data and you have a linearised 12/16 bits value. It works :)

Off course, you will need a large amount of memory to store all the values. Either use the internal program memory to store or use a SEEPROM to store the values.

Cheers

Ravi

Added after 4 hours 11 minutes:

Here is a double lookup table method to linearise or convert 12/16 bits to another set of 12/16 bits.

Cheers

Ravi
 
shaz, i appologise for mistake in my previous post . If you know the polynom, you can write a simple C code to implement .
Use double types when coding formula calculation.
Do these compilers for mentioned micros support double ? Could you check that ? If not - try float, and test got values against double types as :

Just use conventional compiler for PC and write polynom formula with double and float , then test difference for each input-output pair values and note maximum difference. If it is acceptable - go ahead with float.
 
Hi

You can check on the net for Cordic.
Cordic is a method to implement complex math with just Add and shift.


It may help

Salam
Hossam Alzomor
www.i-g.org
 
will a 8 Bit MCU be sufficiant for this kind of Math or you require a 16 Bit version.
 
rauol said:
will a 8 Bit MCU be sufficiant for this kind of Math or you require a 16 Bit version.
with fingers we can count up to 10 and for counting 20 what we will do? count once again or borrow some one's fingers?
 
Hello,
you can simplify the problem by making a linearization of your high order polynomials by using lower order polynomials on smaller intervalls.

I send here a matlab program linc5 that make linearization of sensor data into polynomials. You can input the polynoimial order and the max accepted approximation error. There are two examples file, tc_b.dat for a thermocouple type B and pt46.dat for a platinum 46 ohm sensor.

I hope this will help you.
 
There are some direct functions in hitech C compiler. As far as I remember they are hardly optimized and I thik that their computtion time isn't so long


Look at this,...
 
To be honest, pre-computing is the way to go, otherwise you have include a maths library to handle these floating point numbers. a 1Mbit serial flash only costs a dollar or two, and can store a whole range of pre-computed tables, and will only use a couple of I/O pins from your microcontroller. Then you can dynamically select the one closest to your needs.

Another way is to try and scale your numbers, so that you can perform integer arithmetic - not always possible, depending on the complexity of the calculations.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top