好友
阅读权限10
听众
最后登录1970-1-1
|
我是一个C语言小白 从事CNC编程 有的时候做后处理需要用到C语言 但又不知从何入手
这是后处理的代码 大佬们 这类代码看着难吗
cyclecode<>2088 && cyclecode<>2089 && Cyclecode<>2084 && Cyclecode<>2098 && Cyclecode<>2099 && cyclecode<>2101
ENDDEFINE
DEFINE NextCycleIsMilling \\
(nextcyclecode=2088) || (nextcyclecode=2089) || (nextCyclecode=2084) || (nextCyclecode=2098) || (nextCyclecode=2099) || (nextcyclecode=2101) || \\
(nextcyclecode=2095) || (nextcyclecode=2094) || (nextcyclecode=2093) || (nextcyclecode=2092) || (nextcyclecode=2091) || (nextcyclecode=1035) || \\
(nextcyclecode=1034) || (nextcyclecode=2090) || (nextcyclecode=1033) || (nextcyclecode=2097) || (nextcyclecode=1037) || (nextcyclecode=2087) || \\
(nextcyclecode=1038) || (nextcyclecode=2067) || (nextcyclecode=1035) || (nextcyclecode=2085) || (nextcyclecode=2084) || (nextcyclecode=2083) || \\
(nextcyclecode=2082) || (nextcyclecode=2081) || (nextcyclecode=2080)
ENDDEFINE
DEFINE NC_ON IF (Turretcode=2) NCOUTPUTOFF ELSE NCOUTPUTON ENDIF
ENDDEFINE
DEFINE NC_OFF NCOUTPUTOFF
ENDDEFINE
DEFINE IF_G68Needed \\
IF (Bvalue<>0)
ENDDEFINE
DEFINE Blockskip2 IF (nextclfile(118)=1) "/2" ENDIF \\
ENDDEFINE
DEFINE OutputStartSpeed \\
IF ((cyclecode<>1022)&&(SPINDLEUNIT=CONSTANTSURFACE)) \\ ## If G96 and not drilling
IF (nextdim(1)=0) StartSpeed=(nextclfile(198)) \\
ELSE \\
IF (MEASUREMENTCODE=INCH) StartSpeed=(nextclfile(418)*6/3.1416/ABS(nextdim(1))) \\
ELSE StartSpeed=(nextclfile(418)/3.1416/ABS(nextdim(1))*500) ENDIF \\
IF (StartSpeed>NEXTCLFILE(198)) StartSpeed=(nextclfile(198)) ENDIF \\
ENDIF \\
G97 S*(StartSpeed) \\
ELSE \\
IF (Nextclfile(194)>Nextclfile(198)) G97 S*(Nextclfile(198)) ELSE G97 S* ENDIF \\
ENDIF
ENDDEFINE
DEFINE OutPutWorkSystemCode \\
G* \\
ENDDEFINE
DEFINE ChangeToDiametral $NC_OFF DIA* $NC_ON
DEFINE ChangeToRadial $NC_OFF RAD* $NC_ON
DEFINE OutputOperationName
: BLANKLINE
: IF (TurretCode=1) N* "(clstring(613))" ENDIF
: COMMENT
ENDDEFINE
DEFINE ResetSpeedAndFeed
: $NC_OFF
: F*(999999) F__*(999999) S*(999999) S__*(999999)
: $NC_ON
ENDDEFINE
DEFINE FeedWrapMilling \\
DZW=(nextdim(3)-presdim(3)) DCW=(nextdim(30)-presdim(30)) RadiusW=(nextdim(1)) \\
WrapFeed=( ( Nextclfile(191)* SQRT( SQR(DZW)+SQR(DCW) ) ) / SQRT( SQR(DZW)+SQR(DCW*3.1416*RadiusW/180) ) ) \\
F(WrapFeed) ##"DZ" DEBUG*(DZW) "DC" DEBUG*(DCW) "X" DEBUG*(RadiusW)
ENDDEFINE
DEFINE Feed5AxisMilling \\ ## works only when only the C-axis is moving !!!!!!!!!!!
DZW=(nextdim(1)-presdim(1)) DCW=(nextdim(30)-presdim(30)) RadiusW=(nextdim(2)) \\
WrapFeed=( ( Nextclfile(191)* SQRT( SQR(DZW)+SQR(DCW) ) ) / SQRT( SQR(DZW)+SQR(DCW*3.1416*RadiusW/180) ) ) \\
F(WrapFeed) ##"DZ" DEBUG*(DZW) "DC" DEBUG*(DCW) "X" DEBUG*(RadiusW)
ENDDEFINE
DEFINE Feed IF (MillTurnCode=TurnCycle) \\
FEEDUNIT IF (FEEDUNIT=FEEDPERREVOLUTION) F__(nextclfile(416)) ELSE F(nextclfile(191)) ENDIF \\
ELSE \\
IF ( ( (cyclecode=2089) || (cyclecode=2084) ) && (nextclfile(262)=2) ) \\
$FeedWrapMilling \\
ELSE \\
F__ \\
ENDIF \\
ENDIF
ENDDEFINE
DEFINE ComputeBvalue
: IF (GlobalTopNormal(1)=0) Bvalue=(90) ## Horizontal B0 Vertical B90
: ELSE Bvalue=(atn(GlobalTopNormal(2)/GlobalTopNormal(1))) ENDIF
: IF ( Int(GlobalTopNormal(1)*1000)<0 ) Bvalue=(Bvalue+180) ENDIF
: Bvalue=(Bvalue-90)
ENDDEFINE
DEFINE outputcoolanton \\
IF (nextclfile(214)=0) ELSE \\
IF (nextclfile(214)=6) "M26" ELSE "M08" ENDIF \\
ENDIF
ENDDEFINE
DEFINE TurningToolOrientation \\
IF (cyclecode=1022) \\
IF (SpindleCode=SpindleAux) BValue=(90) ELSE BValue=(-90) ENDIF \\
ELSE \\
IF ( nextclfile(402)=11 ) BValue=(180) ENDIF \\ ##1V
IF ( nextclfile(402)=12 ) BValue=(180) ENDIF \\ ##2V
IF ( nextclfile(402)=13 ) BValue=(0) ENDIF \\ ##3V
IF ( nextclfile(402)=14 ) BValue=(0) ENDIF \\ ##4V
IF ( nextclfile(402)=15 ) BValue=(90) ENDIF \\ ##1H
IF ( nextclfile(402)=16 ) BValue=(-90) ENDIF \\ ##2H
IF ( nextclfile(402)=17 ) BValue=(-90) ENDIF \\ ##3H
IF ( nextclfile(402)=18 ) BValue=(90) ENDIF \\ ##4H
ENDIF
ENDDEFINE
DEFINE OutputNextTool \\
IF (CountToolT1=LastToolT1) \\
IF (presenttool<>FirstToolUpperTurret) T*(FirstToolUpperTurret+100) ENDIF \\
ELSE T*(nexttool*100) "(call next tool)" \\
ENDIF
ENDDEFINE
# DEFINE OutputToolNumberUpperTurret \\
M99 \\
IF (FirstToolUpperTurret=0) FirstToolUpperTurret=(PresentTool) ENDIF \\
IF (MillTurnCode=MillCycle) \\
T*((presenttool*100)+nextclfile(121)) \\
ELSE \\
T*((presenttool*100)+nextclfile(121)) \\
ENDIF
ENDDEFINE
DEFINE OutputG361
: IF (MillTurnCode=MillCycle)
$ComputeBvalue
: ELSE
: $TurningToolOrientation
: ENDIF
: ## "M111 (Brake disk unclamp)"
: ## "M107"
: ## "G368" B__*(Bvalue) inG368=(1)
: ## "M170"
: ## "M110 (Brake disk clamp)"
ENDDEFINE
DEFINE OutPutWorkPlane \\
IF (MillTurnCode=TurnCycle) \\
IF(TCUPPER=0) \\
G18 \\
ELSE \\
G18* \\
ENDIF \\
ELSE \\
IF (GlobalTopNormal(2)=0) IF(TCUPPER=0) G17 ELSE G17* ENDIF ENDIF \\ ## FACE
IF (GlobalTopNormal(1)=0) IF(TCUPPER=0) G19 ELSE G19* ENDIF ENDIF \\ ## OD
\\ ## IF (GlobalTopNormal(1)<>0 && GlobalTopNormal(2)<>0 ) FACE_OD=(3) ENDIF ## ANGLE
ENDIF \\
\\ ## : "*** CYCLECODE=" _*(CYCLECODE)
ENDDEFINE
|
|
发帖前要善用【论坛搜索】功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。 |
|
|
|
|