天天看点

ACS运动控制:ACSPL+ 总结一、ACSPL+程序语法(类C语言?)二、运动部分: ACSPL+语言 vs G代码

文章目录

  • 一、ACSPL+程序语法(类C语言?)
    • 1、循环 结构
    • 2、逻辑判断关键字
  • 二、运动部分: ACSPL+语言 vs G代码
    • 1、G00~G04 与ACSPL+的对应关系
      • 1.1、G00 空走 速度G129、加速度(?)、加加速度? --- PTP点对点运动。
      • 1.2、G04 延时代码
      • 1.3、M30 程序停止代码
      • 1.4、G01/G02/G03 直线/圆弧 分段运动 vs XSEG:Line Arc1 Arc2 扩展分段运动。
        • 1.4.1、XSEG Motion Parameterization 运动参数设置:
        • 1.4.2、XSEG Segment Parameterization 段运动(line/arc1/arc2)参数:
        • 1.4.3、文档其他功能:
        • 1.4.4、圆弧G02/G03测试需求 :
    • 2、运动控制需要的变量接口 :加速度、加加速度、拐点控制、C2点控制方法,正负软件限位值设定。

一、ACSPL+程序语法(类C语言?)

SPiiPlus Command & Variable Reference Guide - 2.6:程序流 命令(IF,WHILE,BLOCK…ENDS …)

1、循环 结构

!1:for 循环10次
loop 10
    i = i+1
    wait 1000
    disp "%d",i
end
           
!2:while 死循环,0轴在(-100~100)之间来回运动,/e的意思:该行程序执行完成之后,ptp/e的下一行程序才会被执行。等价于 ptp + till ^AST(0).#MOVE +下一行程序
while 1
    ptp/e 0,100
    ptp/e 0,-100
end
           

2、逻辑判断关键字

关键字 功能
&
|

二、运动部分: ACSPL+语言 vs G代码

1、G00~G04 与ACSPL+的对应关系

1.1、G00 空走 速度G129、加速度(?)、加加速度? — PTP点对点运动。

;test1 - GCode
G129=100 ;设置G00速度比例
G00 X100 Y100
G00 X0 Y0
M30
           
!test1 - ACSPL+
!速度设置的方式:ptp/v (轴号),速度大小(单位:mm/s)
ptp/ve (x,y) ,100,100,400
ptp/ve (x,y),0,0,400
stop
           
!上机实测代码:
real time1,time2,delta_time
time1=TIME
ptp/v (x,y) ,100,100,100
till ^AST(x).#MOVE
time2=TIME
delta_time = time2-time1
disp "delta_time=%f",delta_time
ptp/ve (x,y),0,0,100
STOP
           

1.2、G04 延时代码

;延时1s  (单位:s)
G04 1 
           
!ACSPL+  (单位:ms)
WAIT 1000
           

1.3、M30 程序停止代码

;停止结束
M30
           
!ACSPL+ 
STOP
           

1.4、G01/G02/G03 直线/圆弧 分段运动 vs XSEG:Line Arc1 Arc2 扩展分段运动。

(ACSPL+中支持的G代码 格式中需要加逗号(comma),逗号的概念类似于ACSPL+语言中的"/"。

举例:/v,/f 在G代码中表现为:,f ,p ;不加逗号,也是有效的~)

ACS中G代码定义的概念:

参考文档:《GSP G&M Code Extension to ACSPL+ Reference Guide.pdf》

An XSEG motion moves axes along a continuous path, defined as a sequence of linear and arc segments on a plane.
XSEG provides many sophisticated features, such as automatic corner rounding, building up velocity profiles using the multi-segment look-ahead algorithm, and digital output synchronization with the motion.

XSEG Automatic Mode and Parameterized Mode

In general, there are two types of parameterizations:

1、XSEG Motion Parameterization - XSEG parameters which are relevant for the whole motion.

2、XSEG Segment Parameterization - XSEG parameters which are relevant for part of the motion (a single segment or few segments).

1.4.1、XSEG Motion Parameterization 运动参数设置:

XSEG/switch (), ???

例子1:使用/switch () 方式,指定XY插补运动的速度是500、拐点速度是100 ;在G代码中,用来设置运动参数用的是G200。

!In ACSPL+: 
SEG/vj (0,1), 0,0,500,100
           
;In GSP:
G200 ,F500 ,J100
           

1.4.2、XSEG Segment Parameterization 段运动(line/arc1/arc2)参数:

例子2:指定一个直线段运动的运动速度是500。

!In ACSPL+: 
LINE/v (0,1),100,100, 500
           
;In GSP: 
G01 X100 Y100 ,F500
           

1.4.3、文档其他功能:

4.7.3 Extended G02/G03 Definition with Helical Interpolation - 螺旋线插补

4.9 Parts Rotation - 旋转命令

ex1: (x , y) 绕原点逆时针旋转θ角度,旋转后的坐标 (s , t):

s = xcosθ + y(-sinθ)

t = xsinθ + y(cosθ)

ex2: xoy坐标系逆时针旋转θ角度变成新坐标系sot,点旋转后的坐标 (s,t):

s = xcosθ + y(sinθ)

t = x*(-sinθ) + y*(cosθ)

总结ex1与ex2,ex2的逆时针旋转 = ex1的顺时针旋转效果

ACS运动控制:ACSPL+ 总结一、ACSPL+程序语法(类C语言?)二、运动部分: ACSPL+语言 vs G代码
ACS运动控制:ACSPL+ 总结一、ACSPL+程序语法(类C语言?)二、运动部分: ACSPL+语言 vs G代码

1.4.4、圆弧G02/G03测试需求 :

!In ACSPL+:圆弧运动可使用2种书写格式定义:ARC1与ARC2。

!ARC1:指定圆心位置与最后到达的位置,半径通过计算最后到达的终点位置离圆心位置的距离自动得出,顺逆运动方向使用+/-表示;

!设轴当前位置(x0,y0),实现40mm/s速度,画一个180°的半圆,半径10mm,顺时针运动:

XSEG/v (x,y),x0,y0,40

arc1(x,y),x0+10,y0,x0+20,y0,+

ENDS (x,y)

!上机测试代码1:
real x0,y0
VEL(x)  = 40
ACC(x)  = 5000
DEC(x)  = 5000
JERK(x) = 25000
KDEC(x) = 20000

VEL(y)  = 40
ACC(y)  = 5000
DEC(y)  = 5000
JERK(y) = 25000
KDEC(y) = 20000
ptp/ve (0,1),0,0,100
disp "go to (%0.01f,%0.01f)",FPOS(x),FPOS(y)
ptp/v (0,1),100,100,100
till ^AST(x).#MOVE
disp "go to (%0.01f,%0.01f)",FPOS(x),FPOS(y)
x0 = FPOS(x)
y0 = FPOS(y)
disp "start arc1_R10_180 ,current pos(%0.01f,%0.01f)",FPOS(x),FPOS(y)
xseg/v (x,y),x0,y0,40
       arc1(x,y),x0+10,y0,x0+20,y0,+
ends(x,y)
till ^AST(x).#MOVE
disp "end arc1_R10,current pos(%0.01f,%0.01f)",FPOS(x),FPOS(y)
stop
           
!上机测试代码2:40mm/s 速度 ,重复画圆测试
VEL(x)  = 40
ACC(x)  = 5000
DEC(x)  = 5000
JERK(x) = 25000
KDEC(x) = 20000

VEL(y)  = 40
ACC(y)  = 5000
DEC(y)  = 5000
JERK(y) = 25000
KDEC(y) = 20000
ptp/ve (0,1),0,0,100
disp "go to (%0.01f,%0.01f)",FPOS(x),FPOS(y)
ptp/v (0,1),100,100,100
till ^AST(x).#MOVE
disp "go to (%0.01f,%0.01f)",FPOS(x),FPOS(y)
xseg/v (x,y),100,100,40
disp "start arc1_R10 forever,current pos(%0.01f,%0.01f)",FPOS(x),FPOS(y)
while 1    !死循环,重复画圆
arc1(x,y),100,90,100,100,-    !沿顺时针方向画整圆
end
disp "end arc1_R10,current pos(%0.01f,%0.01f)",FPOS(x),FPOS(y)
ends(x,y)
stop
           
ARC2:指定圆心位置与旋转角度,半径通过计算前一段运动的终点位置离圆心位置的距离自动得出,顺逆运动方向使用+/-表示;
ACS运动控制:ACSPL+ 总结一、ACSPL+程序语法(类C语言?)二、运动部分: ACSPL+语言 vs G代码
ACS运动控制:ACSPL+ 总结一、ACSPL+程序语法(类C语言?)二、运动部分: ACSPL+语言 vs G代码

2、运动控制需要的变量接口 :加速度、加加速度、拐点控制、C2点控制方法,正负软件限位值设定。

正负限位距离设定:(以x轴为例)

参考文档:SPiiPlus Command & Variable Reference Guide,3.8.8 FDEF (Page309) ,3.8.9FMASK。

!激活软件限位响应功能(到了软件设定的限位值, 轴停+弹窗报警,FDEF = ):
FDEF(X).#LL =1    !Enable the axis left limit default response 使能 软件左限位
FDEF(X).#RL =1    !Enable the axis right limit default response 使能 软件右限位
!设置限位值 set soft limit value
SLLIMIT(X)= -40         !set soft left limit (user units :mm) 设置左限位 -40mm
SRLIMIT(X)= 500         !set soft right limit(user units :mm) 设置右限位 500mm
!测试软件限位功能
ptp/ve (0),-50,100
           
!激活实体正负限位开关 轴停响应,反方向可正常运动
FMASK(x).#SLL =1          !Enable the axis Soft Lower limit default  response
FMASK(x).#SRL =1          !Enable the axis Soft Upper limit default  response
           
!中断语法,可用于报警刷新:
ON...RET
           

继续阅读