威纶通官方论坛

求助宏指令没按顺序来

[复制链接]
发表于 2015-8-23 23:18:52 | 显示全部楼层 |阅读模式
本帖最后由 lyph1 于 2015-8-25 08:41 编辑

启动按钮(触摸屏上LB0)-----》判断 LB0==1,f(变频器运行频率,通讯读上来的)==0,将设置一段速(LW0)写入变偏器地址‘310’----------------------》判断(LW0-1)<=a<=(Lw0+1)(实际读上来的变频器频率会略微低些)---->计时器开始计时(LB10=1)----------->计时时间到(LB20==1)------>将设置二段速(LW2)写入变频器--------》判断(LW2-1)<=f<=(Lw2+1),LB0==1--------------》计时器开始计时(LB11=1)----------->计时时间到(LB21==1)------>将设置三段速(LW4)写入变频器--------》判断(LW4-1)<=f<=(Lw4+1),LB0==1--------------》计时器开始计时(LB12=1)----------->计时时间到(LB22==1)------>将设置四段速(LW6)写入变频器--------》判断(LW6-1)<=f<=(Lw6+1),LB0==1--------------》计时器开始计时(LB13=1)----------->计时时间到(LB23==1)-------->将LB0=0,所有计时器复位,下次按启动重新按上逻辑运行。

    附件是做的宏指令,但是不执行,前天改的,能计时了,但是4个计时器是同时计时,没按逻辑来计时,我将程序发于大家,希望能得到帮助,谢谢
42910647@qq.com



macro_command main()
int f, s[4],a=0


bool q,ting,ti[4],tq[4],b[4]={0,0,0,0}
GetData(f, "Danfoss FC Series", Parameter, 1613, 1)
GetData(s[0], "Local HMI", LW, 0, 1)
GetData(s[1], "Local HMI", LW, 2, 1)
GetData(s[2], "Local HMI", LW, 4, 1)
GetData(s[3], "Local HMI", LW, 6, 1)
GetData(ti[0], "Local HMI", LB, 10, 4)
GetData(tq[0], "Local HMI", LB, 20, 4)
GetData(q, "Local HMI", LB, 0, 1)
GetData(ting, "Local HMI", LB, 1, 1)
if f==0 and q==1 then
SetData(s[0], "Danfoss FC Series", Parameter, 310, 1)
end if
if tq[0]==1 and(s[0]-1)<=f<=(s[0]+1) then
SetData(s[1], "Danfoss FC Series", Parameter, 310, 1)
end if
if tq[1]==1 and(s[1]-1)<=f<=(s[1]+1) then
SetData(s[2], "Danfoss FC Series", Parameter, 310, 1)
end if
if tq[2]==1 and(s[2]-1)<=f<=(s[2]+1) then
SetData(s[3], "Danfoss FC Series", Parameter, 310, 1)
end if
if tq[3]==1 and(s[3]-1)<=f<=(s[3]+1) or ting==true then
SetData(a, "Danfoss FC Series", Parameter, 310, 1)
SetData(b[0], "Local HMI", LB, 10, 4)

end if

if (s[0]-1)<=f<=(s[0]+1) and f>0  then
ti[0]=true
else
ti[0]=false

SetData(ti[0], "Local HMI", LB, 10, 1)
end if
GetData(f, "Danfoss FC Series", Parameter, 1613, 1)
GetData(s[1], "Local HMI", LW, 2, 1)
if (s[1]-1)<=f<=(s[1]+1) and f>0 then
ti[1]=true
else
ti[1]=false
SetData(ti[1], "Local HMI", LB, 11, 1)
end if
GetData(f, "Danfoss FC Series", Parameter, 1613, 1)
if (s[2]-1)<=f<=(s[2]+1) and f>0 then
ti[2]=true
else
ti[2]=false
SetData(ti[2], "Local HMI", LB, 12, 1)
end if
GetData(f, "Danfoss FC Series", Parameter, 1613, 1)
if (s[3]-1)<=f<=(s[3]+1) and f>0 then
ti[3]=true
else
ti[3]=false

SetData(ti[3], "Local HMI", LB, 13, 1)
end if

end macro_command
您需要登录后才可以发帖 登录 | 注册

本版积分规则

回复帖子

Archiver|小黑屋|威纶通官网 ( 粤ICP备06054553号 )

GMT+8, 2024-11-24 08:24

Powered by Discuz! X3.4

© 2001-2023 Comsenz Inc.

快速回复 返回顶部 返回列表