EPSON 代码程序
1.EPSON SPEL+ 语言代码示例:
//
String RCdata$, InData$, toks$(0), data1$, data2$, data3$ //定义字符型变量名需要添加“$”符号
Integer N, x
Double VX(500), VY(500), VZ(500)
#define delay_Time 0.1
Function mainSetNet #201, "192.168.60.5", 8000, CRLF, NONE //当控制器作为客户端的时候ip-set有效 OpenNet #201 As Server //打开#201服务器端口(作为服务器)Print "wait Connect ok..."WaitNet #201 //等待端口打开Print "Connect#201 ok."Print #201, "RC.OK"
loop1:Call communication //pc通信 Input #202, RCdata$ ParseStr RCdata$, toks$(), "," //将字符串按间隔符号" "拆分成多组数据. Print "指令=", toks$(0)//解析RCdata$判断控制If toks$(0) = "CLOSE" ThenPrint "接收到控制类型数据."Call close //关闭机器人ElseIf UBound(toks$()) >= 1 Then //如果toks$(1)不为空则判断为点数据Call ParsePoint //解析函数Call movePGoTo loop1ElsePrint "数据无效请重新输入:"GoTo loop1 // 继续循环EndIf
Fend
//
Function communication //TCP/IP 网口通信
succRC:If ChkNet(201) > 0 Then //Line Input #201, InData$ //从端口接收字符到一个或多个变量中//Print "InData$=", InData$Read #201, RCdata$, ChkNet(201) //从端口接收一行以上字符到一个字符串变量中(指定读入的字节数)Print "RCdata$=", RCdata$ElseWaitNet #201Print "等待数据接受"GoTo succRCEndIfFend
//
Function ParsePoint //解析数据:节点3维坐标点N = Val(toks$(0)) //获取点数//VX(1) = Val(toks$(1))Print "坐标点数N=", NInteger iVX(0) = VY(0) = VZ(0) = 0For i = 1 To N Step 1VX(i) = Val(toks$(i))VY(i) = Val(toks$(N + i))VZ(i) = Val(toks$(2 * N + i))P(i) = XY(VX(i), VY(i), VZ(i), 0)Print " X(i) =", VX(i), "Y(i) =", VY(i), "Z(i) =", VZ(i) //显示坐标值Next
Fend
//
Function WaiteP //移动到待机点If Motor = Off ThenMotor On //打开电机Power LowSpeed 50Accel 30, 30EndIfTool 0 //设置工具坐标系为0Go waitPFend
//
Function movePIf Motor = Off ThenMotor OnPower LowSpeedS 50AccelS 50EndIfCall WaiteP //1 回到待机点Tool 2 //2 设置工具坐标系2Integer iCurve "mycurve", O, 0, 4, P(1:N) //3 用自由曲线制作用于 CP 控制的数据与点Jump P1 -Z(-10) //4 运动到开始点上方10mm处CVMove "mycurve" //5 执行定义的自由曲线CP 动作Go P(N) -Z(-10) //6 运动到结束点上方10mm处////Jump P1 -Z(-10) //偏移Z轴坐标Z=P1z-z(-10)mm)移动到P1,如:P1z=-20 则 Z=-10//CP On //运动CP模式:在多个动作连续进行时//For i = 1 To N Step 1//Go P(i)//Next//CP Off//Jump P(N) -Z(-10)// Call WaiteP //回到待机点FendFunction close //关机CloseNet #201If Motor = On ThenMotor OffEndIf
Fend
//
2.关键函数:
Curve,CVMove 函数
3.代码截图