|
/******************************************************************************
|
* Copyright (C) 2014-2015 HangZhou SiZhu Co.,LTD.
|
*
|
*-----------------------------------------------------------------------------
|
* File: temperature.c
|
* Description: get temperature of now
|
* Author: Lishoujian (867693272@qq.com)
|
* Date: Jan 8, 2015
|
*****************************************************************************/
|
|
/* ----------------------- Platform includes --------------------------------*/
|
#include "temperature.h"
|
#include "adc.h"
|
#include "para.h"
|
#include "devicegpioinit.h"
|
#include "regdefine.h"
|
#include "ads1120.h"
|
|
|
float Get_temperature_v(float tep_vol);// 100 =>10.0 ¡æ
|
#define AD_REF_VOL 3000
|
#define RES_VALUE 100
|
#define VOL_OFFSET 42
|
#define AD_TEMPERATURE_CH 11
|
#define AD_CNT 40
|
#define Inputvol 3000
|
#define TEM_AD_MIN_DATA 500
|
#define TEM_AD_MAX_DATA 3500
|
|
|
/******************************************
|
* func: Get_temperature_volt
|
* desc: get average voltage from temperature sensor.
|
* input:
|
* output: none
|
* return: average voltage:eg 1000 means voltage equal to 1.000v
|
*****************************************/
|
float get_temperature(void)
|
{
|
// uint16 volt_ret;
|
float vol;
|
float tep;
|
|
|
|
vol = temperature_ad_value();//·µ»ØµÄÊÇVΪµ¥Î»
|
|
if((vol > 0.2)||(vol < 0.006))
|
{
|
return TEMP_ERROR_DATA;
|
}else
|
{
|
tep = Get_temperature_v(vol);
|
}
|
|
|
return tep;
|
|
}
|
|
/******************************************
|
* func: Get_temperature
|
* desc: transform the voltage of sampling to temperature
|
* input: tep_vol - the voltage of sampling
|
* output: none
|
* return: tep - (temperature * 10) of now
|
*****************************************/
|
|
float Get_temperature_v(float tep_vol)// 100 =>10.0 ¡æ
|
{
|
float tep; //resistance of PT1000,temperature
|
|
//µ÷ÕûζÈÊý¾Ý
|
tep = (float)tep_vol * system_para_control_run_g.temperature_para_k;
|
tep = tep + system_para_control_run_g.temperature_para_b;
|
|
|
return ( tep);
|
}
|
|