Разработка, производство и продажа радиоэлектронной аппаратуры
|
Требуется программист в Зеленограде - обработка данных с датчиков; ColdFire; 40 тыс.
e-mail: jobsmp@pochta.ru
|
Ребята, кто може помочь сделать десятые градусы на датчике KTY ? :) зарание благодарен
Отправлено
nicekit 15 мая 2009, г. 11:52
Вот куски кода которые как я понимаю нужны:
flash unsigned int PRTD[] = {0, 460, 494, 540, 584, 624, 679, 732, 774, 824, 872, 921, 970, 1034, 1090, 1146,
1200, 1269, 1338, 1404, 1477, 1553, 1632, 1713, 1800, 1891, 1987, 2090};
flash unsigned int PRTDcoef[] = {0, 30, 50, 50, 50, 50, 50, 50, 50, 50, 50, 52, 53, 54, 55,
57, 60, 63, 67, 71, 76, 82, 89, 96, 105, 114, 124, 87};
unsigned int Ohm2mDegree (unsigned int R_PRTD)
{
//Used to convert resistance in Ohms to Degrees of Celsius, don't change
unsigned int temp16;
unsigned char i=1;
if (R_PRTD > 2166) R_PRTD = 2165;
while ((i<27)&&(R_PRTD > PRTD[i])) i++;
temp16=(i-2)*10+((R_PRTD - PRTD[i-1])*10/PRTDcoef[i-1]);
return temp16;
}
void convert_temp(unsigned char temper)
{
//Convert binary temperature to BCD, don't change
st[3]=temper/100;
st[4]=(temper%100)/10;
st[5]=temper%10;
}
unsigned char get_temp(void)
{
//Get temperature
unsigned long data;
unsigned char temp0;
data=read_adc(0); //Get binary value
if ((data>175)&&(data<888)) //Deny voltages which are out of bounds
{
//Convert binary value from ADC to Ohms
data=data*2500/1024; //Ohm=(data/1024)*5V/2mA
data=data%2500;
data=Ohm2mDegree(data);
temp0=data%256;
} else temp0=0;
return temp0;
}
у кого какие мысли есть ?
Составить ответ | Вернуться на конференцию.
Ответы