ABB机器人视觉应用和Socket通讯如何去实现
将此处应用分为四步讲解:一:建立通讯收发数据
二:解析数据
三: 点位数据类型转换
四:现场应用技巧
建立通讯收发数据
机器人与相机通讯一般采用TCP/IP无协议通讯,微软环境下成为socket,可收发字符串,数组,,,机器人通常做client。
ABB机器人端需要配备616-1 PC Interface选项。 确认机器人配备 616-1 选项,通讯网口可使用LAN,LAN3口或WAN口。
一、IP设定:
1. 点击主菜单——“控制面板”——“配置”——主题选择 Communication 2. 双击IP Setting ——输入地址——选择网口——添加标签。
(注意选择网口时检查不要与其他通讯如PROFINET 共用一个网口,否则后续程序运行将报错) 二、建立通讯:
1.为防止之前的连接为中断先插入Socketclose指令,socket1为新建的 Socketdev型程序数据
然后用Socketcreate创建连接
Socketconnect指定服务器的IP地址和端口,如创建失败则一直等待,创建成功则向下执行,在下一行做人机交互提醒通讯连接成功。 2.后续建立通讯收发字符串标准由相机规定,大致为发送字符串,接收字符串并判断该步是否成功,此处为康耐视相机,程序如下:
Start:
SocketClose socket1;
SocketCreate socket1;
SocketConnect socket1, "192.168.250.111", 23;
TPWrite "Connect sussessful!";
SocketReceive socket1\Str:=stringReceived;
TPWrite "server say_" + stringReceived;
SocketSend socket1\Str:="admin\0d\0a";
SocketReceive socket1\Str:=stringReceived;
IF stringReceived <> "Password: " THEN
TPErase;
TPWrite "Vision Login Error(Password Prompt)";
Stop;
GOTO Start;
ENDIF
TPWrite stringReceived;
SocketSend socket1\Str:="\0d\0a";
SocketReceive socket1\Str:=stringReceived;
TPWrite stringReceived;
IF stringReceived <> "User Logged In\0d\0a" THEN
TPErase;
TPWrite "Vision Login Error( Uers Login prompt)";
Stop;
GOTO Start;
ENDIF
SocketSend socket1\Str:="sw8\0d\0a";
SocketReceive socket1\Str:=stringReceived;
IF stringReceived = "1\0d\0a" THEN
TPWrite "Communication sussessful!";
ELSEIF stringReceived = "-2\0d\0a" THEN
TPWrite "Vision Return Error:-2";
ELSEIF stringReceived = "0\0d\0a" THEN
TPWrite "Vision Return Error:0";
ELSE
TPWrite "Vision Return Error";
ENDIF
3.触发拍照并接收位置数据
SocketSend socket1\Str:="gvu017\0d\0a";
SocketReceive socket1\Str:=Pose1string;
更多机器人资讯请点击:abb机器人
联系电话:18616560100