好文档 - 专业文书写作范文服务资料分享网站

过程控制系统实验报告汇总

天下 分享 时间: 加入收藏 我要投稿 点赞

DRV_CounterEventRead (DriverHandle, (LPT_CounterEventRead)&ptCounterEventRead);

DRV_CounterEventRead (DriverHandle, &ptCounterEventRead); printf(\

count=num2-num1;

printf(\

FILE *fp=fopen(\

float fluid;

while(!kbhit()){

DRV_AIVoltageIn(DriverHandle,(LPT_AIVoltageIn)&ptAIVoltageIn);

ptCounterEventStart.counter=0;

DRV_CounterEventStart(DriverHandle,&ptCounterEventStart);

ptCounterEventRead.count=&num1;

DRV_CounterEventRead (DriverHandle,

(LPT_CounterEventRead)&ptCounterEventRead);

DRV_CounterEventRead (DriverHandle, &ptCounterEventRead);

Sleep(1000);

ptCounterEventRead.count=&num2;

DRV_CounterEventRead (DriverHandle,

(LPT_CounterEventRead)&ptCounterEventRead);

DRV_CounterEventRead (DriverHandle, &ptCounterEventRead);

count=num2-num1;

fluid = (14.5*(count-13)/(1200-13)+0.5);

printf(\ printf(\ printf(\ printf(\

15

printf(\

fprintf(fp,\ fprintf(fp,\ }

fclose(fp);

DRV_CounterReset(DriverHandle,0); DRV_DeviceClose( &DriverHandle );

DRV_DeviceClose( &DriverHandle_v ); //关闭设备 }

实验四 液位单回路控制系统的设计及参数整定#include #include #include \ #include #include \ #include

void main() {

FILE *fp=fopen(\

long DriverHandle;

PT_AIConfig ptAIConfig;

PT_AIVoltageIn ptAIVoltageIn; float height_v_In; float m_h;

float e1=0,e2=0,e3=0; //误差

16

float seth=200; float setv=0;

float k=1,ti=0.5,td=0; //PID 系数

int n=0; float time;

long DriverHandle1;

PT_AOConfig ptAOConfig;

PT_AOVoltageOut ptAOVoltageOut; float height_v_Out=0;

DRV_DeviceOpen(0,&DriverHandle); //打开设备 DRV_DeviceOpen(0,&DriverHandle1); //打开设备

ptAIConfig.DasChan=0;//AI 通道 0

ptAIConfig.DasGain=4;//Gain Code,+/-10V

DRV_AIConfig(DriverHandle, (LPT_AIConfig)&ptAIConfig);

ptAOConfig.chan=0;//AO 通道 0 ptAOConfig.RefSrc=0;//内部参考源 ptAOConfig.MaxValue=10;

ptAOConfig.MinValue=0;

DRV_AOConfig(DriverHandle1, (LPT_AOConfig)&ptAOConfig);

setv=seth/80;

while(!kbhit()) {

Sleep(300); n++;

time=n*0.3;

//读取指定 AI 通道的电压值

ptAIVoltageIn.chan = 0;//通道 0

ptAIVoltageIn.gain = 4;//Gain Code,+/-10V ptAIVoltageIn.TrigMode = 0; //内部触发

ptAIVoltageIn.voltage = (FLOAT far *)&height_v_In;//返回电压值DRV_AIVoltageIn(DriverHandle,(LPT_AIVoltageIn)&ptAIVoltageIn);

17

if(height_v_In < setv) {

e3=setv-height_v_In;

height_v_Out += k*((e3-e2)+0.3/ti*e3+td/0.3*(e3-2*e2+e1));

增量式 PID 控制

e1=e2;//前两次值 e2=e3;//前一次值

if(height_v_Out>10) height_v_Out=10; else if(height_v_Out<0)

height_v_Out=0; }

else height_v_Out=0;

printf(\ printf(\

printf(\

//电压输出

ptAOVoltageOut.chan = 0;

ptAOVoltageOut.OutputValue = height_v_Out;//所要设置的输出电压值,浮

点型数据

DRV_AOVoltageOut(DriverHandle1,(LPT_AOVoltageOut)&ptAOVoltageOut);

fprintf(fp,\

h=%f,

time=%f\\n\

}

//AO 配置

ptAOConfig.chan=0;//AO 通道 0 ptAOConfig.RefSrc=0;//内部参考源 ptAOConfig.MaxValue=10;

ptAOConfig.MinValue=0;

DRV_AOConfig(DriverHandle1, (LPT_AOConfig)&ptAOConfig);

ptAOVoltageOut.chan = 0;

height_v_Out=0;

ptAOVoltageOut.OutputValue = height_v_Out;//所要设置的输出电压值,浮点型

18

//

数据

DRV_DeviceClose( &DriverHandle ); //关闭设备 DRV_DeviceClose( &DriverHandle1 ); //关闭设备 }

实验五 流量单回路控制系统的设计及参数整定

#include #include #include\ #include #include

PT_CounterEventStart ptCounterEventStart; PT_CounterEventRead ptCounterEventRead; long DriverHandle;

PT_AOConfig ptAOConfig;

PT_AOVoltageOut ptAOVoltageOut; float davalue;

float Q=0;

float Qh=2; float t=0,U=0;

float e1=0,e2=0,e3=0; float Kc=0.5,Ti=1,Ts=0.5;

void main() {

ULONG num1=0,num2=0; int count; USHORT over=0;

19

过程控制系统实验报告汇总

DRV_CounterEventRead(DriverHandle,(LPT_CounterEventRead)&ptCounterEventRead);DRV_CounterEventRead(DriverHandle,&ptCounterEventRead);printf(\count=num2-num1;pr
推荐度:
点击下载文档文档为doc格式
4xtc955jqm2p7v43zg0p6rgfk15t3500h6u
领取福利

微信扫码领取福利

微信扫码分享