⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 canon.hh

📁 数控系统中的解释器源代码
💻 HH
📖 第 1 页 / 共 2 页
字号:
#ifndef CANON_HH#define CANON_HH#include <stdio.h>              // FILE/* canon.hhThis is the header file that all applications that use thecanonical commands for three- to six-axis machining should include.Three mutually orthogonal (in a right-handed system) X, Y, and Z axesare always present. In addition, there may be zero to three rotationalaxes: A (parallel to the X-axis), B (parallel to the Y-axis), and C(parallel to the Z-axis).In the functions that use rotational axes, the axis value is that of awrapped linear axis, in degrees.It is assumed in these activities that the spindle tip is always atsome location called the "current location," and the controller alwaysknows where that is. It is also assumed that there is always a"selected plane" which must be the XY-plane, the YZ-plane, or theZX-plane of the machine.*/typedef int CANON_PLANE;#define CANON_PLANE_XY 1#define CANON_PLANE_YZ 2#define CANON_PLANE_XZ 3typedef int CANON_UNITS;#define CANON_UNITS_INCHES 1#define CANON_UNITS_MM 2#define CANON_UNITS_CM 3typedef int CANON_MOTION_MODE;#define CANON_EXACT_STOP 1#define CANON_EXACT_PATH 2#define CANON_CONTINUOUS 3typedef int CANON_SPEED_FEED_MODE;#define CANON_SYNCHED 1#define CANON_INDEPENDENT 2typedef int CANON_SPEED_MODE;#define CANON_RPM 0#define CANON_CONSTANT_VEL 1typedef int CANON_DIRECTION;#define CANON_STOPPED 1#define CANON_CLOCKWISE 2#define CANON_COUNTERCLOCKWISE 3typedef int CANON_FEED_REFERENCE;#define CANON_WORKPIECE 1#define CANON_XYZ 2typedef int CANON_SIDE;#define CANON_SIDE_RIGHT 1#define CANON_SIDE_LEFT 2#define CANON_SIDE_OFF 3typedef int CANON_AXIS;#define CANON_AXIS_X 1#define CANON_AXIS_Y 2#define CANON_AXIS_Z 3#define CANON_AXIS_A 4#define CANON_AXIS_B 5#define CANON_AXIS_C 6/* Currently using the typedefs above rather than the enums belowtypedef enum {CANON_PLANE_XY, CANON_PLANE_YZ, CANON_PLANE_XZ} CANON_PLANE;typedef enum {CANON_UNITS_INCHES, CANON_UNITS_MM, CANON_UNITS_CM} CANON_UNITS;typedef enum {CANON_EXACT_STOP, CANON_EXACT_PATH, CANON_CONTINUOUS}             CANON_MOTION_MODE;typedef enum {CANON_SYNCHED, CANON_INDEPENDENT} CANON_SPEED_FEED_MODE;typedef enum {CANON_STOPPED, CANON_CLOCKWISE, CANON_COUNTERCLOCKWISE}             CANON_DIRECTION;typedef enum {CANON_WORKPIECE, CANON_XYZ} CANON_FEED_REFERENCE;typedef enum {CANON_SIDE_RIGHT, CANON_SIDE_LEFT, CANON_SIDE_OFF} CANON_SIDE;typedef enum {CANON_AXIS_X, CANON_AXIS_Y, CANON_AXIS_Z, CANON_AXIS_A,              CANON_AXIS_B, CANON_AXIS_C} CANON_AXIS;*/struct CANON_VECTOR{  CANON_VECTOR() {}  CANON_VECTOR(double _x, double _y, double _z) {x = _x; y = _y; z = _z;}  double x, y, z;};struct CANON_POSITION{  CANON_POSITION() {}  CANON_POSITION(double _x, double _y, double _z#ifdef AA                , double _a#endif#ifdef BB                , double _b#endif#ifdef CC                , double _c#endif)  {    x = _x; y = _y; z = _z;#ifdef AA    a = _a;#endif#ifdef BB    b = _b;#endif#ifdef CC    c = _c;#endif  }  double x, y, z#ifdef AA       , a#endif#ifdef BB       , b#endif#ifdef CC       , c#endif;};/* Tools are numbered 1..CANON_TOOL_MAX, with tool 0 meaning no tool. */#define CANON_TOOL_MAX 99      // max size of carousel handled#define CANON_TOOL_ENTRY_LEN 256 // how long each file line can bestruct CANON_TOOL_TABLE{  int id;  double length;  double diameter;#ifdef LATHE_FLAG	double zOffset;     //lathe tool   int  orientation;  //lathe tool#endif};/* Initialization *//* reads world model data into the canonical interface */extern void INIT_CANON();/* Representation */extern void SET_ORIGIN_OFFSETS( double x, double y, double z#ifdef AA , double a#else#ifdef ALL_AXES , double a#endif#endif#ifdef BB , double b#else#ifdef ALL_AXES , double b#endif#endif#ifdef CC , double c#else#ifdef ALL_AXES , double c#endif#endif,double x2, double y2, double z2#ifdef AA , double a2#else#ifdef ALL_AXES , double a2#endif#endif#ifdef BB , double b2#else#ifdef ALL_AXES , double b2#endif#endif#ifdef CC , double c2#else#ifdef ALL_AXES , double c2#endif#endif);/* Offset the origin to the point with absolute coordinates x, y, z,a, b, and c. Values of x, y, z, a, b, and c are real numbers. The unitsare whatever length units are being used at the time this command isgiven. */extern void USE_LENGTH_UNITS(CANON_UNITS u);/* Use the specified units for length. Conceptually, the units mustbe either inches or millimeters. */extern void SELECT_PLANE(CANON_PLANE pl);/* Use the plane designated by selected_plane as the selected plane.Conceptually, the selected_plane must be the XY-plane, the XZ-plane, orthe YZ-plane. *//* Free Space Motion */extern void SET_TRAVERSE_RATE(double rate);/* Set the traverse rate that will be used when the spindle traverses. Itis expected that no cutting will occur while a traverse move is beingmade. */extern void STRAIGHT_TRAVERSE( double x, double y, double z#ifdef AA , double a_position#else#ifdef ALL_AXES , double a_position#endif#endif#ifdef BB , double b_position#else#ifdef ALL_AXES , double b_position#endif#endif#ifdef CC , double c_position#else#ifdef ALL_AXES , double c_position#endif#endif);/*Move at traverse rate so that at any time during the move, all axeshave covered the same proportion of their required motion. The finalXYZ position is given by x, y, and z. If there is an a-axis, its finalposition is given by a_position, and similarly for the b-axis and c-axis.A more positive value of a rotational axis is in the counterclockwisedirection.Clockwise or counterclockwise is from the point of view of theworkpiece. If the workpiece is fastened to a turntable, the turntablewill turn clockwise (from the point of view of the machinist or anyoneelse not moving with respect to the machining center) in order to makethe tool move counterclockwise from the point of view of theworkpiece.*//* Machining Attributes */extern void SET_FEED_RATE(int feed_mode,double rate);/*SET_FEED_RATE sets the feed rate that will be used when the spindle istold to move at the currently set feed rate. The rate is either:1. the rate of motion of the tool tip in the workpiece coordinate system,   which is used when the feed_reference mode is "CANON_WORKPIECE", or2. the rate of motion of the tool tip in the XYZ axis system, ignoring   motion of other axes, which is used when the feed_reference mode is   "CANON_XYZ".The units of the rate are:1. If the feed_reference mode is CANON_WORKPIECE:length units (inches or millimeters according to the setting ofCANON_UNITS) per minute along the programmed path as seen by theworkpiece.2. If the feed_reference mode is CANON_XYZ:A. For motion including one rotational axis only: degrees per minute.B. For motion including two rotational axes only: degrees per minute   In this case, the rate applies to the axis with the larger angle   to cover, and the second rotational axis rotates so that it has   always completed the same proportion of its required motion as has   the rotational axis to which the feed rate applies.C. For motion involving one or more of the XYZ axes (with or without   simultaneous rotational axis motion): length units (inches or   millimeters according to the setting of CANON_UNITS) per minute   along the programmed XYZ path.*/extern void SET_FEED_REFERENCE(CANON_FEED_REFERENCE reference);/*This sets the feed_reference mode to either CANON_WORKPIECE orCANON_XYZ.The CANON_WORKPIECE mode is more natural and general, since the rateat which the tool passes through the material must be controlled forsafe and effective machining. For machines with more than the threestandard XYZ axes, however, computing the feed rate may betime-consuming because the trajectories that result from motion infour or more axes may be complex. Computation of path lengths whenonly XYZ motion is considered is quite simple for the two standardmotion types (straight lines and helical arcs).Some programming languages (rs274kt, in particular) use CANON_XYZmode. In these languages, the task of dealing with the rate at whichthe tool tip passes through material is pushed back on the NC-programgenerator, where the computation of path lengths is (almost always in1995) an off-line activity where speed of calculation is not critical.In CANON_WORKPIECE mode, some motions cannot be carried out as fast asthe programmed feed rate would require because axis motions tend tocancel each other. For example, an arc in the YZ-plane can exactlycancel a rotation around the A-axis, so that the location of the tooltip with respect to the workpiece does not change at all during themotion; in this case, the motion should take no time, which isimpossible at any finite rate of axis motion. In such cases, the axesshould be moved as fast as possible consistent with accuratemachining.It would be possible to omit the SET_FEED_REFERENCE command from thecanonical commands and operate always in one mode or the other,letting the interpreter issue SET_FEED_RATE commands, if necessary tocompensate if the NC language being interpreted used the other mode.This would create two disadvantages when the feed_reference modeassumed by the canonical commands differed from that assumed by the NClanguage being interpreted:1. The output code could have a lot of SET_FEED_RATE commands notfound in the input code; this is a relatively minor consideration.2. If the interpreter reads a program in language which uses theCANON_XYZ mode and writes canonical commands in the CANON_WORKPIECEmode, both the interpreter and the executor of the output canonicalcommands would have to perform a lot of complex calculations. With theSET_FEED_REFERENCE command available, both do only simple calculationsfor the same motions.*/extern void SET_MOTION_CONTROL_MODE(CANON_MOTION_MODE mode);/*This sets the motion control mode to one of: CANON_EXACT_STOP,CANON_EXACT_PATH, or CANON_CONTINUOUS.*/extern void SET_CUTTER_RADIUS_COMPENSATION(double radius);/* Set the radius to use when performing cutter radius compensation. */extern void START_CUTTER_RADIUS_COMPENSATION(int direction);/* Conceptually, the direction must be left (meaning the cutterstays to the left of the programmed path) or right. */extern void STOP_CUTTER_RADIUS_COMPENSATION();/* Do not apply cutter radius compensation when executing spindletranslation commands. */extern void START_SPEED_FEED_SYNCH();extern void STOP_SPEED_FEED_SYNCH();/* Machining Functions */extern void ARC_FEED( double first_end, double second_end, double first_axis, double second_axis, int rotation, double axis_end_point#ifdef AA , double a_position#else#ifdef ALL_AXES , double a_position#endif#endif#ifdef BB , double b_position#else#ifdef ALL_AXES , double b_position#endif#endif#ifdef CC , double c_position#else#ifdef ALL_AXES , double c_position#endif#endif);/* Move in a helical arc from the current location at the existing feedrate. The axis of the helix is parallel to the x, y, or z axis,according to which one is perpendicular to the selected plane. Thehelical arc may degenerate to a circular arc if there is no motionparallel to the axis of the helix.1. If the selected plane is the xy-plane:A. first_end is the x-coordinate of the end of the arc.B. second_end is the y-coordinate of the end of the arc.C. first_axis is the x-coordinate of the axis (center) of the arc.D. second_axis is the y-coordinate of the axis.E. axis_end_point is the z-coordinate of the end of the arc.2. If the selected plane is the yz-plane:A. first_end is the y-coordinate of the end of the arc.B. second_end is the z-coordinate of the end of the arc.C. first_axis is the y-coordinate of the axis (center) of the arc.D. second_axis is the z-coordinate of the axis.E. axis_end_point is the x-coordinate of the end of the arc.3. If the selected plane is the zx-plane:A. first_end is the z-coordinate of the end of the arc.B. second_end is the x-coordinate of the end of the arc.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -