📄 interp_convert.cc
字号:
If any of the following errors occur, this returns the error code shown. Otherwise, it returns INTERP_OK. 1. cutter radius compensation is on: NCE_CANNOT_USE_G28_OR_G30_WITH_CUTTER_RADIUS_COMP 2. The code is not G28 or G30: NCE_BUG_CODE_NOT_G28_OR_G30Side effects: This executes a straight traverse to the programmed point, using the current coordinate system, tool length offset, and motion mode to interpret the coordinate values. Then it executes a straight traverse to the location of reference point 1 (if G28) or reference point 2 (if G30). It also updates the setting of the position of the tool point to the end point of the move.Called by: convert_modal_0.During the motion from the intermediate point to the home point, thisfunction currently makes the A and C axes turn counterclockwise if aturn is needed. This is not necessarily the most efficient way to doit. A check might be made of which direction to turn to have the leastturn to get to the reference position, and the axis would turn thatway.*/int Interp::convert_home(int move, //!< G code, must be G_28 or G_30 block_pointer block, //!< pointer to a block of RS274 instructions setup_pointer settings) //!< pointer to machine settings { static char name[] = "convert_home"; double end_x; double end_y; double end_z; double AA_end; double BB_end; double CC_end; double *parameters; parameters = settings->parameters; find_ends(block, settings, &end_x, &end_y, &end_z, &AA_end, &BB_end, &CC_end); CHK((settings->cutter_comp_side != OFF), NCE_CANNOT_USE_G28_OR_G30_WITH_CUTTER_RADIUS_COMP); STRAIGHT_TRAVERSE(end_x, end_y, end_z, AA_end, BB_end, CC_end); if (move == G_28) { find_relative(parameters[5161], parameters[5162], parameters[5163], parameters[5164], parameters[5165], parameters[5166], &end_x, &end_y, &end_z, &AA_end, &BB_end, &CC_end, settings); } else if (move == G_30) { find_relative(parameters[5181], parameters[5182], parameters[5183], parameters[5184], parameters[5185], parameters[5186], &end_x, &end_y, &end_z, &AA_end, &BB_end, &CC_end, settings); } else ERM(NCE_BUG_CODE_NOT_G28_OR_G30); STRAIGHT_TRAVERSE(end_x, end_y, 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_length_unitsReturned Value: int If any of the following errors occur, this returns the error shown. Otherwise, it returns INTERP_OK. 1. The g_code argument isnt G_20 or G_21: NCE_BUG_CODE_NOT_G20_OR_G21 2. Cutter radius compensation is on: NCE_CANNOT_CHANGE_UNITS_WITH_CUTTER_RADIUS_COMPSide effects: A command setting the length units is executed. The machine settings are reset regarding length units and current position.Called by: convert_g.We are not changing tool length offset values or tool diameter values.Those values must be given in the table in the correct units. Thus itwill generally not be feasible to switch units in the middle of aprogram.We are not changing the parameters that represent the positionsof the nine work coordinate systems.We are also not changing feed rate values when length units arechanged, so the actual behavior may change.Several other distance items in the settings (such as the variousparameters for cycles) are also not reset.We are changing origin offset and axis offset values, which arecritical. If this were not done, when length units are set and the newlength units are not the same as the default length units(millimeters), and any XYZ origin or axis offset is not zero, then anysubsequent change in XYZ origin or axis offset values will beincorrect. Also, g53 (motion in absolute coordinates) will not workcorrectly.*/int Interp::convert_length_units(int g_code, //!< g_code being executed (must be G_20 or G_21) setup_pointer settings) //!< pointer to machine settings { static char name[] = "convert_length_units"; CHK((settings->cutter_comp_side != OFF), NCE_CANNOT_CHANGE_UNITS_WITH_CUTTER_RADIUS_COMP); if (g_code == G_20) { USE_LENGTH_UNITS(CANON_UNITS_INCHES); if (settings->length_units != CANON_UNITS_INCHES) { settings->length_units = CANON_UNITS_INCHES; settings->current_x = (settings->current_x * INCH_PER_MM); settings->current_y = (settings->current_y * INCH_PER_MM); settings->current_z = (settings->current_z * INCH_PER_MM); settings->axis_offset_x = (settings->axis_offset_x * INCH_PER_MM); settings->axis_offset_y = (settings->axis_offset_y * INCH_PER_MM); settings->axis_offset_z = (settings->axis_offset_z * INCH_PER_MM); settings->origin_offset_x = (settings->origin_offset_x * INCH_PER_MM); settings->origin_offset_y = (settings->origin_offset_y * INCH_PER_MM); settings->origin_offset_z = (settings->origin_offset_z * INCH_PER_MM); settings->feed_rate = GET_EXTERNAL_FEED_RATE(); } } else if (g_code == G_21) { USE_LENGTH_UNITS(CANON_UNITS_MM); if (settings->length_units != CANON_UNITS_MM) { settings->length_units = CANON_UNITS_MM; settings->current_x = (settings->current_x * MM_PER_INCH); settings->current_y = (settings->current_y * MM_PER_INCH); settings->current_z = (settings->current_z * MM_PER_INCH); settings->axis_offset_x = (settings->axis_offset_x * MM_PER_INCH); settings->axis_offset_y = (settings->axis_offset_y * MM_PER_INCH); settings->axis_offset_z = (settings->axis_offset_z * MM_PER_INCH); settings->origin_offset_x = (settings->origin_offset_x * MM_PER_INCH); settings->origin_offset_y = (settings->origin_offset_y * MM_PER_INCH); settings->origin_offset_z = (settings->origin_offset_z * MM_PER_INCH); settings->feed_rate = GET_EXTERNAL_FEED_RATE(); } } else ERM(NCE_BUG_CODE_NOT_G20_OR_G21); return INTERP_OK;}/****************************************************************************//*! convert_mReturned Value: int If convert_tool_change returns an error code, this returns that code. Otherwise, it returns INTERP_OK.Side effects: m_codes in the block are executed. For each m_code this consists of making a function call(s) to a canonical machining function(s) and setting the machine model.Called by: execute_block.This handles four separate types of activity in order:1. changing the tool (m6) - which also retracts and stops the spindle.2. Turning the spindle on or off (m3, m4, and m5)3. Turning coolant on and off (m7, m8, and m9)4. turning a-axis clamping on and off (m26, m27) - commented out.5. enabling or disabling feed and speed overrides (m49, m49).Within each group, only the first code encountered will be executed.This does nothing with m0, m1, m2, m30, or m60 (which are handled inconvert_stop).*/int Interp::convert_m(block_pointer block, //!< pointer to a block of RS274/NGC instructions setup_pointer settings) //!< pointer to machine settings { static char name[] = "convert_m"; int status; /* The M62-65 commands are used for DIO */ /* M62 sets a DIO synched with motion M63 clears a DIO synched with motion M64 sets a DIO imediately M65 clears a DIO imediately */ if (block->m_modes[5] == 62) { SET_MOTION_OUTPUT_BIT(round_to_int(block->p_number)); } else if (block->m_modes[5] == 63) { CLEAR_MOTION_OUTPUT_BIT(round_to_int(block->p_number)); } else if (block->m_modes[5] == 64) { SET_AUX_OUTPUT_BIT(round_to_int(block->p_number)); } else if (block->m_modes[5] == 65) { CLEAR_AUX_OUTPUT_BIT(round_to_int(block->p_number)); } if (block->m_modes[6] != -1) { CHP(convert_tool_change(settings)); } if (block->m_modes[7] == 3) { START_SPINDLE_CLOCKWISE(); settings->spindle_turning = CANON_CLOCKWISE; } else if (block->m_modes[7] == 4) { START_SPINDLE_COUNTERCLOCKWISE(); settings->spindle_turning = CANON_COUNTERCLOCKWISE; } else if (block->m_modes[7] == 5) { STOP_SPINDLE_TURNING(); settings->spindle_turning = CANON_STOPPED; } if (block->m_modes[8] == 7) { MIST_ON(); settings->mist = ON; } else if (block->m_modes[8] == 8) { FLOOD_ON(); settings->flood = ON; } else if (block->m_modes[8] == 9) { MIST_OFF(); settings->mist = OFF; FLOOD_OFF(); settings->flood = OFF; }/* No axis clamps in this version if (block->m_modes[2] == 26) {#ifdef DEBUG_EMC COMMENT("interpreter: automatic A-axis clamping turned on");#endif settings->a_axis_clamping = ON; } else if (block->m_modes[2] == 27) {#ifdef DEBUG_EMC COMMENT("interpreter: automatic A-axis clamping turned off");#endif settings->a_axis_clamping = OFF; }*/ if (block->m_modes[9] == 48) { ENABLE_FEED_OVERRIDE(); ENABLE_SPEED_OVERRIDE(); settings->feed_override = ON; settings->speed_override = ON; } else if (block->m_modes[9] == 49) { DISABLE_FEED_OVERRIDE(); DISABLE_SPEED_OVERRIDE(); settings->feed_override = OFF; settings->speed_override = OFF; } /* user-defined M codes */ for (int index = 100; index < 200; index++) { if (block->m_modes[index] == index) { if (USER_DEFINED_FUNCTION[index - 100] != 0) { (*(USER_DEFINED_FUNCTION[index - 100])) (index - 100, block->p_number, block->q_number); } else { CHK(1, NCE_UNKNOWN_M_CODE_USED); } } } return INTERP_OK;}/****************************************************************************//*! convert_modal_0Returned Value: int If one of the following functions is called and returns an error code, this returns that code. convert_axis_offsets convert_home convert_setup If any of the following errors occur, this returns the error code shown. Otherwise, it returns INTERP_OK. 1. code is not G_4, G_10, G_28, G_30, G_53, G92, G_92_1, G_92_2, or G_92_3: NCE_BUG_CODE_NOT_G4_G10_G28_G30_G53_OR_G92_SERIESSide effects: See belowCalled by: convert_gIf the g_code is g10, g28, g30, g92, g92.1, g92.2, or g92.3 (all are inmodal group 0), it is executed. The other two in modal group 0 (G4 andG53) are executed elsewhere.*/int Interp::convert_modal_0(int code, //!< G code, must be from group 0 block_pointer block, //!< pointer to a block of RS274/NGC instructions setup_pointer settings) //!< pointer to machine settings { static char name[] = "convert_modal_0"; int status; if (code == G_10) { CHP(convert_setup(block, settings)); } else if ((code == G_28) || (code == G_30)) { CHP(convert_home(code, block, settings)); } else if ((code == G_92) || (code == G_92_1) || (code == G_92_2) || (code == G_92_3)) { CHP(convert_axis_offsets(code, block, settings)); } else if ((code == G_4) || (code == G_53)); /* handled elsewhere */ else ERM(NCE_BUG_CODE_NOT_G4_G10_G28_G30_G53_OR_G92_SERIES); return INTERP_OK;}/****************************************************************************//*! convert_motionReturned Value: int If one of the following functions is called and returns an error code, this returns that code. convert_arc convert_cycle convert_probe convert_straight If any of the following errors occur, this returns the error shown. Otherwise, it returns INTERP_OK. 1. The motion code is not 0,1,2,3,38.2,80,81,82,83,84,85,86,87, 88, or 89: NCE_BUG_UNKNOWN_MOTION_CODESide effects: A g_code from the group causing motion (mode 1) is executed.Called
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -