📄 adsample.c
字号:
else
{
fTempData = 0;
}
}
}
/* else if (((AD.iScaleHigh[uchChannel - 1] <= 5000) && (AD.uchChType[uchChannel - 1] == 16) && (AD.uchtMeasureType[uchChannel - 1] == 2)) || ((AD.iScaleHigh[uchChannel - 1] <= 10000) && (AD.uchChType[uchChannel - 1] == 16) && (AD.uchtMeasureType[uchChannel - 1] == 1)) || ((AD.iScaleHigh[uchChannel - 1] <= 5000) && (AD.uchChType[uchChannel - 1] == 16) && (AD.uchtMeasureType[uchChannel - 1] == 3))
|| ((AD.iScaleHigh[uchChannel - 1] <= 250) && (AD.uchChType[uchChannel - 1] == 13) && (AD.uchtMeasureType[uchChannel - 1] == 2)) || ((AD.iScaleHigh[uchChannel - 1] <= 500) && (AD.uchChType[uchChannel - 1] == 13) && (AD.uchtMeasureType[uchChannel - 1] == 1)) || ((AD.iScaleHigh[uchChannel - 1] <= 200) && (AD.uchChType[uchChannel - 1] == 13) && (AD.uchtMeasureType[uchChannel - 1] == 3))
|| ((AD.iScaleHigh[uchChannel - 1] <= 120) && (AD.uchChType[uchChannel - 1] == 18) && (AD.uchtMeasureType[uchChannel - 1] == 1)) || ((AD.iScaleHigh[uchChannel - 1] <= 60) && (AD.uchChType[uchChannel - 1] == 18) && (AD.uchtMeasureType[uchChannel - 1] == 2)) || ((AD.iScaleHigh[uchChannel - 1] <= 50) && (AD.uchChType[uchChannel - 1] == 18) && (AD.uchtMeasureType[uchChannel - 1] == 3)))
*/
else if (uchChannelScaleStatus[uchChannel - 1] == 0)
{
if (AD.uchtMeasureType[uchChannel - 1] == 3) //有效值
{
/* if (fNotIntegralData > 3)
{
fTempData = fNotIntegralData / AD.fRealNotIntegralLittleScaleData[uchChannel - 1];
}
else
{
fTempData = 0;
} */
if (fNotIntegralData > AD.fRMSNotIntegrateLittleRangeValue[uchChannel - 1]) //20080730
{
fTempData = (fNotIntegralData - AD.fRMSNotIntegrateLittleRangeValue[uchChannel - 1]) / AD.fRealNotIntegralLittleScaleData[uchChannel - 1];
}
else
{
fTempData = 0;
}
}
else
{
if (fNotIntegralData > (float)AD.uiLittleRangeADZero[uchChannel - 1])
{
fTempData = fNotIntegralData - AD.uiLittleRangeADZero[uchChannel - 1];
fTempData = fTempData / AD.fRealNotIntegralLittleScaleData[uchChannel - 1];
}
else
{
fTempData = 0;
}
}
}
if (fTempData > 6.5) //计算上传的比例值不能超过量程的6.5倍
{
fTempData = 6.5;
}
lTempData = fTempData * (AD.iScaleHigh[uchChannel - 1]-AD.iScaleLow[uchChannel - 1]) + AD.iScaleLow[uchChannel - 1]; //实际测量值
if (lTempData > 32700)
{
lTempData = 32700;
}
if (AD.uchChType[0] == 13) //20080910
{
if (lTempData <= 4) //a-a类型 小于0.04g做平均计算
{
fPercentValueBAK[uchChannel -1][uchPercentCountNumber] = fTempData;
uchPercentCountNumber = (uchPercentCountNumber++) & 0x03;
fTempData = (fTempData + fPercentValueBAK[uchChannel -1][0] + fPercentValueBAK[uchChannel -1][1] + fPercentValueBAK[uchChannel -1][2] + fPercentValueBAK[uchChannel -1][3]) / 5;
}
else
{
;
}
}
else if (AD.uchChType[0] == 16) //20080910
{
if (lTempData <= 100) //小于1mm/s ,做平均计算 v-v类型
{
fPercentValueBAK[uchChannel -1][uchPercentCountNumber] = fTempData;
uchPercentCountNumber = (uchPercentCountNumber++) & 0x03;
fTempData = (fTempData + fPercentValueBAK[uchChannel -1][0] + fPercentValueBAK[uchChannel -1][1] + fPercentValueBAK[uchChannel -1][2] + fPercentValueBAK[uchChannel -1][3]) / 5;
}
else
{
;
}
}
else
{
;
}
AD.iActualValue[uchChannel - 1][1] = fTempData*5000;
/* if (AD.iActualValue[uchChannel - 1][1] < 25) //测量结果低于百分之0.5不显示
{
AD.iActualValue[uchChannel - 1][1] = 0;
}*/ ////--------------------------------注意修改--------------20080425--------
AD.iActualValue[uchChannel - 1][0] = lTempData;
FeedDog();
}
//---------------------------HHH-----------------------------
//函数名称:void CalculateLVDTChannelValue(unsigned char uchChannel,float fLVDTData)
//功 能:计算LVDT直流通道的数据
//输入参数:通道号,采集到的LVDT AD值
//返 回:无
//完成日期:1/24/2008
//作 者:马爱虹
//----------------------------------------------------------
void CalculateLVDTChannelValue(unsigned char uchChannel,float fLVDTData)
{
xdata float fTempData1;
xdata float fTempData2;
xdata long lTempData;
switch(AD.uchSenDirection[uchChannel - 1]) //间隙电压不考虑方向
{
case 0: //Toward probe
if( fLVDTData < 20 )
{
fLVDTData = fLVDTData-10;
}
if(fLVDTData >AD.uiGAPADLVDTZero[uchChannel - 1])
{
fTempData1 = fLVDTData - (float)AD.lLvdtMark[uchChannel-1];
fTempData2 = fLVDTData - AD.uiGAPADLVDTZero[uchChannel - 1];
}
else
{
// fTempData1=0; //tong modify
fTempData1 = AD.uiGAPADLVDTZero[uchChannel - 1] - (float)AD.lLvdtMark[uchChannel-1]; //tong add
fTempData2 = fLVDTData - AD.uiGAPADLVDTZero[uchChannel - 1];
}
fTempData2 = fTempData2 / ( AD.uiGAPADFull[uchChannel - 1] - AD.uiGAPADLVDTZero[uchChannel - 1] );
fTempData1 = fTempData1 / AD.fRealLVDTScaleData[uchChannel - 1];
if (fTempData1 > 3)
{
fTempData1 = 3;
}
lTempData = fTempData1 * (AD.iScaleHigh[uchChannel - 1]-AD.iScaleLow[0]) + AD.iScaleLow[0]; //正向实际测量值
AD.iActualValue[uchChannel - 1][0] = lTempData; //测量值
AD.iActualValue[uchChannel - 1][1] = fTempData1 * 5000; //被测量值的比例值
AD.iActualValue[uchChannel - 1][2] = fTempData2 * 16000;//被测量值的间隙电压值
break;
case 1:
if( fLVDTData < 20 )
{
fLVDTData = fLVDTData-10;
}
if(fLVDTData > AD.uiGAPADLVDTZero[uchChannel - 1])
{
fTempData1 = fLVDTData - (float)AD.lLvdtMark[uchChannel-1];
fTempData2 = fLVDTData - AD.uiGAPADLVDTZero[uchChannel - 1];
}
else
{
fTempData1 = AD.uiGAPADLVDTZero[uchChannel - 1] - (float)AD.lLvdtMark[uchChannel-1]; //tong add
// fTempData1=0; //tong modify
fTempData2 = fLVDTData - AD.uiGAPADLVDTZero[uchChannel - 1];
}
fTempData2 = fTempData2 / ( AD.uiGAPADFull[uchChannel - 1] - AD.uiGAPADLVDTZero[uchChannel - 1] );
fTempData1 = fTempData1 / AD.fRealLVDTScaleData[uchChannel - 1];
if (fTempData1 > 3)
{
fTempData1 = 3;
}
lTempData = (1-fTempData1) * (AD.iScaleHigh[uchChannel - 1]-AD.iScaleLow[0]);
AD.iActualValue[uchChannel - 1][0] = lTempData; //测量值
AD.iActualValue[uchChannel - 1][1] = (1-fTempData1) * 5000; //被测量值的比例值
AD.iActualValue[uchChannel - 1][2] = fTempData2 * 16000;//被测量值的间隙电压值
break;
default:
AD.uchSenDirection[uchChannel - 1] = 0;
break;
}
}
//------------------------HHH--------------------------------
//函数名称:void CompositeLVDTValue(void)
//功 能:计算复合LVDT各通道的数据 第二通道比例值
//输入参数:通道号
//返 回:无
//完成日期:1/24/2008
//作 者:马爱虹
//----------------------------------------------------------
void CompositeLVDTValue(void)
{
long xdata lTemp;
unsigned int xdata uiTemp;
// if(uchChannel==2) //tong modify
// {
AD.iActualValue[1][0] = AD.iActualValue[0][0]-AD.iActualValue[1][0];
lTemp = (long)AD.iActualValue[1][0] - (long)AD.iScaleLow[1];
lTemp = lTemp * 5000;
uiTemp = AD.iScaleHigh[1] - AD.iScaleLow[1];
AD.iActualValue[1][1] = lTemp / uiTemp;
// }
}
//--------------------------------------------------------
//函数名称:void CalculateGAPValue(unsigned char uchChannel,unsigned int xdata *SrcData,unsigned int uiSampleLocation)
//功 能:计算间隙电压
//输入参数:通道号,数据起始地址指针,计算位置
//返 回:无
//完成日期:9/26/2007
//作 者:佟文杰
//----------------------------------------------------------
void CalculateGAPValue(unsigned char uchChannel,unsigned int xdata *SrcData,unsigned int uiSampleLocation)
{
xdata float Temp;
unsigned int xdata i,uiMaxValue,uiMinValue, *PTR;
unsigned long xdata GapSum;
unsigned int xdata uiTempData;
unsigned int xdata uiGAPTempData[2][2];
unsigned int xdata uiAverageGAPTempData[2];
if(uchChannel == 1)
{
PTR = SrcData + uiSampleLocation;
GapSum = 0;
for(i=0;i<(AD.uiGroupLength/2);i++)
{
GapSum += *(PTR + i);
}
FeedDog();
AD.uiGapSumValue1[AD.uiGapSumPTR1] = GapSum >> 7; //AD.uiGroupLength/2
uiGAPTempData[0][0] = AD.uiGapSumValue1[AD.uiGapSumPTR1];
AD.uiGapSumPTR1 = (AD.uiGapSumPTR1 + 1)&0x1f;
GapSum = 0;
for(i=(AD.uiGroupLength/2);i<AD.uiGroupLength;i++)
{
GapSum += *(PTR + i);
}
AD.uiGapSumValue1[AD.uiGapSumPTR1] = GapSum >> 7; //AD.uiGroupLength/2
uiGAPTempData[0][1] = AD.uiGapSumValue1[AD.uiGapSumPTR1];
AD.uiGapSumPTR1 = (AD.uiGapSumPTR1 + 1)&0x1f;
uiMaxValue = AD.uiGapSumValue1[0];
uiMinValue = AD.uiGapSumValue1[0];
for(i=1;i<32;i++)
{
if(AD.uiGapSumValue1[i] > uiMaxValue)
{
uiMaxValue = AD.uiGapSumValue1[i];
}
else if(AD.uiGapSumValue1[i] < uiMinValue)
{
uiMinValue = AD.uiGapSumValue1[i];
}
}
}
else
{
PTR = SrcData + uiSampleLocation;
GapSum = 0;
for(i=0;i<(AD.uiGroupLength/2);i++)
{
GapSum += *(PTR + i);
}
FeedDog();
AD.uiGapSumValue2[AD.uiGapSumPTR2] = GapSum >> 7; //AD.uiGroupLength
uiGAPTempData[1][0]= AD.uiGapSumValue2[AD.uiGapSumPTR2];
AD.uiGapSumPTR2 = (AD.uiGapSumPTR2 + 1)&0x1f;
GapSum = 0;
for(i=(AD.uiGroupLength/2);i<AD.uiGroupLength;i++)
{
GapSum += *(PTR + i);
}
AD.uiGapSumValue2[AD.uiGapSumPTR2] = GapSum >> 7; //AD.uiGroupLength
uiGAPTempData[1][1]= AD.uiGapSumValue2[AD.uiGapSumPTR2];
AD.uiGapSumPTR2 = (AD.uiGapSumPTR2 + 1)&0x1f;
uiMaxValue = AD.uiGapSumValue2[0];
uiMinValue = AD.uiGapSumValue2[0];
for(i=1;i<32;i++)
{
if(AD.uiGapSumValue2[i] > uiMaxValue)
{
uiMaxValue = AD.uiGapSumValue2[i];
}
else if(AD.uiGapSumValue2[i] < uiMinValue)
{
uiMinValue = AD.uiGapSumValue2[i];
}
}
}
uiTempData = (uiMaxValue + uiMinValue) >> 1;
Temp = AD.uiGAPADFull[uchChannel - 1] - AD.uiGAPADZero[uchChannel - 1];
if (uiTempData >= AD.uiGAPADZero[uchChannel - 1])
{
Temp = (unsigned long)(uiTempData - AD.uiGAPADZero[uchChannel - 1]) * 15/Temp; //GAP占AD区间范围
AD.iActualValue[uchChannel - 1][2] = (1 + Temp)*1000;
}
else
{
Temp = (unsigned long)(AD.uiGAPADZero[uchChannel - 1] - uiTempData) * 15/Temp; //GAP占AD区间范围
AD.iActualValue[uchChannel - 1][2] = (1 - Temp)*1000; //实际间隙电压值
}
Temp = AD.uiGAPADFull[uchChannel - 1] - AD.uiGAPADZero[uchChannel - 1];
uiAverageGAPTempData[uchChannel - 1] = (uiGAPTempData[uchChannel - 1][0] + uiGAPTempData[uchChannel - 1][1]) >> 1;
if (uiAverageGAPTempData[uchChannel - 1] >= AD.uiGAPADZero[uchChannel - 1])
{
Temp = (unsigned long)(uiAverageGAPTempData[uchChannel - 1] - AD.uiGAPADZero[uchChannel - 1]) * 15/Temp; //GAP占AD区间范围
AD.iActualGAPNotOKValue[uchChannel - 1] = (1 + Temp)*1000;
}
else
{
Temp = (unsigned long)(AD.uiGAPADZero[uchChannel - 1] - uiAverageGAPTempData[uchChannel - 1]) * 15/Temp; //GAP占AD区间范围
AD.iActualGAPNotOKValue[uchChannel - 1] = (1 - Temp)*1000; //实际间隙电压值
}
}
//--------------------------------------------------------
//函数名称:void CalculateCalibrationAD(unsigned char uchChannel,unsigned char uchZeroOrSpan)
//功 能:计算标定积分通道和非积分通道的AD值
//输入参数:通道号,零点或者满度的标志位
//返 回:无
//完成日期:9/26/2007
//作 者:佟文杰
//----------------------------------------------------------
void CalculateCalibrationAD(unsigned char uchChannel,unsigned char uchZeroOrSpan)
{
unsigned char xdata i;
i = 0;
InitADSampleModule();
ADModuleSoftInitialize();
while(i < 32)
{
FeedDog();
if(AD.uchGroupDone == 1)
{
i++;
AD.uchGroupDone = 0;
if(uchSampleLocationNumber >= 8)
{
uchSampleLocationNumber -= 8;
}
AD.uiSampleLocation = uchSampleLocationNumber << 8;
AD.uiPassedGroupIndex = (AD.uiCurProcessingIndex + 1) &0x0f;
switch(uchChannel)
{
case 1:
CalculatePKPKValue0(pSampBuffer0,AD.uiSampleLocation,AD.uiCurProcessingIndex,AD.uiPassedGroupIndex,AD.uiGroupNum);
break;
case 2:
CalculatePKPKValue2(pSampBuffer2,AD.uiSampleLocation,AD.uiCurProcessingIndex,AD.uiPassedGroupIndex,AD.uiGroupNum);
break;
default:
CalculatePKPKValue0(pSampBuffer0,AD.uiSampleLocation,AD.uiCurProcessingIndex,AD.uiPassedGroupIndex,AD.uiGroupNum);
break;
}
/* AD.uiSampleLocation = (AD.uiSampleLocation + AD.uiGroupLength)& MAXLENGTH;
AD.uiCurProcessingIndex = AD.uiCurProcessingIndex + 1;
if(AD.uiCurProcessingIndex >= AD.uiGroupNum)
{
AD.uiCurProcessingIndex = 0;
}
AD.uiPassedGroupIndex = AD.uiCurProcessingIndex + 1;
if(AD.uiPassedGroupIndex >= AD.uiGroupNum)
{
AD.uiPassedGroupIndex = 0;
} */
}
}
if(uchZeroOrSpan == 0) //零点
{
switch(AD.uchChType[uchChannel - 1])
{
case 16: //非积分通道 速度入、出
if (((AD.iScaleHigh[uchChannel - 1] > 5000) && (AD.uchtMeasureType[uchChannel - 1] == 2)) || ((AD.iScaleHigh[uchChannel - 1] > 10000) && (AD.uchtMeasureType[uchChannel - 1] == 1)) || ((AD.iScaleHigh[uchChannel - 1] > 5000) && (AD.uchtMeasureType[uchChannel - 1] == 3))) //大量程
{
AD.uiDCADZero[uchChannel - 1] = AD.uiCurPKPKValue[(uchChannel - 1)*2]+2;
SetDisADZeroCountResultMain(uchChannel, AD.uiDCADZero[uchChannel - 1]);
OutputCurrentValue(uchChannel, 400);
}
else if (((AD.iScaleHigh[uchChannel - 1] <= 5000) && (AD.uchtMeasureType[uchChannel - 1] == 2)) || ((AD.iScaleHigh[uchChannel - 1] <= 10000) && (AD.uchtMeasureType[uchChannel - 1] == 1)) || ((AD.iScaleHigh[uchChannel - 1] <= 5000) && (AD.uchtMeasureType[uchChannel - 1] == 3))) //小量程
{
AD.uiLittleRangeADZero[uchChannel - 1] = AD.uiCurPKPKValue[(uchChannel - 1)*2]+1;
SetLittleADZeroCountResultMain(uchChannel, AD.uiLittleRangeADZero[uchChannel - 1]);
OutputCurrentValue(uchChannel, 400);
}
break;
case 13: //加速度入、出
if (((AD.iScaleHigh[uchChannel - 1] > 250) && (AD.uchtMeasureType[uchChannel - 1] == 2)) || ((AD.iScaleHigh[uchChannel - 1] > 500) && (AD.uchtMeasureType[uchChannel - 1] == 1)) || ((AD.iScaleHigh[uchChannel - 1] > 200) && (AD.uchtMeasureType[uchChannel - 1] == 3))) //大量程
{
AD.uiDCADZero[uchChannel - 1] = AD.uiCurPKPKValue[(uchChannel - 1)*2]+2;
SetDisADZeroCountResultMain(uchChannel, AD.uiDCADZero[uchChannel - 1]);
OutputCurrentValue(uchChannel, 400);
}
else if (((AD.iScaleHigh[uchChannel - 1] <= 250) && (AD.uchtMeasureType[uchChannel - 1] == 2)) || ((AD.iScaleHigh[uchChannel - 1] <= 500) && (AD.uchtMeasureType[uchChannel - 1] == 1)) || ((AD.iScaleHigh[uchChannel -
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -