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

📄 motion.h

📁 CNC 的开放码,EMC2 V2.2.8版
💻 H
📖 第 1 页 / 共 2 页
字号:
/********************************************************************* Description: motion.h*   Data structures used throughout emc2.** Author:* License: GPL Version 2* System: Linux** Copyright (c) 2004 All rights reserved** Last change:* $Revision: 1.87.2.1 $* $Author: jepler $* $Date: 2007/11/29 03:22:47 $********************************************************************//* jmk says: This file is a mess! *//*Misc ramblings:The terms axis and joint are used inconsistently throughout EMC.For all new code, the usages are as follows:    axis - one of the six degrees of freedom, x, y, z, a, b, c	these refer to axes in Cartesian space, which may or	may not match up with joints (see below). On Cartesian	machines they do match up, but for hexapods, robots, and	other non-Cartesian machines they don't.    joint - one of the physical degrees of freedom of the machine	these might be linear (leadscrews) or rotary (rotary	tables, robot arm joints).  There can be any number of	joints.  The kinematics code is responsible for translating	from axis space to joint space and back.There are three main kinds of data needed by the motion controller1) data shared with higher level stuff - commands, status, etc.2) data that is local to the motion controller3) data shared with lower level stuff - hal pinsIn addition, some internal data (2) should be shared for troubleshooting purposes, even though it is "internal" to the motioncontroller.  Depending on the type of data, it can either betreated as type (1), and made available to the higher levelcode, or it can be treated as type (3), and made available tothe hal, so that halscope can monitor it.This file should ONLY contain structures and declarations fortype (1) items - those that are shared with higher level code.Type (2) items should be declared in mot_priv.h, alongwith type (3) items.In the interest of retaining my sanity, I'm not gonna attemptto move everything to its proper location yet....However, all new items will be defined in the proper place,and some existing items may be moved from one struct definitionto another.*//* the following line can be used to control where some of the   "internal" motion controller data is stored.  By default,   it is stored in staticlly allocated kernel memory.  However,   if STRUCTS_IN_SHMEM is defined, it will be stored in the   emcmotStruct shared memory area, for debugging purposes.*/// #define STRUCTS_IN_SHMEM#ifndef MOTION_H#define MOTION_H#include "posemath.h"		/* PmCartesian, PmPose, pmCartMag() */#include "emcpos.h"		/* EmcPose */#include "cubic.h"		/* CUBIC_STRUCT, CUBIC_COEFF */#include "emcmotcfg.h"		/* EMCMOT_MAX_AXIS, EMCMOT_MAX_JOINTS */#include "kinematics.h"#ifdef __cplusplusextern "C" {#endif    typedef struct _EMC_TELEOP_DATA {	EmcPose currentVel;	EmcPose currentAccell;	EmcPose desiredVel;	EmcPose desiredAccell;    } EMC_TELEOP_DATA;/* This enum lists all the possible commands */    typedef enum {	EMCMOT_ABORT = 1,	/* abort all motion */	EMCMOT_AXIS_ABORT,	/* abort one axis */	EMCMOT_ENABLE,		/* enable servos for active axes */	EMCMOT_DISABLE,		/* disable servos for active axes */	EMCMOT_ENABLE_AMPLIFIER,	/* enable amp outputs */	EMCMOT_DISABLE_AMPLIFIER,	/* disable amp outputs */	EMCMOT_ENABLE_WATCHDOG,	/* enable watchdog sound, parport */	EMCMOT_DISABLE_WATCHDOG,	/* enable watchdog sound, parport */	EMCMOT_ACTIVATE_JOINT,	/* make axis active */	EMCMOT_DEACTIVATE_JOINT,	/* make axis inactive */	EMCMOT_PAUSE,		/* pause motion */	EMCMOT_RESUME,		/* resume motion */	EMCMOT_STEP,		/* resume motion until id encountered */	EMCMOT_FREE,		/* set mode to free (joint) motion */	EMCMOT_COORD,		/* set mode to coordinated motion */	EMCMOT_TELEOP,		/* set mode to teleop */	EMCMOT_SPINDLE_SCALE,	/* set scale factor for spindle speed */	EMCMOT_SS_ENABLE,	/* enable/disable scaling the spindle speed */	EMCMOT_FEED_SCALE,	/* set scale factor for feedrate */	EMCMOT_FS_ENABLE,	/* enable/disable scaling feedrate */	EMCMOT_FH_ENABLE,	/* enable/disable feed_hold */	EMCMOT_AF_ENABLE,	/* enable/disable adaptive feedrate */	EMCMOT_OVERRIDE_LIMITS,	/* temporarily ignore limits until jog done */	EMCMOT_HOME,		/* home an axis */	EMCMOT_JOG_CONT,	/* continuous jog */	EMCMOT_JOG_INCR,	/* incremental jog */	EMCMOT_JOG_ABS,		/* absolute jog */	EMCMOT_SET_LINE,	/* queue up a linear move */	EMCMOT_SET_CIRCLE,	/* queue up a circular move */	EMCMOT_SET_TELEOP_VECTOR,	/* Move at a given velocity but in					   world cartesian coordinates, not					   in joint space like EMCMOT_JOG_* */	EMCMOT_CLEAR_PROBE_FLAGS,	/* clears probeTripped flag */	EMCMOT_PROBE,		/* go to pos, stop if probe trips, record				   trip pos */	EMCMOT_RIGID_TAP,	/* go to pos, with sync to spindle speed, 				   then return to initial pos */	EMCMOT_SET_POSITION_LIMITS,	/* set the axis position +/- limits */	EMCMOT_SET_BACKLASH,	/* set the axis backlash */	EMCMOT_SET_MIN_FERROR,	/* minimum following error, input units */	EMCMOT_SET_MAX_FERROR,	/* maximum following error, input units */	EMCMOT_SET_VEL,		/* set the velocity for subsequent moves */	EMCMOT_SET_VEL_LIMIT,	/* set the max vel for all moves (tooltip) */	EMCMOT_SET_JOINT_VEL_LIMIT,	/* set the max axis vel */	EMCMOT_SET_JOINT_ACC_LIMIT,	/* set the max axis accel */	EMCMOT_SET_ACC,		/* set the max accel for moves (tooltip) */	EMCMOT_SET_TERM_COND,	/* set termination condition (stop, blend) */	EMCMOT_SET_NUM_AXES,	/* set the number of axes */	EMCMOT_SET_WORLD_HOME,	/* set pose for world home */	EMCMOT_SET_HOMING_PARAMS,	/* sets axis homing parameters */	EMCMOT_SET_DEBUG,       /* sets the debug level */	EMCMOT_SET_DOUT,        /* sets or unsets a DIO, this can be imediate or synched with motion */	EMCMOT_SET_AOUT,	/* sets or unsets a AIO, this can be imediate or synched with motion */        EMCMOT_SET_SPINDLESYNC, /* syncronize motion to spindle encoder */		EMCMOT_SET_SPINDLE_VEL,	/* set the spindle vel (>0 means forward, <0 means backward) */	EMCMOT_SPINDLE_ON,	/* start the spindle */	EMCMOT_SPINDLE_OFF,	/* stop the spindle */	EMCMOT_SPINDLE_INCREASE,	/* spindle faster */	EMCMOT_SPINDLE_DECREASE,	/* spindle slower */	EMCMOT_SPINDLE_BRAKE_ENGAGE,	/* engage the spindle brake */	EMCMOT_SPINDLE_BRAKE_RELEASE,	/* release the spindle brake */	EMCMOT_SET_MOTOR_OFFSET,	/* set the offset between joint and motor */	EMCMOT_SET_JOINT_COMP,	/* set a compensation triplet for a joint (nominal, forw., rev.) */    } cmd_code_t;/* this enum lists the possible results of a command */    typedef enum {	EMCMOT_COMMAND_OK = 0,	/* cmd honored */	EMCMOT_COMMAND_UNKNOWN_COMMAND,	/* cmd not understood */	EMCMOT_COMMAND_INVALID_COMMAND,	/* cmd can't be handled now */	EMCMOT_COMMAND_INVALID_PARAMS,	/* bad cmd params */	EMCMOT_COMMAND_BAD_EXEC	/* error trying to initiate */    } cmd_status_t;/* termination conditions for queued motions */#define EMCMOT_TERM_COND_STOP 1#define EMCMOT_TERM_COND_BLEND 2/*********************************       COMMAND STRUCTURE*********************************//* This is the command structure.  There is one of these in shared   memory, and all commands from higher level code come thru it.*/    typedef struct emcmot_command_t {	unsigned char head;	/* flag count for mutex detect */	cmd_code_t command;	/* command code (enum) */	int commandNum;		/* increment this for new command */	double motor_offset;    /* offset from joint to motor position */	double maxLimit;	/* pos value for position limit, output */	double minLimit;	/* neg value for position limit, output */	EmcPose pos;		/* line/circle endpt, or teleop vector */	PmCartesian center;	/* center for circle */	PmCartesian normal;	/* normal vec for circle */	int turn;		/* turns for circle */	double vel;		/* max velocity */        double ini_maxvel;      /* max velocity allowed by machine                                   constraints (the ini file) */        int motion_type;        /* this move is because of traverse, feed, arc, or toolchange */        double spindlesync;     /* user units per spindle revolution, 0 = no sync */	double acc;		/* max acceleration */	double backlash;	/* amount of backlash */	int id;			/* id for motion */	int termCond;		/* termination condition */	double tolerance;	/* tolerance for path deviation in CONTINUOUS mode */	int axis;		/* which index to use for below */	double scale;		/* velocity scale or spindle_speed scale arg */	double offset;		/* input, output, or home offset arg */	double home;		/* joint home position */	double search_vel;	/* home search velocity */	double latch_vel;	/* home latch velocity */	int flags;		/* homing config flags, other boolean args */	int home_sequence;      /* order in homing sequence */	double minFerror;	/* min following error */	double maxFerror;	/* max following error */	int wdWait;		/* cycle to wait before toggling wd */	int debug;		/* debug level, from DEBUG in .ini file */	unsigned char now, out, start, end;	/* these are related to synched AOUT/DOUT. now=wether now or synched, out = which gets set, start=start value, end=end value */	unsigned char mode;	/* used for turning overrides etc. on/off */	double comp_nominal, comp_forward, comp_reverse; /* compensation triplet, nominal, forward, reverse */	unsigned char tail;	/* flag count for mutex detect */    } emcmot_command_t;/*! \todo FIXME - these packed bits might be replaced with chars   memory is cheap, and being able to access them without those   damn macros would be nice*//* motion flag type */    typedef unsigned short EMCMOT_MOTION_FLAG;/*  motion status flag structure-- looks like:  MSB                             LSB  v---------------v------------------v  |   |   |   | T | CE | C | IP | EN |  ^---------------^------------------^  where:  EN is 1 if calculations are enabled, 0 if not  IP is 1 if all axes in position, 0 if not  C is 1 if coordinated mode, 0 if in free mode  CE is 1 if coordinated mode error, 0 if not  T is 1 if we are in teleop mode.  *//* bit masks */#define EMCMOT_MOTION_ENABLE_BIT      0x0001#define EMCMOT_MOTION_INPOS_BIT       0x0002#define EMCMOT_MOTION_COORD_BIT       0x0004#define EMCMOT_MOTION_ERROR_BIT       0x0008#define EMCMOT_MOTION_TELEOP_BIT      0x0010/* axis flag type */    typedef unsigned short EMCMOT_AXIS_FLAG;/*  axis status flag structure-- looks like:  MSB                                                          LSB  ----------v-----------------v--------------------v-------------------v  | AF | FE | AH | HD | H | HS | NHL | PHL | - | - | ER | IP | AC | EN |  ----------^-----------------^--------------------^-------------------^                 x = unused  where:  EN  is 1 if axis amplifier is enabled, 0 if not  AC  is 1 if axis is active for calculations, 0 if not  IP  is 1 if axis is in position, 0 if not (free mode only)  ER  is 1 if axis has an error, 0 if not  PHL is 1 if axis is on maximum hardware limit, 0 if not  NHL is 1 if axis is on minimum hardware limit, 0 if not  HS  is 1 if axis home switch is tripped, 0 if not  H   is 1 if axis is homing, 0 if not  HD  is 1 if axis has been homed, 0 if not  AH  is 1 if axis is at home position, 0 if not  FE  is 1 if axis exceeded following error, 0 if not  AF  is 1 if amplifier is faulted, 0 if notSuggestion: Split this in to an Error and a Status flag register..             Then a simple test on each of the two flags can be performed             rather than testing each bit... Saving on a global per axis             fault and ready status flag.  *//* bit masks */#define EMCMOT_AXIS_ENABLE_BIT         0x0001#define EMCMOT_AXIS_ACTIVE_BIT         0x0002#define EMCMOT_AXIS_INPOS_BIT          0x0004#define EMCMOT_AXIS_ERROR_BIT          0x0008#define EMCMOT_AXIS_MAX_HARD_LIMIT_BIT 0x0040#define EMCMOT_AXIS_MIN_HARD_LIMIT_BIT 0x0080#define EMCMOT_AXIS_HOME_SWITCH_BIT    0x0100#define EMCMOT_AXIS_HOMING_BIT         0x0200#define EMCMOT_AXIS_HOMED_BIT          0x0400/*! \todo FIXME - I'm not sure AT_HOME is being reported correctly.   AT_HOME is cleared when you jog in free mode, but not if   you do a coordinated move... perhaps that is the intended   behavior.*/#define EMCMOT_AXIS_AT_HOME_BIT        0x0800#define EMCMOT_AXIS_FERROR_BIT         0x1000#define EMCMOT_AXIS_FAULT_BIT          0x2000/*! \todo FIXME - the terms "teleop", "coord", and "free" are poorly   documented.  This is my feeble attempt to understand exactly   what they mean.   According to Fred, teleop is never used with machine tools,   although that may not be true for machines with non-trivial   kinematics.   "coord", or coordinated mode, means that all the axis are   synchronized, and move together as commanded by the higher   level code.  It is the normal mode when machining.  In   coordinated mode, commands are assumed to be in the cartesean   reference frame, and if the machine is non-cartesean, the   commands are translated by the kinematics to drive each   axis in joint space as needed.   "free" mode means commands are interpreted in joint space.   It is used for jogging individual axes (joints), although   it does not preclude multiple axes moving at once (I think).   Homing is also done in free mode, in fact machines with   non-trivial kinematics must be homed before they can go   into either coord or teleop mode.   'teleop' is what you probably want if you are 'jogging'   a hexapod.  The jog commands as implemented by the motion   controller are joint jogs, which work in free mode.  But   if you want to jog a hexapod or similar machine along   one particular cartesean axis, you need to operate more   than one joint.  That's what 'teleop' is for.*//* compensation structures */    typedef struct {	double nominal;		/* nominal (command) position */	float fwd_trim;		/* correction for forward movement */	float rev_trim;		/* correction for reverse movement */	float fwd_slope;	/* slopes between here and next pt */	float rev_slope;    } emcmot_comp_entry_t; #define EMCMOT_COMP_SIZE 256    typedef struct {	int entries;		/* number of entries in the array */	emcmot_comp_entry_t *entry;  /* current entry in array */

⌨️ 快捷键说明

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