本帖最后由 yi2012 于 2014-5-30 15:15 编辑
各位我有个输入模块,用串口调试助手可以用如图(也有用触摸屏的COM1口试过的);
但是我用触摸屏就一点反应的都没有,通讯指示灯不闪,通信格式没有错啊!如图
宏指令如下
macro_command main()
bool b0[16],b1=1,b2=0
char command[32], response[32], c0[6]
short read_no, return_value
FILL(command[0], 0, 32) // init
FILL(response[0], 0, 32)
command[0] = 0x55 //fixed
command[1] = 0x1 // station no
command[2] = 0x10 // function
command[3] = 0x0 // data
command[4] = 0x0 // data
command[5] = 0x0 // data
command[6] = 0x0 // data
command[7] =0x66 // checksum
OUTPORT(command[0], "plc1", 8) // send command
INPORT(response[0], "plc1", 8, return_value) // read response
c0[0]=response[0]+response[1] // checksum
c0[1]=response[2]+c0[0]
c0[2]=response[3]+c0[1]
c0[3]=response[4]+c0[2]
c0[4]=response[5]+c0[3]
c0[5]=response[6]+c0[4]
if c0[5]==response[7] then
SetData(response[3], "Local HMI", LW, 100, 2)
end if
if return_value==0 then
SetData(command[3], "Local HMI", LW, 100, 2)
SetData(b1, "Local HMI", LB, 100, 1)
end if
SetData(response[3], "Local HMI", LW, 100, 2)
GetData(b0[0], "Local HMI", LW_Bit, 10000, 16)
SetData(b0[0], "Local HMI", LB, 0, 16)
end macro_command |