|
double AverageData(USHORT ch, int count)
{
static PT_AIVoltageIn ptAIVoltageIn;
static PT_AIConfig ptAIConfig;
float dVoltage, total = 0.0;
double ad_value = 0.0;
ptAIConfig.DasChan = ch;
if(ch != 0) ptAIConfig.DasGain = 0; //+/- 10V
else ptAIConfig.DasGain = 1; //+/- 5V
DRV_AIConfig(DriverHandle, (LPT_AIConfig)&ptAIConfig);
for(int i = 0; i < count; i++) {
dVoltage = 0.0;
ptAIVoltageIn.chan = ptAIConfig.DasChan; // input channel
ptAIVoltageIn.gain = ptAIConfig.DasGain ; // input range
ptAIVoltageIn.TrigMode = 0; // 0 : internal trigger, 1 : external trigger
ptAIVoltageIn.voltage = &dVoltage;
DRV_AIVoltageIn(DriverHandle, (LPT_AIVoltageIn)&ptAIVoltageIn);
total += dVoltage;
}
ad_value = total / count;
return ad_value;
}
//---------------------------------------------------------------------------
double ConvertData(USHORT ch, int avg)
{
double value;
double temp[5];
value = AverageData(ch, avg);
temp[0] = adj_valx[action_direct][ch] - init_valx[action_direct][ch];
if(temp[0] == 0) temp[0] = 0.01;
temp[1] = adj_valy[action_direct][ch] - init_valy[action_direct][ch];
temp[2] = temp[1] / temp[0];
temp[3] = (temp[2] * value) - (temp[2] * init_valx[action_direct][ch]);
temp[4] = temp[3] + init_valy[action_direct][ch];
if(temp[4] <= 0) temp[4] = 0;
return temp[4];
}
이해가 안되네여.. 대충 설명좀..
|