📄 interp_cycles.cc
字号:
CYCLE_MACRO(convert_cycle_g87(CANON_PLANE_YZ, aa, (aa + j), bb, (bb + k), r, clear_cc, i, cc, settings->spindle_turning)) break; case G_88: CHK(((settings->motion_mode != G_88) && (block->p_number == -1.0)), NCE_DWELL_TIME_P_WORD_MISSING_WITH_G88); block->p_number = block->p_number == -1.0 ? settings->cycle_p : block->p_number; CYCLE_MACRO(convert_cycle_g88(CANON_PLANE_YZ, aa, bb, cc, block->p_number, settings->spindle_turning)) settings-> cycle_p = block->p_number; break; case G_89: CHK(((settings->motion_mode != G_89) && (block->p_number == -1.0)), NCE_DWELL_TIME_P_WORD_MISSING_WITH_G89); block->p_number = block->p_number == -1.0 ? settings->cycle_p : block->p_number; CYCLE_MACRO(convert_cycle_g89(CANON_PLANE_YZ, aa, bb, clear_cc, cc, block->p_number)) settings->cycle_p = block->p_number; break; default: ERM(NCE_BUG_FUNCTION_SHOULD_NOT_HAVE_BEEN_CALLED); } settings->current_y = aa; /* CYCLE_MACRO updates aa and bb */ settings->current_z = bb; settings->current_x = clear_cc; settings->cycle_cc = block->x_number; if (save_mode != CANON_EXACT_PATH) SET_MOTION_CONTROL_MODE(save_mode, save_tolerance); return INTERP_OK;}/****************************************************************************//*! convert_cycle_zxReturned 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 y-value is not given the first time this code is called after some other motion mode has been in effect: NCE_Y_VALUE_UNSPECIFIED_IN_XZ_PLANE_CANNED_CYCLE 2. The r clearance plane is below the bottom_y: NCE_R_LESS_THAN_Y_IN_CYCLE_IN_XZ_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 a canned cycle.Called by: convert_cycleSee the documentation of convert_cycle_xy. This function is entirelysimilar. In this function aa represents z, bb represents x, and ccrepresents y.The CYCLE_MACRO is defined just before the convert_cycle_xy function.Tool length offsets work only when the tool axis is parallel to theZ-axis, so if this function is used, tool length offsets should beturned off, and the NC code written to take tool length into account.It is a little distracting that this function uses zx in some placesand xz in others; uniform use of zx would be nice, since that is theorder for a right-handed coordinate system. Also with that usage,permutation of the symbols x, y, and z would allow for automaticallyconverting the convert_cycle_xy function (or convert_cycle_yz) intothe convert_cycle_xz function. However, the canonical interface usesCANON_PLANE_XZ.*/int Interp::convert_cycle_zx(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_zx"; double aa; double aa_increment; double bb; double bb_increment; double cc; double clear_cc; double i; double j; double k; double old_cc; CANON_PLANE plane; double r; int repeat; CANON_MOTION_MODE save_mode; double save_tolerance; //save current path-following tolerance, to restore it lateron int status; plane = CANON_PLANE_XZ; if (settings->motion_mode != motion) { CHK((block->y_flag == OFF), NCE_Y_VALUE_UNSPECIFIED_IN_XZ_PLANE_CANNED_CYCLE); } block->y_number = block->y_flag == ON ? block->y_number : settings->cycle_cc; old_cc = settings->current_y; if (settings->distance_mode == MODE_ABSOLUTE) { aa_increment = 0.0; bb_increment = 0.0; r = block->r_number; cc = block->y_number; aa = block->z_flag == ON ? block->z_number : settings->current_z; bb = block->x_flag == ON ? block->x_number : settings->current_x; } else if (settings->distance_mode == MODE_INCREMENTAL) { aa_increment = block->z_number; bb_increment = block->x_number; r = (block->r_number + old_cc); cc = (r + block->y_number); /* [NCMS, page 98] */ aa = settings->current_z; bb = settings->current_x; } else ERM(NCE_BUG_DISTANCE_MODE_NOT_G90_OR_G91); CHK((r < cc), NCE_R_LESS_THAN_Y_IN_CYCLE_IN_XZ_PLANE); if (old_cc < r) { STRAIGHT_TRAVERSE(settings->current_x, r, settings->current_z, settings->AA_current, settings->BB_current, settings->CC_current); old_cc = r; } clear_cc = (settings->retract_mode == R_PLANE) ? r : old_cc; save_mode = GET_EXTERNAL_MOTION_CONTROL_MODE(); save_tolerance = GET_EXTERNAL_MOTION_CONTROL_TOLERANCE(); if (save_mode != CANON_EXACT_PATH) SET_MOTION_CONTROL_MODE(CANON_EXACT_PATH, 0); switch (motion) { case G_81: CYCLE_MACRO(convert_cycle_g81(CANON_PLANE_XZ, aa, bb, clear_cc, cc)) break; case G_82: CHK(((settings->motion_mode != G_82) && (block->p_number == -1.0)), NCE_DWELL_TIME_P_WORD_MISSING_WITH_G82); block->p_number = block->p_number == -1.0 ? settings->cycle_p : block->p_number; CYCLE_MACRO(convert_cycle_g82(CANON_PLANE_XZ, aa, bb, clear_cc, cc, block->p_number)) settings->cycle_p = block->p_number; break; case G_83: CHK(((settings->motion_mode != G_83) && (block->q_number == -1.0)), NCE_Q_WORD_MISSING_WITH_G83); block->q_number = block->q_number == -1.0 ? settings->cycle_q : block->q_number; CYCLE_MACRO(convert_cycle_g83(CANON_PLANE_XZ, aa, bb, r, clear_cc, cc, block->q_number)) settings->cycle_q = block->q_number; break; case G_84: CYCLE_MACRO(convert_cycle_g84(CANON_PLANE_XZ, aa, bb, clear_cc, cc, settings->spindle_turning, settings->speed_feed_mode)) break; case G_85: CYCLE_MACRO(convert_cycle_g85(CANON_PLANE_XZ, aa, bb, clear_cc, cc)) break; case G_86: CHK(((settings->motion_mode != G_86) && (block->p_number == -1.0)), NCE_DWELL_TIME_P_WORD_MISSING_WITH_G86); block->p_number = block->p_number == -1.0 ? settings->cycle_p : block->p_number; CYCLE_MACRO(convert_cycle_g86(CANON_PLANE_XZ, aa, bb, clear_cc, cc, block->p_number, settings->spindle_turning)) settings-> cycle_p = block->p_number; break; case G_87: if (settings->motion_mode != G_87) { CHK((block->i_flag == OFF), NCE_I_WORD_MISSING_WITH_G87); CHK((block->j_flag == OFF), NCE_J_WORD_MISSING_WITH_G87); CHK((block->k_flag == OFF), NCE_K_WORD_MISSING_WITH_G87); } i = block->i_flag == ON ? block->i_number : settings->cycle_i; j = block->j_flag == ON ? block->j_number : settings->cycle_j; k = block->k_flag == ON ? block->k_number : settings->cycle_k; settings->cycle_i = i; settings->cycle_j = j; settings->cycle_k = k; if (settings->distance_mode == MODE_INCREMENTAL) { j = (cc + j); /* j always absolute in function call below */ } CYCLE_MACRO(convert_cycle_g87(CANON_PLANE_XZ, aa, (aa + k), bb, (bb + i), r, clear_cc, j, cc, settings->spindle_turning)) break; case G_88: CHK(((settings->motion_mode != G_88) && (block->p_number == -1.0)), NCE_DWELL_TIME_P_WORD_MISSING_WITH_G88); block->p_number = block->p_number == -1.0 ? settings->cycle_p : block->p_number; CYCLE_MACRO(convert_cycle_g88(CANON_PLANE_XZ, aa, bb, cc, block->p_number, settings->spindle_turning)) settings-> cycle_p = block->p_number; break; case G_89: CHK(((settings->motion_mode != G_89) && (block->p_number == -1.0)), NCE_DWELL_TIME_P_WORD_MISSING_WITH_G89); block->p_number = block->p_number == -1.0 ? settings->cycle_p : block->p_number; CYCLE_MACRO(convert_cycle_g89(CANON_PLANE_XZ, aa, bb, clear_cc, cc, block->p_number)) settings->cycle_p = block->p_number; break; default: ERM(NCE_BUG_FUNCTION_SHOULD_NOT_HAVE_BEEN_CALLED); } settings->current_z = aa; /* CYCLE_MACRO updates aa and bb */ settings->current_x = bb; settings->current_y = clear_cc; settings->cycle_cc = block->y_number; if (save_mode != CANON_EXACT_PATH) SET_MOTION_CONTROL_MODE(save_mode, save_tolerance); return INTERP_OK;}/****************************************************************************//*! cycle_feedReturned Value: int (INTERP_OK)Side effects: STRAIGHT_FEED is called.Called by: convert_cycle_g81 convert_cycle_g82 convert_cycle_g83 convert_cycle_g84 convert_cycle_g85 convert_cycle_g86 convert_cycle_g87 convert_cycle_g88 convert_cycle_g89This writes a STRAIGHT_FEED command appropriate for a cycle move withrespect to the given plane. No rotary axis motion takes place.*/int Interp::cycle_feed(CANON_PLANE plane, //!< currently selected plane double end1, //!< first coordinate value double end2, //!< second coordinate value double end3) //!< third coordinate value { if (plane == CANON_PLANE_XY) STRAIGHT_FEED(end1, end2, end3, _setup.AA_current, _setup.BB_current, _setup.CC_current); else if (plane == CANON_PLANE_YZ) STRAIGHT_FEED(end3, end1, end2, _setup.AA_current, _setup.BB_current, _setup.CC_current); else /* if (plane == CANON_PLANE_XZ) */ STRAIGHT_FEED(end2, end3, end1, _setup.AA_current, _setup.BB_current, _setup.CC_current); return INTERP_OK;}/****************************************************************************//*! cycle_traverseReturned Value: int (INTERP_OK)Side effects: STRAIGHT_TRAVERSE is called.Called by: convert_cycle convert_cycle_g81 convert_cycle_g82 convert_cycle_g83 convert_cycle_g86 convert_cycle_g87 convert_cycle_xy (via CYCLE_MACRO) convert_cycle_yz (via CYCLE_MACRO) convert_cycle_zx (via CYCLE_MACRO)This writes a STRAIGHT_TRAVERSE command appropriate for a cyclemove with respect to the given plane. No rotary axis motion takes place.*/int Interp::cycle_traverse(CANON_PLANE plane, //!< currently selected plane double end1, //!< first coordinate value double end2, //!< second coordinate value double end3) //!< third coordinate value { if (plane == CANON_PLANE_XY) STRAIGHT_TRAVERSE(end1, end2, end3, _setup.AA_current, _setup.BB_current, _setup.CC_current); else if (plane == CANON_PLANE_YZ) STRAIGHT_TRAVERSE(end3, end1, end2, _setup.AA_current, _setup.BB_current, _setup.CC_current); else /* if (plane == CANON_PLANE_XZ) */ STRAIGHT_TRAVERSE(end2, end3, end1, _setup.AA_current, _setup.BB_current, _setup.CC_current); return INTERP_OK;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -