更新 RTD驱动部分数值计算修正
This commit is contained in:
parent
ea8c9b7b42
commit
0d72859d19
|
@ -274,6 +274,12 @@ float32 tcmv2temp(SIG_FUNCTIONS_TYPE type, float32 mv);
|
|||
//数据转换,将需要模拟的温度值℃转化为热电偶对应的mv
|
||||
float32 temp2tcmv(SIG_FUNCTIONS_TYPE type, float32 temp);
|
||||
|
||||
//数据转换,热电阻阻值 Ω 转化为温度 ℃
|
||||
float32 ohm2temp(float32 ohm);
|
||||
|
||||
//数据转换,温度 ℃ 转化为热电阻阻值 Ω
|
||||
float32 temp2ohm(float32 temp);
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -41,37 +41,93 @@
|
|||
|
||||
//my address
|
||||
//{
|
||||
//0x7D0 - 0x7E0,标记后写入0xAAAA(连续16位“1”“0”交替)
|
||||
#define DEVICE_CHECK 0x0007D0
|
||||
#define EE_START_ADDR 0x000000
|
||||
#define EE_INTERVAL 16
|
||||
|
||||
//电压V上限,tag:0
|
||||
#define VOL_V_UP_ADDR EE_START_ADDR
|
||||
|
||||
//电压V下限,tag:0
|
||||
#define VOL_V_LOW_ADDR (VOL_V_UP_ADDR + EE_INTERVAL)
|
||||
|
||||
//电压mV上限,tag:0
|
||||
#define VOL_MV_UP_ADDR (VOL_V_LOW_ADDR + EE_INTERVAL)
|
||||
|
||||
//电压mV下限,tag:0
|
||||
#define VOL_MV_LOW_ADDR (VOL_MV_UP_ADDR + EE_INTERVAL)
|
||||
|
||||
//电流上限,tag:1
|
||||
#define CUR_UP_ADDR (VOL_MV_LOW_ADDR + EE_INTERVAL)
|
||||
|
||||
//电流下限,tag:1
|
||||
#define CUR_LOW_ADDR (CUR_UP_ADDR + EE_INTERVAL)
|
||||
|
||||
//电阻上限,tag:2
|
||||
#define RES_UP_ADDR (CUR_LOW_ADDR + EE_INTERVAL)
|
||||
|
||||
//电阻下限,tag:2
|
||||
#define RES_LOW_ADDR (RES_UP_ADDR + EE_INTERVAL)
|
||||
|
||||
//频率上限,tag:3
|
||||
#define FRE_UP_ADDR (RES_LOW_ADDR + EE_INTERVAL)
|
||||
|
||||
//频率下限,tag:3
|
||||
#define FRE_LOW_ADDR (FRE_UP_ADDR + EE_INTERVAL)
|
||||
|
||||
//TC_K上限,tag:4
|
||||
#define TC_K_UP_ADDR (FRE_LOW_ADDR + EE_INTERVAL)
|
||||
|
||||
//TC_K下限,tag:4
|
||||
#define TC_K_LOW_ADDR (TC_K_UP_ADDR + EE_INTERVAL)
|
||||
|
||||
//TC_S上限,tag:5
|
||||
#define TC_S_UP_ADDR (TC_K_LOW_ADDR + EE_INTERVAL)
|
||||
|
||||
//TC_S下限,tag:5
|
||||
#define TC_S_LOW_ADDR (TC_S_UP_ADDR + EE_INTERVAL)
|
||||
|
||||
//TC_N上限,tag:6
|
||||
#define TC_N_UP_ADDR (TC_S_LOW_ADDR + EE_INTERVAL)
|
||||
|
||||
//TC_N下限,tag:6
|
||||
#define TC_N_LOW_ADDR (TC_N_UP_ADDR + EE_INTERVAL)
|
||||
|
||||
//TC_B上限,tag:7
|
||||
#define TC_B_UP_ADDR (TC_N_LOW_ADDR + EE_INTERVAL)
|
||||
|
||||
//TC_B下限,tag:7
|
||||
#define TC_B_LOW_ADDR (TC_B_UP_ADDR + EE_INTERVAL)
|
||||
|
||||
//TC_E上限,tag:8
|
||||
#define TC_E_UP_ADDR (TC_B_LOW_ADDR + EE_INTERVAL)
|
||||
|
||||
//TC_E下限,tag:8
|
||||
#define TC_E_LOW_ADDR (TC_E_UP_ADDR + EE_INTERVAL)
|
||||
|
||||
//TC_J上限,tag:9
|
||||
#define TC_J_UP_ADDR (TC_E_LOW_ADDR + EE_INTERVAL)
|
||||
|
||||
//TC_J下限,tag:9
|
||||
#define TC_J_LOW_ADDR (TC_J_UP_ADDR + EE_INTERVAL)
|
||||
|
||||
//TC_R上限,tag:10
|
||||
#define TC_R_UP_ADDR (TC_J_LOW_ADDR + EE_INTERVAL)
|
||||
|
||||
//TC_R下限,tag:10
|
||||
#define TC_R_LOW_ADDR (TC_R_UP_ADDR + EE_INTERVAL)
|
||||
|
||||
//TC_T上限,tag:11
|
||||
#define TC_T_UP_ADDR (TC_R_LOW_ADDR + EE_INTERVAL)
|
||||
|
||||
//TC_T下限,tag:11
|
||||
#define TC_T_LOW_ADDR (TC_T_UP_ADDR + EE_INTERVAL)
|
||||
|
||||
//RTD上限,tag:12
|
||||
#define RTD_UP_ADDR (TC_T_LOW_ADDR + EE_INTERVAL)
|
||||
|
||||
//RTD下限,tag:12
|
||||
#define RTD_LOW_ADDR (RTD_UP_ADDR + EE_INTERVAL)
|
||||
//}
|
||||
|
||||
|
@ -85,7 +141,7 @@ uint8_t eeprom_spi_readbyte(void);
|
|||
void eeprom_writedata(int32_t addr_long, uint8_t txd);
|
||||
uint8_t eeprom_readdata(int32_t addr_long);
|
||||
|
||||
//存储参数
|
||||
//存储参数,全部
|
||||
void eeprom_datasave(void);
|
||||
|
||||
//开机上电后读取参数
|
||||
|
@ -94,6 +150,8 @@ void eeprom_dataread(void);
|
|||
//判断EEPROM内是否已存在数据
|
||||
uint8_t eeprom_device_check(void);
|
||||
|
||||
void eeprom_datasave_single(uint8_t tag);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -37,6 +37,12 @@ static float32 TC_TABLE_TEMP[8][11] =
|
|||
{-270.0, -203.0, -136.0, -69.0, -2.0, 65.0, 132.0, 199.0, 266.0, 333.0, 400.0}
|
||||
};
|
||||
|
||||
//热电阻真值表,温度℃
|
||||
static float32 RTD_TABLE_TEMP[11] = {-200, -114, -28, 58, 144, 230, 316, 402, 488, 574, 660};
|
||||
|
||||
//热电阻真值表,电阻Ω
|
||||
static float32 RTD_TABLE_OHM[11] = {18.52, 54.97, 89.01, 122.47, 155.08, 186.84, 217.74, 247.78, 276.97, 305.31, 332.79};
|
||||
|
||||
//热电偶数据初始化
|
||||
void TC_init(void)
|
||||
{
|
||||
|
@ -135,8 +141,8 @@ void physical_quantity_init(void)
|
|||
|
||||
RTD.tag = SIG_RTD;
|
||||
RTD.typ = RTD_DC;
|
||||
RTD.low = -200;
|
||||
RTD.up = 660;
|
||||
RTD.low = RTD_TABLE_TEMP[0];
|
||||
RTD.up = RTD_TABLE_TEMP[10];
|
||||
RTD.pv = 0;
|
||||
}
|
||||
|
||||
|
@ -315,46 +321,55 @@ void sig_channel_select(uint8_t io, SIG_FUNCTIONS_TYPE type)
|
|||
|
||||
case TC_K:
|
||||
{
|
||||
mux_signal.channel = CH1_OUT_VOL_MV;
|
||||
}
|
||||
break;
|
||||
|
||||
case TC_S:
|
||||
{
|
||||
mux_signal.channel = CH1_OUT_VOL_MV;
|
||||
}
|
||||
break;
|
||||
|
||||
case TC_N:
|
||||
{
|
||||
mux_signal.channel = CH1_OUT_VOL_MV;
|
||||
}
|
||||
break;
|
||||
|
||||
case TC_B:
|
||||
{
|
||||
mux_signal.channel = CH1_OUT_VOL_MV;
|
||||
}
|
||||
break;
|
||||
|
||||
case TC_E:
|
||||
{
|
||||
mux_signal.channel = CH1_OUT_VOL_MV;
|
||||
}
|
||||
break;
|
||||
|
||||
case TC_J:
|
||||
{
|
||||
mux_signal.channel = CH1_OUT_VOL_MV;
|
||||
}
|
||||
break;
|
||||
|
||||
case TC_R:
|
||||
{
|
||||
mux_signal.channel = CH1_OUT_VOL_MV;
|
||||
}
|
||||
break;
|
||||
|
||||
case TC_T:
|
||||
{
|
||||
mux_signal.channel = CH1_OUT_VOL_MV;
|
||||
}
|
||||
break;
|
||||
|
||||
case RTD_DC:
|
||||
{
|
||||
mux_signal.channel = CH4_OUT_RES;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -422,6 +437,37 @@ float32 tcmv2temp(SIG_FUNCTIONS_TYPE type, float32 mv)
|
|||
return -999;
|
||||
}
|
||||
|
||||
//数据转换,将需要模拟的温度值℃转化为热电偶对应的mv
|
||||
float32 temp2tcmv(SIG_FUNCTIONS_TYPE type, float32 temp)
|
||||
{
|
||||
float32 result_mv = 0;
|
||||
uint8_t typ = 0, i = 0;
|
||||
typ = (uint8_t)type;
|
||||
typ -= 5; //[5,12]->[0,7]
|
||||
|
||||
float32 mv_left = 0, mv_right = 0;
|
||||
float32 temp_left = 0, temp_right = 0;
|
||||
|
||||
for(i = 0; i < 10; i++)
|
||||
{
|
||||
if( ( TC_TABLE_TEMP[typ][i] <= temp )&&( temp < TC_TABLE_TEMP[typ][i + 1] ) )
|
||||
{
|
||||
mv_left = TC_TABLE_MV[typ][i];
|
||||
mv_right = TC_TABLE_MV[typ][i + 1];
|
||||
temp_left = TC_TABLE_TEMP[typ][i];
|
||||
temp_right = TC_TABLE_TEMP[typ][i + 1];
|
||||
|
||||
result_mv = mv_left + ( mv_right - mv_left )*\
|
||||
( temp - temp_left )/( temp_right - temp_left);
|
||||
|
||||
return result_mv;
|
||||
}
|
||||
}
|
||||
|
||||
//ERROR
|
||||
return -999;
|
||||
}
|
||||
|
||||
//数据转换,mux_signal.pv -> real_value
|
||||
//float32 m2r_test_in = 0, m2r_test_out = 0;
|
||||
float32 mux2real(float32 mux_pv)
|
||||
|
@ -546,7 +592,7 @@ float32 mux2real(float32 mux_pv)
|
|||
{
|
||||
case RTD_DC:
|
||||
{
|
||||
result = mux_pv;
|
||||
result = ohm2temp(mux_pv);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -564,36 +610,7 @@ float32 mux2real(float32 mux_pv)
|
|||
}
|
||||
|
||||
|
||||
//数据转换,将需要模拟的温度值℃转化为热电偶对应的mv
|
||||
float32 temp2tcmv(SIG_FUNCTIONS_TYPE type, float32 temp)
|
||||
{
|
||||
float32 result_mv = 0;
|
||||
uint8_t typ = 0, i = 0;
|
||||
typ = (uint8_t)type;
|
||||
typ -= 5; //[5,12]->[0,7]
|
||||
|
||||
float32 mv_left = 0, mv_right = 0;
|
||||
float32 temp_left = 0, temp_right = 0;
|
||||
|
||||
for(i = 0; i < 10; i++)
|
||||
{
|
||||
if( ( TC_TABLE_TEMP[typ][i] <= temp )&&( temp < TC_TABLE_TEMP[typ][i + 1] ) )
|
||||
{
|
||||
mv_left = TC_TABLE_MV[typ][i];
|
||||
mv_right = TC_TABLE_MV[typ][i + 1];
|
||||
temp_left = TC_TABLE_TEMP[typ][i];
|
||||
temp_right = TC_TABLE_TEMP[typ][i + 1];
|
||||
|
||||
result_mv = mv_left + ( mv_right - mv_left )*\
|
||||
( temp - temp_left )/( temp_right - temp_left);
|
||||
|
||||
return result_mv;
|
||||
}
|
||||
}
|
||||
|
||||
//ERROR
|
||||
return -999;
|
||||
}
|
||||
|
||||
//数据转换,real_value -> mux_signal.sv
|
||||
//float32 r2m_test_in = 0, r2m_test_out = 0;
|
||||
|
@ -720,7 +737,7 @@ float32 real2mux(float32 real_value)
|
|||
{
|
||||
case RTD_DC:
|
||||
{
|
||||
result = real_value;
|
||||
result = temp2ohm(real_value);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -737,6 +754,44 @@ float32 real2mux(float32 real_value)
|
|||
return result;
|
||||
}
|
||||
|
||||
//数据转换,热电阻阻值 Ω 转化为温度 ℃
|
||||
float32 ohm2temp(float32 ohm)
|
||||
{
|
||||
float32 result = 0;
|
||||
|
||||
for(uint8_t i = 0;i < 10; i++)
|
||||
{
|
||||
if( ( RTD_TABLE_OHM[i] <= ohm ) && ( ohm <= RTD_TABLE_OHM[i + 1] ) )
|
||||
{
|
||||
result = RTD_TABLE_TEMP[i] + ( RTD_TABLE_TEMP[i + 1] - RTD_TABLE_TEMP[i] ) *\
|
||||
( ( ohm - RTD_TABLE_OHM[i] ) / ( RTD_TABLE_OHM[i + 1] - RTD_TABLE_OHM[i] ) );
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//数据转换,温度 ℃ 转化为热电阻阻值 Ω
|
||||
float32 temp2ohm(float32 temp)
|
||||
{
|
||||
float32 result = 0;
|
||||
|
||||
for(uint8_t i = 0;i < 10; i++)
|
||||
{
|
||||
if( ( RTD_TABLE_TEMP[i] <= temp ) && ( temp <= RTD_TABLE_TEMP[i + 1] ) )
|
||||
{
|
||||
result = RTD_TABLE_OHM[i] + ( RTD_TABLE_OHM[i + 1] - RTD_TABLE_OHM[i] ) *\
|
||||
( ( temp - RTD_TABLE_TEMP[i] ) / ( RTD_TABLE_TEMP[i + 1] - RTD_TABLE_TEMP[i] ) );
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//计算a的b次方
|
||||
float32 my_power(int a, int b)
|
||||
{
|
||||
|
|
|
@ -386,6 +386,223 @@ void eeprom_datasave(void)
|
|||
|
||||
}
|
||||
|
||||
void eeprom_datasave_single(uint8_t tag)
|
||||
{
|
||||
uint8_t temp_h = 0, temp_l = 0;
|
||||
|
||||
switch (tag)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
//VOL V
|
||||
temp_h = tabdata.item0_page0_vup[0] >> 8;
|
||||
temp_l = tabdata.item0_page0_vup[0] & 0xFF;
|
||||
eeprom_writedata(VOL_V_UP_ADDR, temp_h);
|
||||
eeprom_writedata(VOL_V_UP_ADDR + 8, temp_l);
|
||||
|
||||
temp_h = tabdata.item0_page0_vlow[0] >> 8;
|
||||
temp_l = tabdata.item0_page0_vlow[0] & 0xFF;
|
||||
eeprom_writedata(VOL_V_LOW_ADDR, temp_h);
|
||||
eeprom_writedata(VOL_V_LOW_ADDR + 8, temp_l);
|
||||
|
||||
//VOL mV
|
||||
temp_h = tabdata.item0_page0_vup[1] >> 8;
|
||||
temp_l = tabdata.item0_page0_vup[1] & 0xFF;
|
||||
eeprom_writedata(VOL_MV_UP_ADDR, temp_h);
|
||||
eeprom_writedata(VOL_MV_UP_ADDR + 8, temp_l);
|
||||
|
||||
temp_h = tabdata.item0_page0_vlow[1] >> 8;
|
||||
temp_l = tabdata.item0_page0_vlow[1] & 0xFF;
|
||||
eeprom_writedata(VOL_MV_LOW_ADDR, temp_h);
|
||||
eeprom_writedata(VOL_MV_LOW_ADDR + 8, temp_l);
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
{
|
||||
//CUR
|
||||
temp_h = tabdata.item0_page0_cup >> 8;
|
||||
temp_l = tabdata.item0_page0_cup & 0xFF;
|
||||
eeprom_writedata(CUR_UP_ADDR, temp_h);
|
||||
eeprom_writedata(CUR_UP_ADDR + 8, temp_l);
|
||||
|
||||
temp_h = tabdata.item0_page0_clow >> 8;
|
||||
temp_l = tabdata.item0_page0_clow & 0xFF;
|
||||
eeprom_writedata(CUR_LOW_ADDR, temp_h);
|
||||
eeprom_writedata(CUR_LOW_ADDR + 8, temp_l);
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
{
|
||||
//RES
|
||||
temp_h = tabdata.item0_page0_rup >> 8;
|
||||
temp_l = tabdata.item0_page0_rup & 0xFF;
|
||||
eeprom_writedata(RES_UP_ADDR, temp_h);
|
||||
eeprom_writedata(RES_UP_ADDR + 8, temp_l);
|
||||
|
||||
temp_h = tabdata.item0_page1_rlow >> 8;
|
||||
temp_l = tabdata.item0_page1_rlow & 0xFF;
|
||||
eeprom_writedata(RES_LOW_ADDR, temp_h);
|
||||
eeprom_writedata(RES_LOW_ADDR + 8, temp_l);
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
{
|
||||
//FRE
|
||||
temp_h = tabdata.item0_page1_fup >> 8;
|
||||
temp_l = tabdata.item0_page1_fup & 0xFF;
|
||||
eeprom_writedata(FRE_UP_ADDR, temp_h);
|
||||
eeprom_writedata(FRE_UP_ADDR + 8, temp_l);
|
||||
|
||||
temp_h = tabdata.item0_page1_flow >> 8;
|
||||
temp_l = tabdata.item0_page1_flow & 0xFF;
|
||||
eeprom_writedata(FRE_LOW_ADDR, temp_h);
|
||||
eeprom_writedata(FRE_LOW_ADDR + 8, temp_l);
|
||||
}
|
||||
break;
|
||||
|
||||
case 4:
|
||||
{
|
||||
//TC K
|
||||
temp_h = tabdata.item0_page1_TCup[0] >> 8;
|
||||
temp_l = tabdata.item0_page1_TCup[0] & 0xFF;
|
||||
eeprom_writedata(TC_K_UP_ADDR, temp_h);
|
||||
eeprom_writedata(TC_K_UP_ADDR + 8, temp_l);
|
||||
|
||||
temp_h = tabdata.item0_page1_TClow[0] >> 8;
|
||||
temp_l = tabdata.item0_page1_TClow[0] & 0xFF;
|
||||
eeprom_writedata(TC_K_LOW_ADDR, temp_h);
|
||||
eeprom_writedata(TC_K_LOW_ADDR + 8, temp_l);
|
||||
}
|
||||
break;
|
||||
|
||||
case 5:
|
||||
{
|
||||
//TC S
|
||||
temp_h = tabdata.item0_page1_TCup[1] >> 8;
|
||||
temp_l = tabdata.item0_page1_TCup[1] & 0xFF;
|
||||
eeprom_writedata(TC_S_UP_ADDR, temp_h);
|
||||
eeprom_writedata(TC_S_UP_ADDR + 8, temp_l);
|
||||
|
||||
temp_h = tabdata.item0_page1_TClow[1] >> 8;
|
||||
temp_l = tabdata.item0_page1_TClow[1] & 0xFF;
|
||||
eeprom_writedata(TC_S_LOW_ADDR, temp_h);
|
||||
eeprom_writedata(TC_S_LOW_ADDR + 8, temp_l);
|
||||
}
|
||||
break;
|
||||
|
||||
case 6:
|
||||
{
|
||||
//TC N
|
||||
temp_h = tabdata.item0_page1_TCup[2] >> 8;
|
||||
temp_l = tabdata.item0_page1_TCup[2] & 0xFF;
|
||||
eeprom_writedata(TC_N_UP_ADDR, temp_h);
|
||||
eeprom_writedata(TC_N_UP_ADDR + 8, temp_l);
|
||||
|
||||
temp_h = tabdata.item0_page1_TClow[2] >> 8;
|
||||
temp_l = tabdata.item0_page1_TClow[2] & 0xFF;
|
||||
eeprom_writedata(TC_N_LOW_ADDR, temp_h);
|
||||
eeprom_writedata(TC_N_LOW_ADDR + 8, temp_l);
|
||||
}
|
||||
break;
|
||||
|
||||
case 7:
|
||||
{
|
||||
//TC B
|
||||
temp_h = tabdata.item0_page1_TCup[3] >> 8;
|
||||
temp_l = tabdata.item0_page1_TCup[3] & 0xFF;
|
||||
eeprom_writedata(TC_B_UP_ADDR, temp_h);
|
||||
eeprom_writedata(TC_B_UP_ADDR + 8, temp_l);
|
||||
|
||||
temp_h = tabdata.item0_page1_TClow[3] >> 8;
|
||||
temp_l = tabdata.item0_page1_TClow[3] & 0xFF;
|
||||
eeprom_writedata(TC_B_LOW_ADDR, temp_h);
|
||||
eeprom_writedata(TC_B_LOW_ADDR + 8, temp_l);
|
||||
}
|
||||
break;
|
||||
|
||||
case 8:
|
||||
{
|
||||
//TC E
|
||||
temp_h = tabdata.item0_page1_TCup[4] >> 8;
|
||||
temp_l = tabdata.item0_page1_TCup[4] & 0xFF;
|
||||
eeprom_writedata(TC_E_UP_ADDR, temp_h);
|
||||
eeprom_writedata(TC_E_UP_ADDR + 8, temp_l);
|
||||
|
||||
temp_h = tabdata.item0_page1_TClow[4] >> 8;
|
||||
temp_l = tabdata.item0_page1_TClow[4] & 0xFF;
|
||||
eeprom_writedata(TC_E_LOW_ADDR, temp_h);
|
||||
eeprom_writedata(TC_E_LOW_ADDR + 8, temp_l);
|
||||
}
|
||||
break;
|
||||
|
||||
case 9:
|
||||
{
|
||||
//TC J
|
||||
temp_h = tabdata.item0_page1_TCup[5] >> 8;
|
||||
temp_l = tabdata.item0_page1_TCup[5] & 0xFF;
|
||||
eeprom_writedata(TC_J_UP_ADDR, temp_h);
|
||||
eeprom_writedata(TC_J_UP_ADDR + 8, temp_l);
|
||||
|
||||
temp_h = tabdata.item0_page1_TClow[5] >> 8;
|
||||
temp_l = tabdata.item0_page1_TClow[5] & 0xFF;
|
||||
eeprom_writedata(TC_J_LOW_ADDR, temp_h);
|
||||
eeprom_writedata(TC_J_LOW_ADDR + 8, temp_l);
|
||||
}
|
||||
break;
|
||||
|
||||
case 10:
|
||||
{
|
||||
//TC R
|
||||
temp_h = tabdata.item0_page1_TCup[6] >> 8;
|
||||
temp_l = tabdata.item0_page1_TCup[6] & 0xFF;
|
||||
eeprom_writedata(TC_R_UP_ADDR, temp_h);
|
||||
eeprom_writedata(TC_R_UP_ADDR + 8, temp_l);
|
||||
|
||||
temp_h = tabdata.item0_page1_TClow[6] >> 8;
|
||||
temp_l = tabdata.item0_page1_TClow[6] & 0xFF;
|
||||
eeprom_writedata(TC_R_LOW_ADDR, temp_h);
|
||||
eeprom_writedata(TC_R_LOW_ADDR + 8, temp_l);
|
||||
}
|
||||
break;
|
||||
|
||||
case 11:
|
||||
{
|
||||
//TC T
|
||||
temp_h = tabdata.item0_page1_TCup[7] >> 8;
|
||||
temp_l = tabdata.item0_page1_TCup[7] & 0xFF;
|
||||
eeprom_writedata(TC_T_UP_ADDR, temp_h);
|
||||
eeprom_writedata(TC_T_UP_ADDR + 8, temp_l);
|
||||
|
||||
temp_h = tabdata.item0_page1_TClow[7] >> 8;
|
||||
temp_l = tabdata.item0_page1_TClow[7] & 0xFF;
|
||||
eeprom_writedata(TC_T_LOW_ADDR, temp_h);
|
||||
eeprom_writedata(TC_T_LOW_ADDR + 8, temp_l);
|
||||
}
|
||||
break;
|
||||
|
||||
case 12:
|
||||
{
|
||||
//RTD
|
||||
temp_h = tabdata.item0_page2_RTDup >> 8;
|
||||
temp_l = tabdata.item0_page2_RTDup & 0xFF;
|
||||
eeprom_writedata(RTD_UP_ADDR, temp_h);
|
||||
eeprom_writedata(RTD_UP_ADDR + 8, temp_l);
|
||||
|
||||
temp_h = tabdata.item0_page2_RTDlow >> 8;
|
||||
temp_l = tabdata.item0_page2_RTDlow & 0xFF;
|
||||
eeprom_writedata(RTD_LOW_ADDR, temp_h);
|
||||
eeprom_writedata(RTD_LOW_ADDR + 8, temp_l);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//开机上电后读取参数
|
||||
void eeprom_dataread(void)
|
||||
{
|
||||
|
|
|
@ -641,7 +641,7 @@ void fun_get_sig16132_ch(uint8_t channel, float32 *data)
|
|||
{
|
||||
float32 ad_16 = SIG16130_RetrievalData(1, 0);
|
||||
float32 voltage = (float32)(2.5f * ad_16 / 32767.0f);
|
||||
float32 Rt = 0;
|
||||
//float32 Rt = 0;
|
||||
|
||||
if (channel == 2) // 0~30V电压输入检测
|
||||
{
|
||||
|
@ -673,16 +673,16 @@ void fun_get_sig16132_ch(uint8_t channel, float32 *data)
|
|||
// A=3.96847×10-3;
|
||||
// B=-5.847×10-7;
|
||||
// C=-4.22×10-12;
|
||||
#define R0 100.0f
|
||||
#define A 3.96847e-3
|
||||
#define B -5.847e-7
|
||||
#define C -4.22e-12
|
||||
Rt = voltage * 1000.0f / 1.0f;
|
||||
float32 temp1 = (-A + sqrt(A * A - 4 * B * (1 - Rt / R0))) / (2 * B);
|
||||
float32 temp2 = (-A - sqrt(A * A - 4 * B * (1 - Rt / R0))) / (2 * B);
|
||||
// #define R0 100.0f
|
||||
// #define A 3.96847e-3
|
||||
// #define B -5.847e-7
|
||||
// #define C -4.22e-12
|
||||
// Rt = voltage * 1000.0f / 1.0f;
|
||||
// float32 temp1 = (-A + sqrt(A * A - 4 * B * (1 - Rt / R0))) / (2 * B);
|
||||
// float32 temp2 = (-A - sqrt(A * A - 4 * B * (1 - Rt / R0))) / (2 * B);
|
||||
|
||||
*data = temp1;
|
||||
//*data = voltage * 1000.0f;
|
||||
// *data = temp1;
|
||||
*data = voltage * 1000.0f/ 0.5f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue