组态软件实验报告(5)
时间:2025-07-14
时间:2025-07-14
distrube5=1;
distrube6=0;
//桶的水平、竖直位置
bottlemoveh=0;
bottlemovev=0;
//灌装容量变量
depth=0;
//灌装速度
valve=0.2;
2 在“程序运行周期执行”脚本编辑区域输入脚本:
//如果处在初始位置上,则刚开始地1 步,同时信号灯1变绿If bottlemoveh==0 then
nsTtep=1;
flag1=0;
endif
//如果是第1步,则桶向前移动
If nStep==1 then
Bottlemoveh=bottlemoveh +1*mover/35;
Endif
//如果是到达灌装位置,则开始第2步,信号灯1变红
If nStep==1&&bottlemoveh>=45 then
nStep=2;
bottlemoveh =45;
flag1=1;
endif
//桶上升
If nStep==2 then
raise1=raise1+5*mover/35;
bottlemovev=bottlemovev+5*mover/35;
endif
//上升到顶部时,进入第3步,生成随机容量
If nStep==2&&raise1>=35 then
Riase=35;
nStep=3;
randweight = 19.7+rand(12001)/20000
endif
//开始灌装制剂
If nStep==3 then
Depth=depth+mover*valve/7;
Endif
//灌装达到指定容量时,停止加料,进入第4步
//并且加上分布图
If nStep==3&&depth>=randweight then
Dep0th=randweight;