实测工程量值=(变送器量程最大值-变送器量程最小值)/(数字量最大值-数字量最小值)*(当前采集工程量值-零点误差值)。
相关程序代码
SEAL_PRESSURE.h
cpp
class CSEAL_PRESSUREApp : public CWinApp
{
public:
CSEAL_PRESSUREApp();
unsigned short nAddr_AD_1;
CString COMB_Data_AD_1[16];
int COMB_Data_AD_Number_1;
short m_saveData_AD_1[32];
unsigned char b_AD_1[16];
CString b_str_AD_1[16];
int AD_1[16];
CString AD_SET_ZERO_VLO[16];
CString AD_SET_ZERO_NUM[16];
CString AD_SET_RAN_VLO[16];
CString AD_SET_RAN_NUM[16];
float flo_AD_SET_ZERO_VLO[16];
float flo_AD_SET_ZERO_NUM[16];
float flo_AD_SET_RAN_VLO[16];
float flo_AD_SET_RAN_NUM[16];
float AD_ACT_COE[16];
...
}
SEAL_PRESSURE.cpp
cpp
CSEAL_PRESSUREApp::CSEAL_PRESSUREApp()
{
nAddr_AD_1=0x110;
COMB_Data_AD_1[0]="AD输入1";
COMB_Data_AD_1[1]="AD输入2";
COMB_Data_AD_1[2]="AD输入3";
COMB_Data_AD_1[3]="AD输入4";
COMB_Data_AD_1[4]="AD输入5";
COMB_Data_AD_1[5]="AD输入6";
COMB_Data_AD_1[6]="AD输入7";
COMB_Data_AD_1[7]="AD输入8";
COMB_Data_AD_1[8]="AD输入9";
COMB_Data_AD_1[9]="AD输入10";
COMB_Data_AD_1[10]="AD输入11";
COMB_Data_AD_1[11]="AD输入12";
COMB_Data_AD_1[12]="AD输入13";
COMB_Data_AD_1[13]="AD输入14";
COMB_Data_AD_1[14]="AD输入15";
COMB_Data_AD_1[15]="AD输入16";
COMB_Data_AD_Number_1=16;
}
SEAL_PRESSUREDlg.cpp
cpp
BOOL CSEAL_PRESSUREDlg::OnInitDialog()
{
CDialog::OnInitDialog();
for( i=0;i<theApp.COMB_Data_AD_Number_1;i++)
{
GetPrivateProfileString("AD输入",theApp.COMB_Data_AD_1[i],NULL,theApp.b_str_AD_1[i].GetBuffer(20),20,theApp.strFilePath);
theApp.AD_1[i]=_ttoi(theApp.b_str_AD_1[i]);
if (theApp.b_str_AD_1[i]!="-1" )
{
GetPrivateProfileString("A/D设置",theApp.COMB_Data_AD_1[i]+"零点电压",NULL,theApp.AD_SET_ZERO_VLO[theApp.AD_1[i]].GetBuffer(20),20,theApp.strFilePath);
GetPrivateProfileString("A/D设置",theApp.COMB_Data_AD_1[i]+"零点数值",NULL,theApp.AD_SET_ZERO_NUM[theApp.AD_1[i]].GetBuffer(20),20,theApp.strFilePath);
GetPrivateProfileString("A/D设置",theApp.COMB_Data_AD_1[i]+"量程电压",NULL,theApp.AD_SET_RAN_VLO[theApp.AD_1[i]].GetBuffer(20),20,theApp.strFilePath);
GetPrivateProfileString("A/D设置",theApp.COMB_Data_AD_1[i]+"量程数值",NULL,theApp.AD_SET_RAN_NUM[theApp.AD_1[i]].GetBuffer(20),20,theApp.strFilePath);
theApp.flo_AD_SET_ZERO_VLO[i]= (float)atof(theApp.AD_SET_ZERO_VLO[theApp.AD_1[i]]);
theApp.flo_AD_SET_ZERO_NUM[i]= (float)atof(theApp.AD_SET_ZERO_NUM[theApp.AD_1[i]]);
theApp.flo_AD_SET_RAN_VLO[i]= (float)atof(theApp.AD_SET_RAN_VLO[theApp.AD_1[i]]);
theApp.flo_AD_SET_RAN_NUM[i]=(float) atof(theApp.AD_SET_RAN_NUM[theApp.AD_1[i]]);
if(theApp.AD_SET_ZERO_VLO[theApp.AD_1[i]]!="" && theApp.AD_SET_ZERO_NUM[theApp.AD_1[i]]!="" && theApp.AD_SET_RAN_VLO[theApp.AD_1[i]]!="" && theApp.AD_SET_RAN_NUM[theApp.AD_1[i]]!="")
{
theApp.AD_ACT_COE[i]= theApp.flo_AD_SET_RAN_NUM[i]/theApp.flo_AD_SET_RAN_VLO[i]*(AI6325ASingle(theApp.nAddr_AD_1,2,theApp.AD_1[i])-theApp.flo_AD_SET_ZERO_NUM[i]);
}
}
}