forked from SZV10X_Software/SZV103_FM33A0xxEV_SiZhu

周巍
2024-04-11 91ef77c00ed797b1048c5187f416e351e646a009
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
 
/******************************************************************************
 * 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);
}