Итак, чтобы на токарном станке заставить работать циклы Cannad Cycles (G81, G82,...) без дополнительных танцев с плоскостями и сохранением работоспособности фрезерной версии нужно к действиям в посте #12 , добавить следующее:
в файле src/emc/rs274ngc/interp_cycles.cc функцию
оригинал_convert_cycle (для просмотра содержимого нажмите на ссылку)
заменить на исправленную функцию
Код: Выделить всё
/*! convert_cycle
Returned 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_XZ
Side 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_motion
This function makes a couple checks and then calls one of three
functions, 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
{
CANON_PLANE plane;
CHKS((settings->feed_rate == 0.0), _("Cannot feed with zero feed rate"));
CHKS((settings->feed_mode == INVERSE_TIME), _("Cannot use inverse time feed with canned cycles"));
CHKS((settings->cutter_comp_side), _("Cannot use canned cycles with cutter compensation on"));
plane = settings->plane;
if (!block->r_flag) {
if (settings->motion_mode == motion)
block->r_number = settings->cycle_r;
else
ERS(NCE_R_CLEARANCE_PLANE_UNSPECIFIED_IN_CYCLE);
}
CHKS((block->l_number == 0), NCE_CANNOT_DO_ZERO_REPEATS_OF_CYCLE);
if (block->l_number == -1)
block->l_number = 1;
switch(plane) {
case CANON_PLANE_XY:
case CANON_PLANE_XZ:
case CANON_PLANE_YZ:
CHKS(block->u_flag, "Cannot put a U in a canned cycle in the %s plane",
plane_name(settings->plane));
CHKS(block->v_flag, "Cannot put a V in a canned cycle in the %s plane",
plane_name(settings->plane));
CHKS(block->w_flag, "Cannot put a W in a canned cycle in the %s plane",
plane_name(settings->plane));
break;
case CANON_PLANE_UV:
case CANON_PLANE_VW:
case CANON_PLANE_UW:
CHKS(block->x_flag, "Cannot put an X in a canned cycle in the %s plane",
plane_name(settings->plane));
CHKS(block->y_flag, "Cannot put a Y in a canned cycle in the %s plane",
plane_name(settings->plane));
CHKS(block->z_flag, "Cannot put a Z in a canned cycle in the %s plane",
plane_name(settings->plane));
}
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 if (plane == CANON_PLANE_UV) {
CHP(convert_cycle_uv(motion, block, settings));
} else if (plane == CANON_PLANE_VW) {
CHP(convert_cycle_vw(motion, block, settings));
} else if (plane == CANON_PLANE_UW) {
CHP(convert_cycle_wu(motion, block, settings));
} else
ERS(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 (для просмотра содержимого нажмите на ссылку)
функцию
Код: Выделить всё
/*! convert_cycle
Returned 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_XZ
Side 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_motion
This function makes a couple checks and then calls one of three
functions, 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
{
CANON_PLANE plane;
CHKS((settings->feed_rate == 0.0), _("Cannot feed with zero feed rate"));
CHKS((settings->feed_mode == INVERSE_TIME), _("Cannot use inverse time feed with canned cycles"));
CHKS((settings->cutter_comp_side), _("Cannot use canned cycles with cutter compensation on"));
plane = settings->plane;
if (!block->r_flag) {
if (settings->motion_mode == motion)
block->r_number = settings->cycle_r;
else
ERS(NCE_R_CLEARANCE_PLANE_UNSPECIFIED_IN_CYCLE);
}
CHKS((block->l_number == 0), NCE_CANNOT_DO_ZERO_REPEATS_OF_CYCLE);
if (block->l_number == -1)
block->l_number = 1;
switch(plane) {
case CANON_PLANE_XY:
case CANON_PLANE_XZ:
case CANON_PLANE_YZ:
CHKS(block->u_flag, "Cannot put a U in a canned cycle in the %s plane",
plane_name(settings->plane));
CHKS(block->v_flag, "Cannot put a V in a canned cycle in the %s plane",
plane_name(settings->plane));
CHKS(block->w_flag, "Cannot put a W in a canned cycle in the %s plane",
plane_name(settings->plane));
break;
case CANON_PLANE_UV:
case CANON_PLANE_VW:
case CANON_PLANE_UW:
CHKS(block->x_flag, "Cannot put an X in a canned cycle in the %s plane",
plane_name(settings->plane));
CHKS(block->y_flag, "Cannot put a Y in a canned cycle in the %s plane",
plane_name(settings->plane));
CHKS(block->z_flag, "Cannot put a Z in a canned cycle in the %s plane",
plane_name(settings->plane));
}
if ((plane == CANON_PLANE_XY) or (_setup.lathe_mode == 1)) {
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) and (_setup.lathe_mode == 0)) {
CHP(convert_cycle_zx(motion, block, settings));
} else if (plane == CANON_PLANE_UV) {
CHP(convert_cycle_uv(motion, block, settings));
} else if (plane == CANON_PLANE_VW) {
CHP(convert_cycle_vw(motion, block, settings));
} else if (plane == CANON_PLANE_UW) {
CHP(convert_cycle_wu(motion, block, settings));
} else
ERS(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;
}
оригинал_cycle_feed (для просмотра содержимого нажмите на ссылку)
заменить на исправленную
Код: Выделить всё
/*! cycle_feed
Returned 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_g89
This writes a STRAIGHT_FEED command appropriate for a cycle move with
respect to the given plane. No rotary axis motion takes place.
*/
int Interp::cycle_feed(block_pointer block,
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(block->line_number, end1, end2, end3,
_setup.AA_current, _setup.BB_current, _setup.CC_current,
_setup.u_current, _setup.v_current, _setup.w_current);
else if (plane == CANON_PLANE_YZ)
STRAIGHT_FEED(block->line_number, end3, end1, end2,
_setup.AA_current, _setup.BB_current, _setup.CC_current,
_setup.u_current, _setup.v_current, _setup.w_current);
else if (plane == CANON_PLANE_XZ )
STRAIGHT_FEED(block->line_number, end2, end3, end1,
_setup.AA_current, _setup.BB_current, _setup.CC_current,
_setup.u_current, _setup.v_current, _setup.w_current);
else if (plane == CANON_PLANE_UV)
STRAIGHT_FEED(block->line_number, _setup.current_x, _setup.current_y, _setup.current_z,
_setup.AA_current, _setup.BB_current, _setup.CC_current,
end1, end2, end3);
else if (plane == CANON_PLANE_VW)
STRAIGHT_FEED(block->line_number, _setup.current_x, _setup.current_y, _setup.current_z,
_setup.AA_current, _setup.BB_current, _setup.CC_current,
end3, end1, end2);
else // (plane == CANON_PLANE_UW)
STRAIGHT_FEED(block->line_number, _setup.current_x, _setup.current_y, _setup.current_z,
_setup.AA_current, _setup.BB_current, _setup.CC_current,
end2, end3, end1);
return INTERP_OK;
}
cycle_feed (для просмотра содержимого нажмите на ссылку)
и функцию Код: Выделить всё
/*! cycle_feed
Returned 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_g89
This writes a STRAIGHT_FEED command appropriate for a cycle move with
respect to the given plane. No rotary axis motion takes place.
*/
int Interp::cycle_feed(block_pointer block,
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) or (_setup.lathe_mode == 1))
STRAIGHT_FEED(block->line_number, end1, end2, end3,
_setup.AA_current, _setup.BB_current, _setup.CC_current,
_setup.u_current, _setup.v_current, _setup.w_current);
else if (plane == CANON_PLANE_YZ)
STRAIGHT_FEED(block->line_number, end3, end1, end2,
_setup.AA_current, _setup.BB_current, _setup.CC_current,
_setup.u_current, _setup.v_current, _setup.w_current);
else if ((plane == CANON_PLANE_XZ ) and (_setup.lathe_mode == 0))
STRAIGHT_FEED(block->line_number, end2, end3, end1,
_setup.AA_current, _setup.BB_current, _setup.CC_current,
_setup.u_current, _setup.v_current, _setup.w_current);
else if (plane == CANON_PLANE_UV)
STRAIGHT_FEED(block->line_number, _setup.current_x, _setup.current_y, _setup.current_z,
_setup.AA_current, _setup.BB_current, _setup.CC_current,
end1, end2, end3);
else if (plane == CANON_PLANE_VW)
STRAIGHT_FEED(block->line_number, _setup.current_x, _setup.current_y, _setup.current_z,
_setup.AA_current, _setup.BB_current, _setup.CC_current,
end3, end1, end2);
else // (plane == CANON_PLANE_UW)
STRAIGHT_FEED(block->line_number, _setup.current_x, _setup.current_y, _setup.current_z,
_setup.AA_current, _setup.BB_current, _setup.CC_current,
end2, end3, end1);
return INTERP_OK;
}
оригинал_cycle_traverse (для просмотра содержимого нажмите на ссылку)
Заменить на исправленную
Код: Выделить всё
/*! cycle_traverse
Returned 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 cycle
move with respect to the given plane. No rotary axis motion takes place.
*/
int Interp::cycle_traverse(block_pointer block,
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(block->line_number, end1, end2, end3,
_setup.AA_current, _setup.BB_current, _setup.CC_current,
_setup.u_current, _setup.v_current, _setup.w_current);
else if (plane == CANON_PLANE_YZ)
STRAIGHT_TRAVERSE(block->line_number, end3, end1, end2,
_setup.AA_current, _setup.BB_current, _setup.CC_current,
_setup.u_current, _setup.v_current, _setup.w_current);
else if (plane == CANON_PLANE_XZ)
STRAIGHT_TRAVERSE(block->line_number, end2, end3, end1,
_setup.AA_current, _setup.BB_current, _setup.CC_current,
_setup.u_current, _setup.v_current, _setup.w_current);
else if (plane == CANON_PLANE_UV)
STRAIGHT_TRAVERSE(block->line_number, _setup.current_x, _setup.current_y, _setup.current_z,
_setup.AA_current, _setup.BB_current, _setup.CC_current,
end1, end2, end3);
else if (plane == CANON_PLANE_VW)
STRAIGHT_TRAVERSE(block->line_number, _setup.current_x, _setup.current_y, _setup.current_z,
_setup.AA_current, _setup.BB_current, _setup.CC_current,
end3, end1, end2);
else // (plane == CANON_PLANE_UW)
STRAIGHT_TRAVERSE(block->line_number, _setup.current_x, _setup.current_y, _setup.current_z,
_setup.AA_current, _setup.BB_current, _setup.CC_current,
end2, end3, end1);
return INTERP_OK;
}
исправленная_cycle_traverse (для просмотра содержимого нажмите на ссылку)
Измениния смотрят на наличие "LATHE =1" в секции [DYSPLAY] и если это так то вызывается отработка цикла с подмененными осями.Код: Выделить всё
/*! cycle_traverse
Returned 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 cycle
move with respect to the given plane. No rotary axis motion takes place.
*/
int Interp::cycle_traverse(block_pointer block,
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) or (_setup.lathe_mode == 1))
STRAIGHT_TRAVERSE(block->line_number, end1, end2, end3,
_setup.AA_current, _setup.BB_current, _setup.CC_current,
_setup.u_current, _setup.v_current, _setup.w_current);
else if (plane == CANON_PLANE_YZ)
STRAIGHT_TRAVERSE(block->line_number, end3, end1, end2,
_setup.AA_current, _setup.BB_current, _setup.CC_current,
_setup.u_current, _setup.v_current, _setup.w_current);
else if ((plane == CANON_PLANE_XZ) and (_setup.lathe_mode == 0))
STRAIGHT_TRAVERSE(block->line_number, end2, end3, end1,
_setup.AA_current, _setup.BB_current, _setup.CC_current,
_setup.u_current, _setup.v_current, _setup.w_current);
else if (plane == CANON_PLANE_UV)
STRAIGHT_TRAVERSE(block->line_number, _setup.current_x, _setup.current_y, _setup.current_z,
_setup.AA_current, _setup.BB_current, _setup.CC_current,
end1, end2, end3);
else if (plane == CANON_PLANE_VW)
STRAIGHT_TRAVERSE(block->line_number, _setup.current_x, _setup.current_y, _setup.current_z,
_setup.AA_current, _setup.BB_current, _setup.CC_current,
end3, end1, end2);
else // (plane == CANON_PLANE_UW)
STRAIGHT_TRAVERSE(block->line_number, _setup.current_x, _setup.current_y, _setup.current_z,
_setup.AA_current, _setup.BB_current, _setup.CC_current,
end2, end3, end1);
return INTERP_OK;
}
Pfhf,jnfkb