DRV_DeviceOpen(0,&DriverHandle); ptAOConfig.chan=0;//AO 通道 0
ptAOConfig.RefSrc=0;//内部参考源
ptAOConfig.MaxValue=10;
ptAOConfig.MinValue=0;
DRV_AOConfig(DriverHandle, (LPT_AOConfig)&ptAOConfig); //电压输出 FILE *fp;
fp=fopen(\
while(!kbhit())
{
ptCounterEventStart.counter=0;
DRV_CounterEventStart(DriverHandle,&ptCounterEventStart);
ptCounterEventRead.counter=0;
ptCounterEventRead.overflow=&over; ptCounterEventRead.count=&num1; DRV_CounterEventRead
(LPT_CounterEventRead)&ptCounterEventRead);
DRV_CounterEventRead (DriverHandle, &ptCounterEventRead); Sleep(500);
ptCounterEventRead.counter=0;
ptCounterEventRead.overflow=&over; ptCounterEventRead.count=&num2; DRV_CounterEventRead
(LPT_CounterEventRead)&ptCounterEventRead);
DRV_CounterEventRead (DriverHandle, &ptCounterEventRead);
count=num2-num1;
Q=0.5+(2*(count-13))*0.0122;
printf(\ \
(DriverHandle,(DriverHandle,20
fprintf(fp,\ \
e1=e2;
e2=e3; e3=Qh-Q;
U+=Kc*(e3-e2)+(Kc*Ts/Ti)*e3; if(U>=10)
U=10; if(U<=0)
U=0; t+=0.5;
ptAOVoltageOut.chan = 0;
ptAOVoltageOut.OutputValue=U;//所要设置的输出电压值,浮点型数据 DRV_AOVoltageOut(DriverHandle,(LPT_AOVoltageOut)&ptAOVoltageOut);
printf(\ fprintf(fp,\ }
fclose(fp);
DRV_CounterReset(DriverHandle,0); DRV_DeviceClose( &DriverHandle ); }
21
22