以下是引用放你一条生路在2009-10-12 1:58:58的发言:
谢谢你对我那个PLC和变频器通信的讲解,看来碰到难题了哦。那能告诉我如果我做GP和变频器直接通信,那要怎么做呢,GP和变频器直接通信,能达到和PLC通信一样的要求吗,我只要能达到在触摸屏上能改变频器的频率就可以了,多谢拉
这个需要使用GP的扩展脚本功能。
脚本里需写类似如下语句:
[w:LS0300]=0x05 //输入通信格式(16进制)ASCII,起始符:ENQ,占用一个地址
[w:LS0301]=0x30 //站号:00,占用二个地址
[w:LS0302]=0x30
[w:LS0303]=0x45 //指令代码:EE,占用二个地址
[w:LS0304]=0x45
[w:LS0311]=0x0d //结束符:CR,占用一个地址
[w:LS0460]=([w:LS0450]&f000h)>>12 //将输入十进制数转换成十六进制数,将一个地址拆成四个地址存放数据
[w:LS0461]=([w:LS0450]&0f00h)>>8
[w:LS0462]=([w:LS0450]&00f0h)>>4
[w:LS0463]=[w:LS0450]&000fh
_bin2hexasc(databuf2, [w:LS0460]) //将四个地址中的十六进制数转换成ASCII
_dlcopy([w:LS0305], databuf2, 0, 1)
_bin2hexasc(databuf2, [w:LS0461])
_dlcopy([w:LS0306], databuf2, 0, 1)
_bin2hexasc(databuf2, [w:LS0462])
_dlcopy([w:LS0307], databuf2, 0, 1)
_bin2hexasc(databuf2, [w:LS0463])
_dlcopy([w:LS0308], databuf2, 0, 1)
[w:LS0400]=[w:LS0301]+[w:LS0302]+[w:LS0303]+[w:LS0304]+[w:LS0305]+[w:LS0306]+[w:LS0307]+[w:LS0308] //和校验累加(16进制)
[w:LS0412]=[w:LS0410]&0x000f //屏蔽前12位,留后4位
[w:LS0413]=[w:LS0410]&0x00f0 //屏蔽前8位,后4位,留4位
[w:LS0415]=[w:LS0413]>>4 //右移处理
_bin2hexasc(databuf2, [w:LS0412]) //将二个地址中的十六进制数转换成ASCII
_dlcopy([w:LS0310], databuf2, 0, 1)
_bin2hexasc(databuf2, [w:LS0415])
_dlcopy([w:LS0311], databuf2, 0, 1)
_ldcopy(databuf0, [w:LS0300], 12) //将设定好的12个数据送至缓存内
//开始送数据
if ([b:LS050000]==1) //触发通信地址
{IO_WRITE_EX([p:EXT_SIO], databuf0, 12) //发数据
}
endif
_dlcopy([w:LS0020], databuf0, [w:LS0020], [w:LS0020])
Nothing is difficult in the world if you dare to climb.
Come on .Just work hard and enjoy yourself!