s7_200plc只能作profibus_dp總線上的從站這是常識(shí)。但前不久有個(gè)項(xiàng)目,控制器是s7_200(226),系統(tǒng)中有一個(gè)傳感器是p+f多圈編碼器(dp接口)。要想獲得編碼器的數(shù)據(jù)只有用s7_200的自由端口模式來模仿dp主站才有可能實(shí)現(xiàn)。按這個(gè)思路,先在wlc(pc+cp5611+winac)上對p+f編碼器進(jìn)行組態(tài),聯(lián)通后再截取wlc與p+f編碼器的握手?jǐn)?shù)據(jù)包和數(shù)據(jù)交換包。
wlc呼叫: 68 05 05 68 85 82 6d 3c 3e ee 16
p+f回答: 68 0b 0b 68 82 85 08 3e 3c 02 05 00 ff 50 46 25 16
wlc呼叫: 68 2c 2c 68 85 82 5d 3d 3e b8 0f 0f 0b 50 46 00 00 4a 00 00 10 00 02 00 00 00 00 00 00 00 00 00 00 00 82 00 00 00 00 00 00 7f ff 00 00 10 00 02 c4 16
p+f回答: e5
wlc呼叫: 68 07 07 68 85 82 7d 3e 3e f1 d0 c1 16
p+f回答: e5
wlc呼叫: 68 05 05 68 85 82 5d 3c 3e de 16
p+f回答: 68 3e 3e 68 82 85 08 3e 3c 00 0c 00 02 50 46 33 00 4a 01 00 00 20 00 10 00 00 00 10 00 00 00 10 01 01 09 09 00 00 00 00 00 fe cd 78 00 00 00 00 00 00 20 00 02 00 00 00 50 46 33 38 39 37 36 32 38 38 bd 16
wlc請求數(shù)據(jù):68 07 07 68 05 02 7d 00 00 00 00 84 16
p+f回答數(shù)據(jù):68 09 09 68 02 05 08 07 f7 8b 75 00 00 0d 16
根據(jù)以上握手和交換的數(shù)據(jù)包,用s7_200的自由口模仿wlc的呼叫,并接收p+f的回答數(shù)據(jù)包,再從回答數(shù)據(jù)包里摘出編碼器的轉(zhuǎn)角編碼數(shù)據(jù)就大功告成了。