📄 interp_convert.cc
字号:
A comment is made that cutter radius compensation is turned off. The machine model of the cutter radius compensation mode is set to OFF. The value of program_x in the machine model is set to UNKNOWN. This serves as a flag when cutter radius compensation is turned on again.Called by: convert_cutter_compensation*/int Interp::convert_cutter_compensation_off(setup_pointer settings) //!< pointer to machine settings{#ifdef DEBUG_EMC COMMENT("interpreter: cutter radius compensation off");#endif settings->cutter_comp_side = OFF; settings->program_x = UNKNOWN; return INTERP_OK;}/****************************************************************************//*! convert_cutter_compensation_onReturned Value: int If any of the following errors occur, this returns the error code shown. Otherwise, it returns INTERP_OK. 1. The selected plane is not the XY plane: NCE_CANNOT_TURN_CUTTER_RADIUS_COMP_ON_OUT_OF_XY_PLANE 2. Cutter radius compensation is already on: NCE_CANNOT_TURN_CUTTER_RADIUS_COMP_ON_WHEN_ONSide effects: A COMMENT function call is made (conditionally) saying that the interpreter is switching mode so that cutter radius compensation is on. The value of cutter_comp_radius in the machine model mode is set to the absolute value of the radius given in the tool table. The value of cutter_comp_side in the machine model mode is set to RIGHT or LEFT. The currently active tool table index in the machine model is updated.Called by: convert_cutter_compensationcheck_other_codes checks that a d word occurs only in a block with g41or g42.Cutter radius compensation is carried out in the interpreter, so nocall is made to a canonical function (although there is a canonicalfunction, START_CUTTER_RADIUS_COMPENSATION, that could be called ifthe primitive level could execute it).This version uses a D word if there is one in the block, but it doesnot require a D word, since the sample programs which the interpreteris supposed to handle do not have them. Logically, the D word isoptional, since the D word is always (except in cases we have neverheard of) the slot number of the tool in the spindle. Not requiring aD word is contrary to [Fanuc, page 116] and [NCMS, page 79], however.Both manuals require the use of the D-word with G41 and G42.This version handles a negative offset radius, which may beencountered if the programmed tool path is a center line path forcutting a profile and the path was constructed using a nominal tooldiameter. Then the value in the tool table for the diameter is set tobe the difference between the actual diameter and the nominaldiameter. If the actual diameter is less than the nominal, the valuein the table is negative. The method of handling a negative radius isto switch the side of the offset and use a positive radius. Thisrequires that the profile use arcs (not straight lines) to go aroundconvex corners.*/int Interp::convert_cutter_compensation_on(int side, //!< side of path cutter is on (LEFT or RIGHT) block_pointer block, //!< pointer to a block of RS274 instructions setup_pointer settings) //!< pointer to machine settings { static char name[] = "convert_cutter_compensation_on"; double radius; int index; CHK((settings->plane != CANON_PLANE_XY), NCE_CANNOT_TURN_CUTTER_RADIUS_COMP_ON_OUT_OF_XY_PLANE); CHK((settings->cutter_comp_side != OFF), NCE_CANNOT_TURN_CUTTER_RADIUS_COMP_ON_WHEN_ON); index = (block->d_number != -1) ? block->d_number : settings->current_slot; radius = ((settings->tool_table[index].diameter) / 2.0); if (radius < 0.0) { /* switch side & make radius positive if radius negative */ radius = -radius; if (side == RIGHT) side = LEFT; else side = RIGHT; }#ifdef DEBUG_EMC if (side == RIGHT) COMMENT("interpreter: cutter radius compensation on right"); else COMMENT("interpreter: cutter radius compensation on left");#endif settings->cutter_comp_radius = radius; settings->tool_table_index = index; settings->cutter_comp_side = side; return INTERP_OK;}/****************************************************************************//*! convert_distance_modeReturned Value: int If any of the following errors occur, this returns the error shown. Otherwise, it returns INTERP_OK. 1. g_code isn't G_90 or G_91: NCE_BUG_CODE_NOT_G90_OR_G91Side effects: The interpreter switches the machine settings to indicate the current distance mode (absolute or incremental). The canonical machine to which commands are being sent does not have an incremental mode, so no command setting the distance mode is generated in this function. A comment function call explaining the change of mode is made (conditionally), however, if there is a change.Called by: convert_g.*/int Interp::convert_distance_mode(int g_code, //!< g_code being executed (must be G_90 or G_91) setup_pointer settings) //!< pointer to machine settings { static char name[] = "convert_distance_mode"; if (g_code == G_90) { if (settings->distance_mode != MODE_ABSOLUTE) {#ifdef DEBUG_EMC COMMENT("interpreter: distance mode changed to absolute");#endif settings->distance_mode = MODE_ABSOLUTE; } } else if (g_code == G_91) { if (settings->distance_mode != MODE_INCREMENTAL) {#ifdef DEBUG_EMC COMMENT("interpreter: distance mode changed to incremental");#endif settings->distance_mode = MODE_INCREMENTAL; } } else ERM(NCE_BUG_CODE_NOT_G90_OR_G91); return INTERP_OK;}/****************************************************************************//*! convert_dwellReturned Value: int (INTERP_OK)Side effects: A dwell command is executed.Called by: convert_g.*/int Interp::convert_dwell(double time) //!< time in seconds to dwell */{ DWELL(time); return INTERP_OK;}/****************************************************************************//*! convert_feed_modeReturned Value: int If any of the following errors occur, this returns the error code shown. Otherwise, it returns INTERP_OK. 1. g_code isn't G_93 or G_94: NCE_BUG_CODE_NOT_G93_OR_G94Side effects: The interpreter switches the machine settings to indicate the current feed mode (UNITS_PER_MINUTE or INVERSE_TIME). The canonical machine to which commands are being sent does not have a feed mode, so no command setting the distance mode is generated in this function. A comment function call is made (conditionally) explaining the change in mode, however.Called by: execute_block.*/int Interp::convert_feed_mode(int g_code, //!< g_code being executed (must be G_93 or G_94) setup_pointer settings) //!< pointer to machine settings { static char name[] = "convert_feed_mode"; if (g_code == G_93) {#ifdef DEBUG_EMC COMMENT("interpreter: feed mode set to inverse time");#endif settings->feed_mode = INVERSE_TIME; } else if (g_code == G_94) {#ifdef DEBUG_EMC COMMENT("interpreter: feed mode set to units per minute");#endif settings->feed_mode = UNITS_PER_MINUTE; } else ERM(NCE_BUG_CODE_NOT_G93_OR_G94); return INTERP_OK;}/****************************************************************************//*! convert_feed_rateReturned Value: int (INTERP_OK)Side effects: The machine feed_rate is set to the value of f_number in the block by function call. The machine model feed_rate is set to that value.Called by: execute_blockThis is called only if the feed mode is UNITS_PER_MINUTE.*/int Interp::convert_feed_rate(block_pointer block, //!< pointer to a block of RS274 instructions setup_pointer settings) //!< pointer to machine settings { SET_FEED_RATE(block->f_number); settings->feed_rate = block->f_number; return INTERP_OK;}/****************************************************************************//*! convert_gReturned Value: int If one of the following functions is called and returns an error code, this returns that code. convert_control_mode convert_coordinate_system convert_cutter_compensation convert_distance_mode convert_dwell convert_length_units convert_modal_0 convert_motion convert_retract_mode convert_set_plane convert_tool_length_offset Otherwise, it returns INTERP_OK.Side effects: Any g_codes in the block (excluding g93 and 94) and any implicit motion g_code are executed.Called by: execute_block.This takes a pointer to a block of RS274/NGC instructions (alreadyread in) and creates the appropriate output commands corresponding toany "g" codes in the block.Codes g93 and g94, which set the feed mode, are executed earlier byexecute_block before reading the feed rate.G codes are are executed in the following order.1. mode 0, G4 only - dwell. Left here from earlier versions.2. mode 2, one of (G17, G18, G19) - plane selection.3. mode 6, one of (G20, G21) - length units.4. mode 7, one of (G40, G41, G42) - cutter radius compensation.5. mode 8, one of (G43, G49) - tool length offset6. mode 12, one of (G54, G55, G56, G57, G58, G59, G59.1, G59.2, G59.3) - coordinate system selection.7. mode 13, one of (G61, G61.1, G64) - control mode8. mode 3, one of (G90, G91) - distance mode.9. mode 10, one of (G98, G99) - retract mode.10. mode 0, one of (G10, G28, G30, G92, G92.1, G92.2, G92.3) - setting coordinate system locations, return to reference point 1, return to reference point 2, setting or cancelling axis offsets.11. mode 1, one of (G0, G1, G2, G3, G38.2, G80, G81 to G89) - motion or cancel. G53 from mode 0 is also handled here, if present.Some mode 0 and most mode 1 G codes must be executed after the length unitsare set, since they use coordinate values. Mode 1 codes also must waituntil most of the other modes are set.*/int Interp::convert_g(block_pointer block, //!< pointer to a block of RS274/NGC instructions setup_pointer settings) //!< pointer to machine settings { static char name[] = "convert_g"; int status; if (block->g_modes[0] == G_4) { CHP(convert_dwell(block->p_number)); } if (block->g_modes[2] != -1) { CHP(convert_set_plane(block->g_modes[2], settings)); } if (block->g_modes[6] != -1) { CHP(convert_length_units(block->g_modes[6], settings)); } if (block->g_modes[7] != -1) { CHP(convert_cutter_compensation(block->g_modes[7], block, settings)); } if (block->g_modes[8] != -1) { CHP(convert_tool_length_offset(block->g_modes[8], block, settings)); } if (block->g_modes[12] != -1) { CHP(convert_coordinate_system(block->g_modes[12], settings)); } if (block->g_modes[13] != -1) { CHP(convert_control_mode(block->g_modes[13], block->p_number, settings)); } if (block->g_modes[3] != -1) { CHP(convert_distance_mode(block->g_modes[3], settings)); } if (block->g_modes[10] != -1) { CHP(convert_retract_mode(block->g_modes[10], settings)); } if (block->g_modes[0] != -1) { CHP(convert_modal_0(block->g_modes[0], block, settings)); } if (block->motion_to_be != -1) { CHP(convert_motion(block->motion_to_be, block, settings)); } return INTERP_OK;}/****************************************************************************//*! convert_homeReturned Value: int
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -