发表于:2005/10/31 11:43:00
#0楼
求助:CP340的485通讯发送问题
调用FB3的程序如下,我在DB31里面的数据是Byte,奇怪的是不管我怎么改变数据,
我测得的发送口上的数据总是不变,感觉就是好像发送的时候根本就不是在发送我
想要发送的数据。我看到一位大侠说用ASCII通信协议时,还要用一个DB设置协议,
是不是这个问题,怎么设?我的调用FB3的方法,发送数据的指向不对吗?作为新
手,我怀疑我是不是有个基本错误。请指教。
L 256 //LADDR
T "SEND_WDB".LADDR
L 2
T "SEND_WDB".LEN //LEN
L 31 //DB_NO
T "SEND_WDB".DB_NO
L 0 //DBB_NOO
T "SEND_WDB".DB_NOO
// ------------------------
// SEND with instance DB
// ------------------------
CALL "P_SEND" , "DB_SEND"
REQ :="SEND_WDB".REQ
R :="SEND_WDB".R
LADDR :="SEND_WDB".LADDR
DB_NO :="SEND_WDB".DB_NO
DBB_NO:="SEND_WDB".DB_NOO
LEN :="SEND_WDB".LEN
DONE :="SEND_WDB".DONE
ERROR :="SEND_WDB".ERROR
STATUS:="SEND_WDB".STATUS
// ------------------------
// generate edge for SEND_REQ
// ------------------------
AN "SEND_WDB".REQ //SEND_REQ
S "SEND_WDB".REQ //set SEND_REQ
O "SEND_WDB".DONE //SEND_DONE
O "SEND_WDB".ERROR //SEND_ERROR
R "SEND_WDB".REQ //reset SEND_REQ
// -------------------------------
// verify "cycle without error"
// -------------------------------
AN "SEND_WDB".DONE //verify SEND_DONE
JC CHER //if SEND_DONE = 0, jump to CHER
//and check SEND_ERROR
// -------------------------------
// "cycle without error"
// SEND_DONE = 1
// -------------------------------
L "SEND_WDB".CONT_OK // "cycle without error"
+ 1 //increment counter
T "SEND_WDB".CONT_OK
L "SEND_WDB".STATUS
T "SEND_WDB".STATUS_SAV //save STATUS
NOP 0
NOP 0 //additional user functions
NOP 0
BE
// -------------------------------
// verify "cycle with error"
// SEND_ERROR = 1
// -------------------------------
CHER: AN "SEND_WDB".ERROR //check SEND_ERROR
BEC //close the block if no error has occurred
// -------------------------------
// "cycle with error"
// -------------------------------
L "SEND_WDB".CONT_ERR // "cycle with error"
+ 1 //increment counter
T "SEND_WDB".CONT_ERR
L "SEND_WDB".STATUS
T "SEND_WDB".STATUS_SAV //save STATUS
NOP 0
NOP 0 //error handling
NOP 0
BE
调用FB3的程序如下,我在DB31里面的数据是Byte,奇怪的是不管我怎么改变数据,
我测得的发送口上的数据总是不变,感觉就是好像发送的时候根本就不是在发送我
想要发送的数据。我看到一位大侠说用ASCII通信协议时,还要用一个DB设置协议,
是不是这个问题,怎么设?我的调用FB3的方法,发送数据的指向不对吗?作为新
手,我怀疑我是不是有个基本错误。请指教。
L 256 //LADDR
T "SEND_WDB".LADDR
L 2
T "SEND_WDB".LEN //LEN
L 31 //DB_NO
T "SEND_WDB".DB_NO
L 0 //DBB_NOO
T "SEND_WDB".DB_NOO
// ------------------------
// SEND with instance DB
// ------------------------
CALL "P_SEND" , "DB_SEND"
REQ :="SEND_WDB".REQ
R :="SEND_WDB".R
LADDR :="SEND_WDB".LADDR
DB_NO :="SEND_WDB".DB_NO
DBB_NO:="SEND_WDB".DB_NOO
LEN :="SEND_WDB".LEN
DONE :="SEND_WDB".DONE
ERROR :="SEND_WDB".ERROR
STATUS:="SEND_WDB".STATUS
// ------------------------
// generate edge for SEND_REQ
// ------------------------
AN "SEND_WDB".REQ //SEND_REQ
S "SEND_WDB".REQ //set SEND_REQ
O "SEND_WDB".DONE //SEND_DONE
O "SEND_WDB".ERROR //SEND_ERROR
R "SEND_WDB".REQ //reset SEND_REQ
// -------------------------------
// verify "cycle without error"
// -------------------------------
AN "SEND_WDB".DONE //verify SEND_DONE
JC CHER //if SEND_DONE = 0, jump to CHER
//and check SEND_ERROR
// -------------------------------
// "cycle without error"
// SEND_DONE = 1
// -------------------------------
L "SEND_WDB".CONT_OK // "cycle without error"
+ 1 //increment counter
T "SEND_WDB".CONT_OK
L "SEND_WDB".STATUS
T "SEND_WDB".STATUS_SAV //save STATUS
NOP 0
NOP 0 //additional user functions
NOP 0
BE
// -------------------------------
// verify "cycle with error"
// SEND_ERROR = 1
// -------------------------------
CHER: AN "SEND_WDB".ERROR //check SEND_ERROR
BEC //close the block if no error has occurred
// -------------------------------
// "cycle with error"
// -------------------------------
L "SEND_WDB".CONT_ERR // "cycle with error"
+ 1 //increment counter
T "SEND_WDB".CONT_ERR
L "SEND_WDB".STATUS
T "SEND_WDB".STATUS_SAV //save STATUS
NOP 0
NOP 0 //error handling
NOP 0
BE