📄 interp_cycles.cc
字号:
Side effects: A number of moves are made as described below. This cycle is a modified version of [Monarch, page 5-24] since [NCMS, pages 98 - 100] gives no clue as to what the cycle is supposed to do. [KT] does not have a back boring cycle. [Fanuc, page 132] in "Canned cycle II" describes the G87 cycle as given here, except that the direction of spindle turning is always clockwise and step 7 below is omitted in [Fanuc].Called by: convert_cycle_xy convert_cycle_yz convert_cycle_zxFor the XY plane, this implements the following RS274/NGC cycle, whichis usually back boring. The situation is that you have a through holeand you want to counterbore the bottom of hole. To do this you put anL-shaped tool in the spindle with a cutting surface on the UPPER sideof its base. You stick it carefully through the hole when it is notspinning and is oriented so it fits through the hole, then you move itso the stem of the L is on the axis of the hole, start the spindle,and feed the tool upward to make the counterbore. Then you get thetool out of the hole.1. Move at traverse rate parallel to the XY-plane to the point with x-value offset_x and y-value offset_y.2. Stop the spindle in a specific orientation.3. Move the z-axis only at traverse rate downward to the bottom_z.4. Move at traverse rate parallel to the XY-plane to the x,y location.5. Start the spindle in the direction it was going before.6. Move the z-axis only at the given feed rate upward to the middle_z.7. Move the z-axis only at the given feed rate back down to bottom_z.8. Stop the spindle in the same orientation as before.9. Move at traverse rate parallel to the XY-plane to the point with x-value offset_x and y-value offset_y.10. Move the z-axis only at traverse rate to the clear z value.11. Move at traverse rate parallel to the XY-plane to the specified x,y location.12. Restart the spindle in the direction it was going before.CYCLE_MACRO has positioned the tool at (x, y, r, a, b, c) before this starts.It might be useful to add a check that clear_z > middle_z > bottom_z.Without the check, however, this can be used to counterbore a hole inmaterial that can only be accessed through a hole in material above it.For the XZ and YZ planes, this makes analogous motions.*/int Interp::convert_cycle_g87(CANON_PLANE plane, //!< selected plane double x, //!< x-value where cycle is executed double offset_x, //!< x-axis offset position double y, //!< y-value where cycle is executed double offset_y, //!< y-axis offset position double r, //!< z_value of r_plane double clear_z, //!< z-value of clearance plane double middle_z, //!< z-value of top of back bore double bottom_z, //!< value of z at bottom of cycle CANON_DIRECTION direction) //!< direction spindle turning at outset{ static char name[] = "convert_cycle_g87"; CHK(((direction != CANON_CLOCKWISE) && (direction != CANON_COUNTERCLOCKWISE)), NCE_SPINDLE_NOT_TURNING_IN_G87); cycle_traverse(plane, offset_x, offset_y, r); STOP_SPINDLE_TURNING(); ORIENT_SPINDLE(0.0, direction); cycle_traverse(plane, offset_x, offset_y, bottom_z); cycle_traverse(plane, x, y, bottom_z); if (direction == CANON_CLOCKWISE) START_SPINDLE_CLOCKWISE(); else START_SPINDLE_COUNTERCLOCKWISE(); cycle_feed(plane, x, y, middle_z); cycle_feed(plane, x, y, bottom_z); STOP_SPINDLE_TURNING(); ORIENT_SPINDLE(0.0, direction); cycle_traverse(plane, offset_x, offset_y, bottom_z); cycle_traverse(plane, offset_x, offset_y, clear_z); cycle_traverse(plane, x, y, clear_z); if (direction == CANON_CLOCKWISE) START_SPINDLE_CLOCKWISE(); else START_SPINDLE_COUNTERCLOCKWISE(); return INTERP_OK;}/****************************************************************************//*! convert_cycle_g88Returned Value: int If the spindle is not turning clockwise or counterclockwise, this returns NCE_SPINDLE_NOT_TURNING_IN_G88. Otherwise, it returns INTERP_OK.Side effects: See belowCalled by: convert_cycle_xy convert_cycle_yz convert_cycle_zxFor the XY plane, this implements the following RS274/NGC cycle,which is usually boring:1. Move the z-axis only at the current feed rate to the specified z-value.2. Dwell for the given number of seconds.3. Stop the spindle turning.4. Stop the program so the operator can retract the spindle manually.5. Restart the spindle.CYCLE_MACRO has positioned the tool at (x, y, r, a, b, c) when this starts.For the XZ and YZ planes, this makes analogous motions.*/int Interp::convert_cycle_g88(CANON_PLANE plane, //!< selected plane double x, //!< x-value where cycle is executed double y, //!< y-value where cycle is executed double bottom_z, //!< value of z at bottom of cycle double dwell, //!< dwell time CANON_DIRECTION direction) //!< direction spindle turning at outset{ static char name[] = "convert_cycle_g88"; CHK(((direction != CANON_CLOCKWISE) && (direction != CANON_COUNTERCLOCKWISE)), NCE_SPINDLE_NOT_TURNING_IN_G88); cycle_feed(plane, x, y, bottom_z); DWELL(dwell); STOP_SPINDLE_TURNING(); PROGRAM_STOP(); /* operator retracts the spindle here */ if (direction == CANON_CLOCKWISE) START_SPINDLE_CLOCKWISE(); else START_SPINDLE_COUNTERCLOCKWISE(); return INTERP_OK;}/****************************************************************************//*! convert_cycle_g89Returned Value: int (INTERP_OK)Side effects: See belowCalled by: convert_cycle_xy convert_cycle_yz convert_cycle_zxThis implements the following RS274/NGC cycle, which is intended for boring:1. Move the z-axis only at the current feed rate to the specified z-value.2. Dwell for the given number of seconds.3. Retract the z-axis at the current feed rate to clear_z.CYCLE_MACRO has positioned the tool at (x, y, r, a, b, c) when this starts.For the XZ and YZ planes, this makes analogous motions.*/int Interp::convert_cycle_g89(CANON_PLANE plane, //!< selected plane double x, //!< x-value where cycle is executed double y, //!< y-value where cycle is executed double clear_z, //!< z-value of clearance plane double bottom_z, //!< value of z at bottom of cycle double dwell) //!< dwell time { cycle_feed(plane, x, y, bottom_z); DWELL(dwell); cycle_feed(plane, x, y, clear_z); return INTERP_OK;}/****************************************************************************//*! convert_cycleReturned Value: int If any of the specific functions called returns an error code, this returns that code. If any of the following errors occur, this returns the error code shown. Otherwise, it returns INTERP_OK. 1. The r-value is not given the first time this code is called after some other motion mode has been in effect: NCE_R_CLEARANCE_PLANE_UNSPECIFIED_IN_CYCLE 2. The l number is zero: NCE_CANNOT_DO_ZERO_REPEATS_OF_CYCLE 3. The currently selected plane in not XY, YZ, or XZ. NCE_BUG_PLANE_NOT_XY_YZ_OR_XZSide effects: A number of moves are made to execute a canned cycle. The current position is reset. The values of the cycle attributes in the settings may be reset.Called by: convert_motionThis function makes a couple checks and then calls one of threefunctions, according to which plane is currently selected.See the documentation of convert_cycle_xy for most of the details.*/int Interp::convert_cycle(int motion, //!< a g-code between G_81 and G_89, a canned cycle block_pointer block, //!< pointer to a block of RS274 instructions setup_pointer settings) //!< pointer to machine settings { static char name[] = "convert_cycle"; CANON_PLANE plane; int status; plane = settings->plane; if (block->r_flag == OFF) { if (settings->motion_mode == motion) block->r_number = settings->cycle_r; else ERM(NCE_R_CLEARANCE_PLANE_UNSPECIFIED_IN_CYCLE); } CHK((block->l_number == 0), NCE_CANNOT_DO_ZERO_REPEATS_OF_CYCLE); if (block->l_number == -1) block->l_number = 1; if (plane == CANON_PLANE_XY) { CHP(convert_cycle_xy(motion, block, settings)); } else if (plane == CANON_PLANE_YZ) { CHP(convert_cycle_yz(motion, block, settings)); } else if (plane == CANON_PLANE_XZ) { CHP(convert_cycle_zx(motion, block, settings)); } else ERM(NCE_BUG_PLANE_NOT_XY_YZ_OR_XZ); settings->cycle_l = block->l_number; settings->cycle_r = block->r_number; settings->motion_mode = motion; return INTERP_OK;}/****************************************************************************//*! convert_cycle_xyReturned Value: int If any of the specific functions called returns an error code, this returns that code. If any of the following errors occur, this returns the error code shown. Otherwise, it returns INTERP_OK. 1. The z-value is not given the first time this code is called after some other motion mode has been in effect: NCE_Z_VALUE_UNSPECIFIED_IN_XY_PLANE_CANNED_CYCLE 2. The r clearance plane is below the bottom_z: NCE_R_LESS_THAN_Z_IN_CYCLE_IN_XY_PLANE 3. the distance mode is neither absolute or incremental: NCE_BUG_DISTANCE_MODE_NOT_G90_OR_G91 4. G82, G86, G88, or G89 is called when it is not already in effect, and no p number is in the block: NCE_DWELL_TIME_P_WORD_MISSING_WITH_G82 NCE_DWELL_TIME_P_WORD_MISSING_WITH_G86 NCE_DWELL_TIME_P_WORD_MISSING_WITH_G88 NCE_DWELL_TIME_P_WORD_MISSING_WITH_G89 5. G83 is called when it is not already in effect, and no q number is in the block: NCE_Q_WORD_MISSING_WITH_G83 6. G87 is called when it is not already in effect, and any of the i number, j number, or k number is missing: NCE_I_WORD_MISSING_WITH_G87 NCE_J_WORD_MISSING_WITH_G87 NCE_K_WORD_MISSING_WITH_G87 7. the G code is not between G_81 and G_89. NCE_BUG_FUNCTION_SHOULD_NOT_HAVE_BEEN_CALLEDSide effects: A number of moves are made to execute the g-codeCalled by: convert_cycleThe function does not require that any of x,y,z, or r be specified inthe block, except that if the last motion mode command executed wasnot the same as this one, the r-value and z-value must be specified.This function is handling the repeat feature of RS274/NGC, whereinthe L word represents the number of repeats [NCMS, page 99]. We arenot allowing L=0, contrary to the manual. We are allowing L > 1in absolute distance mode to mean "do the same thing in the sameplace several times", as provided in the manual, although this seemsabnormal.In incremental distance mode, x, y, and r values are treated asincrements to the current position and z as an increment from r. Inabsolute distance mode, x, y, r, and z are absolute. In g87, i and jwill always be increments, regardless of the distance mode setting, asimplied in [NCMS, page 98], but k (z-value of top of counterbore) willbe an absolute z-value in absolute distance mode, and an increment(from bottom z) in incremental distance mode.If the r position of a cycle is above the current_z position, thisretracts the z-axis to the r position before moving parallel to theXY plane.In the code for this function, there is a nearly identical "for" loopin every case of the switch. The loop is the done with a compilermacro, "CYCLE_MACRO" so that the code is easy to read, automaticallykept identical from case to case and, and much shorter than it wouldbe without the macro. The loop could be put outside the switch, butthen the switch would run every time around the loop, not just once,as it does here. The loop could also be placed in the calledfunctions, but then it would not be clear that all the loops are thesame, and it would be hard to keep them the same when the code ismodified. The macro would be very awkward as a regular functionbecause it would have to be passed all of the arguments used by any ofthe specific cycles, and, if another switch in the function is to beavoided, it would have to passed a function pointer, but the differentcycle functions have different arguments so the type of the pointercould not be declared unless the cycle functions were re-written totake the same arguments (in which case most of them would have severalunused arguments).The motions within the CYCLE_MACRO (but outside a specific cycle) area straight traverse parallel to the selected plane to the givenposition in the plane and a straight traverse of the third axis only(if needed) to the r position.The CYCLE_MACRO is defined here but is also used in convert_cycle_yzand convert_cycle_zx. The variables aa, bb, and cc are used inCYCLE_MACRO and in the other two functions just mentioned. Those
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -