📄 temp.c
字号:
#include "STC12C5410AD.h"
#include "app.h"
#include <string.h>
#include <stdio.h>
#include <INTRINS.H>
void temp_done(void);
unsigned char findindex(float temp);
//extern void CPLD_LED(unsigned char buffer);
//extern void CPLD_LED8(unsigned char buffer);
extern void CPLD_OUT(unsigned char buffer,unsigned char led);
extern struct _LED
{
unsigned char status ; // LED状态
unsigned char temp ; // 温度值
}LED;
code const float temptable[] =
{
//-20.0
489.0000,
//-19.0
462.4000,
//-18.0
437.2000,
//-17.0
413.5000,
//-16.0
391.1000,
//-15.0
370.0000,
//-14.0
349.9000,
//-13.0
331.1000,
//-12.0
313.3000,
//-11.0
296.5000,
//-10.0
280.6000,
//-9.0
265.8000,
//-8.0
251.7000,
//-7.0
238.5000,
//-6.0
226.1000,
//-5.0
214.4000,
//-4.0
203.3000,
//-3.0
192.9000,
//-2.0
183.1000,
//-1.0
173.8000,
// 0.0
164.9100,
// 1.0
156.6282,
// 2.0
148.8133,
// 3.0
141.4360,
// 4.0
134.4695,
// 5.0
127.8884,
// 6.0
121.6692,
// 7.0
115.7899,
// 8.0
110.2301,
// 9.0
104.9705,
// 10.0
99.9932,
// 11.0
95.2816,
// 12.0
90.8198,
// 13.0
86.5933,
// 14.0
82.5884,
// 15.0
78.7922,
// 16.0
75.1927,
// 17.0
71.7786,
// 18.0
68.5393,
// 19.0
65.4650,
// 20.0
62.5463,
// 21.0
59.7745,
// 22.0
57.1414,
// 23.0
54.6394,
// 24.0
52.2612,
// 25.0
50.0000,
// 26.0
47.8494,
// 27.0
45.8035,
// 28.0
43.8566,
// 29.0
42.0034,
// 30.0
40.2388,
// 31.0
38.5582,
// 32.0
36.9571,
// 33.0
35.4314,
// 34.0
33.9771,
// 35.0
32.5905,
// 36.0
31.2682,
// 37.0
30.0067,
// 38.0
28.8030,
// 39.0
27.6541,
// 40.0
26.5574,
// 41.0
25.5100,
// 42.0
24.5096,
// 43.0
23.5538,
// 44.0
22.6405,
// 45.0
21.7674,
// 46.0
20.9327,
// 47.0
20.1344,
// 48.0
19.3708,
// 49.0
18.6402,
// 50.0
17.9410,
// 51.0
17.2717,
// 52.0
16.6309,
// 53.0
16.0173,
// 54.0
15.4294,
// 55.0
14.8662,
// 56.0
14.3265,
// 57.0
13.8092,
// 58.0
13.3132,
// 59.0
12.8376,
// 60.0
12.3815,
// 61.0
11.9439,
// 62.0
11.5239,
// 63.0
11.1209,
// 64.0
10.7341,
// 65.0
10.3626,
// 66.0
10.0059,
// 67.0
9.6632,
//68.0
9.3341,
//69.0
9.0177,
//70.0
8.7137,
//71.0
8.4215,
//72.0
8.1405,
//73.0
7.8703,
//74.0
7.6104,
//75.0
7.3603,
//76.0
7.1197,
//77.0
6.8882,
//78.0
6.6653,
//79.0
6.4507,
//80.0
6.2441,
//81.0
6.0451,
//82.0
5.8534,
//83.0
5.6687,
//84.0
5.4907,
//85.0
5.3192,
//86.0
5.1539,
//87.0
4.9945,
//88.0
4.8407,
//89.0
4.6925,
//90.0
4.5495,
//91.0
4.4115,
//92.0
4.2784,
//93.0
4.1499,
//94.0
4.0259,
//95.0
3.9062,
//96.0
3.7906,
//97.0
3.6790,
//98.0
3.5711,
//99.0
3.4670,
//100.0
3.3663,
//101.0
3.2691,
//102.0
3.1751
};
extern unsigned char CMD_Status ; // 按键状态
extern IndexPamDef IndexPam; // 系统参数
extern unsigned int Current_Montor_Count;
extern unsigned int CurrentSpeed;
unsigned char songliaotime =0; // 送料电机时间控制
extern unsigned int GetSetInitCount(unsigned int Speed);
void temp_done(void)
{
unsigned int tempvalue;
float tempdata;
int a = 0;
float *p = temptable;
ADC_CONTR = ADC_Channel_0;
ADC_CONTR |= 0x08; // 启动AD转换
// 是否转换结束
while(!(ADC_CONTR&0x10));
//清转换和标志位,停止转换
ADC_CONTR &= 0xef;
//保存转化结果
tempvalue = (ADC_DATA<<2) | (ADC_LOW2&0x3);
// 计算得到电阻值
tempdata=(float)(50*tempvalue)/((float)(1024-tempvalue));
// 查表
while(tempdata<=*p)
{
p++;
a++;
}
// 减去负的20度
LED.temp =a - 20;
CPLD_OUT(LED.temp,LED.status);
if( (CMD_Status == 0x08) && ( (LED.status &FIREING) == FIREING) )
{
if(LED.temp>IndexPam.maxtemp)
{
Current_Montor_Count = GetSetInitCount(IndexPam.minspeed);
CurrentSpeed = IndexPam.minspeed;
if(songliaotime==0) // 循环结束
{
songliaotime ++;
MONTOR = 1;
LED.status |=SMALLFIRE;
LED.status &=BIGFIREOFF;
LED.status |=SONGLIAO;
CPLD_OUT(LED.temp,LED.status);
}
}
if( LED.temp<(IndexPam.maxtemp-IndexPam.mintemp) )
{
Current_Montor_Count = GetSetInitCount(IndexPam.maxspeed);
CurrentSpeed = IndexPam.maxspeed;
// // 进入燃烧状态时,送料循环
if(songliaotime==0) // 循环结束
{
songliaotime ++;
MONTOR = 1;
LED.status |=BIGFIRE;
LED.status &=SMALLFIREOFF;
LED.status |=SONGLIAO;
CPLD_OUT(LED.temp,LED.status);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -