Quantcast
Channel: Forums - Recent Threads
Viewing all articles
Browse latest Browse all 262198

Urgent help in Interpolation Programming

$
0
0

HI,

I was writing a code for silicon diode temperature sensor , for sensor to work properly we have to perform interpolation , that interpolation technique is implemented in the embedded C code, the code is mentioned below , the problem is , i'm not getting any  output on the LCD, and there is a warning in the IAR, it says like this : implicit conversion from floating point to integer. and when we exe the program , on debug blog of IAR i'm getting a message like : Program exit reached.

These are the interpolation functions: 


long float test_one (long float );
long float test_two (long float );
long float test_three (long float);
long float test_four (long float );

The temperature range of the sensor is divided into four parts. for further ref i'm including the PDF file pls have look.

(Please visit the site to view this file)

Code:


#include <msp430g2452.h>
#include "adc_lcd16.h"


long float test_one (long float );
long float test_two (long float );
long float test_three (long float);
long float test_four (long float );

void main(void)
{

long double temp1;
long double vol;
long double temp;

WDTCTL = WDTPW + WDTHOLD;
P1DIR = 0xFF;
P1OUT = 0x00;
lcdinit();


if((vol >= 1.68786) && (vol < 1.36809))
{
temp1=test_one(vol);
temp=temp1;
gotoXy(0,0);
integerToLcd(temp);
}

else if(( vol >= 1.36809) && (vol < 1.130305))
{
temp1=test_two(vol);
temp=temp1;
integerToLcd(temp);
}

else if ( (vol >= 1.130305) && (vol < 0.97550))
{
temp1=test_three(vol);
temp=temp1;
integerToLcd(temp);
}

else if ( (vol >= 0.97550 )&& (vol < 0.09062))
{
temp1=test_four(vol);
temp=temp1;
integerToLcd(temp);
}



}

long float test_one(long float z)
{
int i;
long float zl,zu;
long float t,x;
long double tc[10];
const long double y[10]={7.556358,-5.917261,0.237238,-0.334636,-0.058642,-0.019929,-0.020715,-0.014814,-0.008789,-0.008554};
zl=1.32412;
zu=1.69812;
x=((z-zl)-(zu-z))/(zu-zl);
tc[0]=1;
tc[1]=x;
t=y[0]+y[1]*x;

for(i=2;i<=11;i++)
{
tc[i]=2*x*tc[i-1]-tc[i-2];
t=t+y[i]*tc[i];
}
return t;
}

long float test_two(long float z)
{
int i;
long float zl,zu;
long float t,x;
long double tc[11];
const long double y[11]={17.304227,-7.894688,0.453442, 0.002243,0.158036,-0.193093,0.155717,-0.085185,0.078550,-0.018312,0.039255};
zl= 1.11732;
zu= 1.42013;
x=((z-zl)-(zu-z))/(zu-zl);
tc[0]=1;
tc[1]=x;
t=y[0]+y[1]*x;

for(i=2;i<=11;i++)
{
tc[i]=2*x*tc[i-1]-tc[i-2];
t=t+y[i]*tc[i];
}
return t;
}

long float test_three(long float z)
{
int i;
long float zl,zu;
long float t,x;
long double tc[12];
const long double y[12]= {71.818025,-53.799888,1.669931,2.314228,1.566635,0.723026,-0.149503,0.046876,-0.388555,0.056889,-0.116823,0.058580};
zl= 0.923174;
zu= 1.13935;
x=((z-zl)-(zu-z))/(zu-zl);
tc[0]=1;
tc[1]=x;
t=y[0]+y[1]*x;

for(i=2;i<=11;i++)
{
tc[i]=2*x*tc[i-1]-tc[i-2];
t=t+y[i]*tc[i];
}
return t;
}

long float test_four(long float z)
{
int i;
long float zl,zu;
long float t,x;
long double tc[11];
const long double y[11]={287.756797,-194.144823,-3.837903,-1.318325,-0.109120,-0.393265,0.146911,-0.111192,0.028877,-0.029286,0.015619};
zl=0.079767;
zu=0.999614;
x=((z-zl)-(zu-z))/(zu-zl);
tc[0]=1;
tc[1]=x;
t=y[0]+y[1]*x;

for(i=2;i<=11;i++)
{
tc[i]=2*x*tc[i-1]-tc[i-2];
t=t+y[i]*tc[i];
}
return t;
}

Pls help in this as i'm runnig out of time. Expecting a speedy and positive reply .

Thanking you 


Viewing all articles
Browse latest Browse all 262198

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>