📄 interp_convert.cc
字号:
end_y = (end_y + (tool_radius * sin(gamma))); /* end_y reset actual */ if (settings->feed_mode == INVERSE_TIME) inverse_time_rate_arc(settings->current_x, settings->current_y, settings->current_z, center_x, center_y, turn, end_x, end_y, end_z, block, settings); ARC_FEED(end_x, end_y, center_x, center_y, turn, end_z, AA_end, BB_end, CC_end); settings->current_x = end_x; settings->current_y = end_y; settings->current_z = end_z; settings->AA_current = AA_end; settings->BB_current = BB_end; settings->CC_current = CC_end; return INTERP_OK;}/****************************************************************************//*! convert_arc_comp2Returned Value: int If arc_data_ijk or arc_data_r returns an error code, this returns that code. If any of the following errors occurs, this returns the error code shown. Otherwise, it returns INTERP_OK. 1. A concave corner is found: NCE_CONCAVE_CORNER_WITH_CUTTER_RADIUS_COMP 2. The tool will not fit inside an arc: NCE_TOOL_RADIUS_NOT_LESS_THAN_ARC_RADIUS_WITH_COMPSide effects: This executes an arc command feed rate. If needed, at also generates an arc to go around a convex corner. It also updates the setting of the position of the tool point to the end point of the move. If inverse time feed rate mode is in effect, the feed rate is reset.Called by: convert_arc.This function converts a helical or circular arc. The axis must beparallel to the z-axis. This is called when cutter radius compensationis on and this is not the first cut after the turning on.If one or more rotary axes is moved in this block and an extra arc isrequired to go around a sharp corner, all the rotary axis motionoccurs on the main arc and none on the extra arc. An alternativemight be to distribute the rotary axis motion over the extra arc andthe programmed arc in proportion to their lengths.If the Z-axis is moved in this block and an extra arc is required togo around a sharp corner, all the Z-axis motion occurs on the main arcand none on the extra arc. An alternative might be to distribute theZ-axis motion over the extra arc and the main arc in proportion totheir lengths.*/int Interp::convert_arc_comp2(int move, //!< either G_2 (cw arc) or G_3 (ccw arc) block_pointer block, //!< pointer to a block of RS274/NGC instructions setup_pointer settings, //!< pointer to machine settings double end_x, //!< x-value at end of programmed (then actual) arc double end_y, //!< y-value at end of programmed (then actual) arc double end_z, //!< z-value at end of arc double AA_end, //!< a-value at end of arc double BB_end, //!< b-value at end of arc double CC_end) //!< c-value at end of arc{ static char name[] = "convert_arc_comp2"; double alpha; /* direction of tangent to start of arc */ double arc_radius; double beta; /* angle between two tangents above */ double center_x; /* center of arc */ double center_y; double delta; /* direction of radius from start of arc to center of arc */ double gamma; /* direction of perpendicular to arc at end */ double mid_x; double mid_y; int side; double small = TOLERANCE_CONCAVE_CORNER; /* angle for testing corners */ double start_x; double start_y; int status; /* status returned from CHP function call */ double theta; /* direction of tangent to last cut */ double tolerance; double tool_radius; int turn; /* number of full or partial circles CCW *//* find basic arc data: center_x, center_y, and turn */ start_x = settings->program_x; start_y = settings->program_y; tolerance = (settings->length_units == CANON_UNITS_INCHES) ? TOLERANCE_INCH : TOLERANCE_MM; if (block->r_flag) { CHP(arc_data_r(move, start_x, start_y, end_x, end_y, block->r_number, ¢er_x, ¢er_y, &turn, tolerance)); } else { CHP(arc_data_ijk(move, start_x, start_y, end_x, end_y, block->i_number, block->j_number, ¢er_x, ¢er_y, &turn, tolerance)); }/* compute other data */ side = settings->cutter_comp_side; tool_radius = settings->cutter_comp_radius; /* always is positive */ arc_radius = hypot((center_x - end_x), (center_y - end_y)); theta = atan2(settings->current_y - start_y, settings->current_x - start_x); theta = (side == LEFT) ? (theta - M_PI_2l) : (theta + M_PI_2l); delta = atan2(center_y - start_y, center_x - start_x); alpha = (move == G_3) ? (delta - M_PI_2l) : (delta + M_PI_2l); beta = (side == LEFT) ? (theta - alpha) : (alpha - theta); beta = (beta > (1.5 * M_PIl)) ? (beta - (2 * M_PIl)) : (beta < -M_PI_2l) ? (beta + (2 * M_PIl)) : beta; if (((side == LEFT) && (move == G_3)) || ((side == RIGHT) && (move == G_2))) { gamma = atan2((center_y - end_y), (center_x - end_x)); CHK((arc_radius <= tool_radius), NCE_TOOL_RADIUS_NOT_LESS_THAN_ARC_RADIUS_WITH_COMP); } else { gamma = atan2((end_y - center_y), (end_x - center_x)); delta = (delta + M_PIl); } settings->program_x = end_x; settings->program_y = end_y; end_x = (end_x + (tool_radius * cos(gamma))); /* end_x reset actual */ end_y = (end_y + (tool_radius * sin(gamma))); /* end_y reset actual *//* check if extra arc needed and insert if so */ CHK(((beta < -small) || (beta > (M_PIl + small))), NCE_CONCAVE_CORNER_WITH_CUTTER_RADIUS_COMP); if (beta > small) { /* two arcs needed */ mid_x = (start_x + (tool_radius * cos(delta))); mid_y = (start_y + (tool_radius * sin(delta))); if (settings->feed_mode == INVERSE_TIME) inverse_time_rate_arc2(start_x, start_y, (side == LEFT) ? -1 : 1, mid_x, mid_y, center_x, center_y, turn, end_x, end_y, end_z, block, settings); ARC_FEED(mid_x, mid_y, start_x, start_y, ((side == LEFT) ? -1 : 1), settings->current_z, AA_end, BB_end, CC_end); ARC_FEED(end_x, end_y, center_x, center_y, turn, end_z, AA_end, BB_end, CC_end); } else { /* one arc needed */ if (settings->feed_mode == INVERSE_TIME) inverse_time_rate_arc(settings->current_x, settings->current_y, settings->current_z, center_x, center_y, turn, end_x, end_y, end_z, block, settings); ARC_FEED(end_x, end_y, center_x, center_y, turn, end_z, AA_end, BB_end, CC_end); } settings->current_x = end_x; settings->current_y = end_y; settings->current_z = end_z; settings->AA_current = AA_end; settings->BB_current = BB_end; settings->CC_current = CC_end; return INTERP_OK;}/****************************************************************************//*! convert_axis_offsetsReturned Value: int If any of the following errors occur, this returns the error code shown. Otherwise, it returns INTERP_OK. 1. The function is called when cutter radius compensation is on: NCE_CANNOT_CHANGE_AXIS_OFFSETS_WITH_CUTTER_RADIUS_COMP 2. The g_code argument is not G_92, G_92_1, G_92_2, or G_92_3 NCE_BUG_CODE_NOT_IN_G92_SERIESSide effects: SET_PROGRAM_ORIGIN is called, and the coordinate values for the axis offsets are reset. The coordinates of the current point are reset. Parameters may be set.Called by: convert_modal_0.The action of G92 is described in [NCMS, pages 10 - 11] and {Fanuc,pages 61 - 63]. [NCMS] is ambiguous about the intent, but [Fanuc]is clear. When G92 is executed, an offset of the origin is calculatedso that the coordinates of the current point with respect to the movedorigin are as specified on the line containing the G92. If an axisis not mentioned on the line, the coordinates of the current pointare not changed. The execution of G92 results in an axis offset beingcalculated and saved for each of the six axes, and the axis offsetsare always used when motion is specified with respect to absolutedistance mode using any of the nine coordinate systems (those designatedby G54 - G59.3). Thus all nine coordinate systems are affected by G92.Being in incremental distance mode has no effect on the action of G92in this implementation. [NCMS] is not explicit about this, but it isimplicit in the second sentence of [Fanuc, page 61].The offset is the amount the origin must be moved so that thecoordinate of the controlled point has the specified value. Forexample, if the current point is at X=4 in the currently specifiedcoordinate system and the current X-axis offset is zero, then "G92 x7"causes the X-axis offset to be reset to -3.Since a non-zero offset may be already be in effect when the G92 iscalled, that must be taken into account.In addition to causing the axis offset values in the _setup model to beset, G92 sets parameters 5211 to 5216 to the x,y,z,a,b,c axis offsets.The action of G92.2 is described in [NCMS, page 12]. There is noequivalent command in [Fanuc]. G92.2 resets axis offsets to zero.G92.1, also included in [NCMS, page 12] (but the usage here differsslightly from the spec), is like G92.2, except that it also causesthe axis offset parameters to be set to zero, whereas G92.2 does notzero out the parameters.G92.3 is not in [NCMS]. It sets the axis offset values to the valuesgiven in the parameters.*/int Interp::convert_axis_offsets(int g_code, //!< g_code being executed (must be in G_92 series) block_pointer block, //!< pointer to a block of RS274/NGC instructions setup_pointer settings) //!< pointer to machine settings { static char name[] = "convert_axis_offsets"; double *pars; /* short name for settings->parameters */ CHK((settings->cutter_comp_side != OFF), /* not "== ON" */ NCE_CANNOT_CHANGE_AXIS_OFFSETS_WITH_CUTTER_RADIUS_COMP); pars = settings->parameters; if (g_code == G_92) { if (block->x_flag == ON) { settings->axis_offset_x = (settings->current_x + settings->axis_offset_x - block->x_number); settings->current_x = block->x_number; } if (block->y_flag == ON) { settings->axis_offset_y = (settings->current_y + settings->axis_offset_y - block->y_number); settings->current_y = block->y_number; } if (block->z_flag == ON) { settings->axis_offset_z = (settings->current_z + settings->axis_offset_z - block->z_number); settings->current_z = block->z_number; } if (block->a_flag == ON) { settings->AA_axis_offset = (settings->AA_current + settings->AA_axis_offset - block->a_number); settings->AA_current = block->a_number; } if (block->b_flag == ON) { settings->BB_axis_offset = (settings->BB_current + settings->BB_axis_offset - block->b_number); settings->BB_current = block->b_number; } if (block->c_flag == ON) { settings->CC_axis_offset = (settings->CC_current + settings->CC_axis_offset - block->c_number); settings->CC_current = block->c_number; } SET_ORIGIN_OFFSETS(settings->origin_offset_x + settings->axis_offset_x, settings->origin_offset_y + settings->axis_offset_y, settings->origin_offset_z + settings->axis_offset_z, (settings->AA_origin_offset + settings->AA_axis_offset), (settings->BB_origin_offset + settings->BB_axis_offset), (settings->CC_origin_offset + settings->CC_axis_offset)); pars[5211] = TO_EXT_LEN(settings->axis_offset_x); pars[5212] = TO_EXT_LEN(settings->axis_offset_y); pars[5213] = TO_EXT_LEN(settings->axis_offset_z); pars[5214] = TO_EXT_ANG(settings->AA_axis_offset); pars[5215] = TO_EXT_ANG(settings->BB_axis_offset); pars[5216] = TO_EXT_ANG(settings->CC_axis_offset); } else if ((g_code == G_92_1) || (g_code == G_92_2)) { settings->current_x = settings->current_x + settings->axis_offset_x; settings->current_y = settings->current_y + settings->axis_offset_y; settings->current_z = settings->current_z + settings->axis_offset_z; settings->AA_current = (settings->AA_current + settings->AA_axis_offset); settings->BB_current = (settings->BB_current + settings->BB_axis_offset); settings->CC_current = (settings->CC_current + settings->CC_axis_offset); SET_ORIGIN_OFFSETS(settings->origin_offset_x, settings->origin_offset_y, settings->origin_offset_z, settings->AA_origin_offset, settings->BB_origin_offset, settings->CC_origin_offset); settings->axis_offset_x = 0.0; settings->axis_offset_y = 0.0; settings->axis_offset_z = 0.0; settings->AA_axis_offset = 0.0; settings->BB_axis_offset = 0.0; settings->CC_axis_offset = 0.0; if (g_code == G_92_1) { pars[5211] = 0.0; pars[5212] = 0.0; pars[5213] = 0.0; pars[5214] = 0.0; pars[5215] = 0.0; pars[5216] = 0.0; } } else if (g_code == G_92_3) { settings->current_x = settings->current_x + settings->axis_offset_x - USER_TO_PROGRAM_LEN(pars[5211]); settings->current_y = settings->current_y + settings->axis_offset_y - USER_TO_PROGRAM_LEN(pars[5212]); settings->current_z = settings->current_z + settings->axis_offset_z - USER_TO_PROGRAM_LEN(pars[5213]); settings->AA_current = settings->AA_current + settings->AA_axis_offset - USER_TO_PROGRAM_ANG(pars[5214]); settings->BB_current = settings->BB_current + settings->BB_axis_offset - USER_TO_PROGRAM_ANG(pars[5215]); settings->CC_current = settings->CC_current + settings->CC_axis_offset - USER_TO_PROGRAM_ANG(pars[5216]); settings->axis_offset_x = USER_TO_PROGRAM_LEN(pars[5211]); settings->axis_offset_y = USER_TO_PROGRAM_LEN(pars[5212]); settings->axis_offset_z = USER_TO_PROGRAM_LEN(pars[5213]); settings->AA_axis_offset = USER_TO_PROGRAM_ANG(pars[5214]); settings->BB_axis_offset = USER_TO_PROGRAM_ANG(pars[5215]); settings->CC_axis_offset = USER_TO_PROGRAM_ANG(pars[5216]); SET_ORIGIN_OFFSETS(settings->origin_offset_x + settings->axis_offset_x, settings->origin_offset_y + settings->axis_offset_y, settings->origin_offset_z + settings->axis_offset_z, (settings->AA_origin_offset + settings->AA_axis_offset), (settings->BB_origin_offset + settings->BB_axis_offset), (settings->CC_origin_offset + settings->CC_axis_offset));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -