汇川PLC学习Day5:汇川PLC CNC入门教程(插补学习)
一、CNC轨迹程序文件添加
(一)添加CNC轨迹程序
(二)CNC三种编译模式
(三)CNC轨迹处理综合流程图
说明:三种轨迹输入方式各有适合的应用设备类型,不同轨迹数据类型,在编译解码时需要使用对应的功能块来处理。
二、CNC程序编写
(一)常见G代码及G代码详细查询
1. 常见G代码
2. G代码详细查询
(二)目标图形
(三)CNC代码
三、PLC程序编写
(一)CNC路径解码
(二)平滑处理
(三)速度检查
(四)插补运算
(五)坐标变换
(六)轴位置控制
(七)PLC典型程序
(八)文件代码
0. Main task
PROGRAM PLC_PRG
VAR
END_VAR
St1_Auto_POU();
1. St1_CNC_POU
PROGRAM St1_CNC_POU
VAR
//CNC_REF
SMC_NCDecoder_0 : SMC_NCDecoder;
SMC_SmoothPath_0 : SMC_SmoothPath; //轨迹平滑处理
SMC_CheckVelocities_0 : SMC_CheckVelocities; //轨迹速度检查
SMC_Interpolator_0 : SMC_Interpolator;
SMC_TRAFO_Gantry3_0 : SMC_TRAFO_Gantry3;
SMC_ControlAxisByPos_X : SMC_ControlAxisByPos;
SMC_ControlAxisByPos_Z : SMC_ControlAxisByPos;
EM17_b1 : ARRAY [0..200] OF SMC_GEOINFO;
EM17_b2 : ARRAY [0..200] OF SMC_GEOINFO;
wMStates : WORD;
nStepCNC : UINT; //步数
bFinish : BOOL; //气缸动作完成
SMC_NCDecoder_1 : SMC_NCDecoder;
SMC_SmoothPath_1 : SMC_SmoothPath; //轨迹平滑处理
SMC_CheckVelocities_1 : SMC_CheckVelocities; //轨迹速度检查
EM18_b1 : ARRAY [0..200] OF SMC_GEOINFO;
EM18_b2 : ARRAY [0..200] OF SMC_GEOINFO;
END_VAR
CNC0_ACT();
2. CNC0_ACT();
//CNC路径解码
SMC_NCDecoder_0(
ncprog:= CNC,
bExecute:=bCNCGlueStart0 ,
bAbort:= ,
bAppend:= ,
bStepSuppress:= ,
piStartPosition:= ,
nSizeOutQueue:= SIZEOF(EM17_b1),
pbyBufferOutQueue:=ADR(EM17_b1) ,
bEnableSyntaxChecks:= ,
bDone=> ,
bBusy=> ,
bError=> ,
wErrorID=> ,
poqDataOut=> ,
iStatus=> ,
iLineNumberDecoded=> ,
GCodeText=> );
//平滑处理
SMC_SmoothPath_0(
bExecute:=bCNCGlueStart0 ,
bAbort:= ,
bAppend:= ,
poqDataIn:=SMC_NCDecoder_0.poqDataOut,
dEdgeDistance:= ,
dAngleTol:= ,
nSizeOutQueue:= SIZEOF(EM17_b2) ,
pbyBufferOutQueue:=ADR(EM17_b2) ,
eMode:= ,
bSymmetricalDistances:= ,
bImprovedSymmetricCuts:= ,
eAddAxMode:= ,
dMinimumCurvatureRadius:= ,
bCheckCurvature:= ,
dRelativeCurvatureTol:= ,
bCheckAddAxVelJump:= ,
dMaxAddAxVelDifference:= ,
bDone=> ,
bBusy=> ,
bError=> ,
wErrorID=> ,
poqDataOut=> ,
udiStopsDueToCurvatureRadius=> );
//速度检查
SMC_CheckVelocities_0(
bExecute:=bCNCGlueStart0,
bAbort:=,
poqDataIn:=SMC_SmoothPath_0.poqDataOut ,
dAngleTol:=180 ,
bCheckAddAxVelJump:= ,
dMaxAddAxVelDifference:= ,
bBusy=> ,
bError=> ,
wErrorID=> ,
poqDataOut=> );
//插补功能
SMC_Interpolator_0(
bExecute:= SMC_SmoothPath_0.bDone,
poqDataIn:=SMC_CheckVelocities_0.poqDataOut ,
bSlow_Stop:= ,
bEmergency_Stop:=,
bWaitAtNextStop:= ,
dOverride:= ,
iVelMode:= ,
dwIpoTime:=2000 ,
dLastWayPos:= ,
bAbort:= ,
bSingleStep:= ,
bAcknM:= bFinish,
bQuick_Stop:= ,
dQuickDeceleration:= ,
dJerkMax:= ,
dQuickStopJerk:= ,
bSuppressSystemMFunctions:= ,
bDone=>bCNCGlueDown0 ,
bBusy=>bCNCGluebusy0,
bError=>bCNCGlueErr0<