All pastes #238829 Raw Edit

Untitled

public text v1 · immutable
#238829 ·published 2006-11-05 03:32 UTC
rendered paste body
Index: src/emc/kinematics/tc.h
===================================================================
RCS file: /cvs/emc2/src/emc/kinematics/tc.h,v
retrieving revision 1.20
diff -u -r1.20 tc.h
--- src/emc/kinematics/tc.h	30 Sep 2006 14:45:52 -0000	1.20
+++ src/emc/kinematics/tc.h	5 Nov 2006 03:29:09 -0000
@@ -70,6 +70,7 @@
     int synchronized;       // spindle sync required for this move
     double uu_per_rev;      // for sync, user units per rev (e.g. 0.0625 for 16tpi)
     double vel_at_blend_start;
+    unsigned char enables;  // Feed scale, etc, enable bits for this move
 } TC_STRUCT;
 
 /* TC_STRUCT functions */
Index: src/emc/kinematics/tp.c
===================================================================
RCS file: /cvs/emc2/src/emc/kinematics/tp.c,v
retrieving revision 1.63
diff -u -r1.63 tp.c
--- src/emc/kinematics/tp.c	6 Oct 2006 03:56:17 -0000	1.63
+++ src/emc/kinematics/tp.c	5 Nov 2006 03:29:11 -0000
@@ -80,7 +80,7 @@
     tp->depth = tp->activeDepth = 0;
     tp->aborting = 0;
     tp->pausing = 0;
-    tp->vScale = emcmotStatus->overallVscale;
+    tp->vScale = emcmotStatus->net_feed_scale;
     tp->synchronized = 0;
     tp->uu_per_rev = 0.0;
     emcmotStatus->spindleSync = 0;
@@ -243,7 +243,7 @@
 // of the previous move to the new end specified here at the
 // currently-active accel and vel settings from the tp struct.
 
-int tpAddLine(TP_STRUCT * tp, EmcPose end, int type, double vel, double ini_maxvel, double acc)
+int tpAddLine(TP_STRUCT * tp, EmcPose end, int type, double vel, double ini_maxvel, double acc, unsigned char enables)
 {
     TC_STRUCT tc;
     PmLine line_xyz, line_abc;
@@ -296,6 +296,7 @@
 
     tc.synchronized = tp->synchronized;
     tc.uu_per_rev = tp->uu_per_rev;
+    tc.enables = enables;
 
     if (tcqPut(&tp->queue, tc) == -1) {
         rtapi_print_msg(RTAPI_MSG_ERR, "tcqPut failed.\n");
@@ -321,7 +322,7 @@
 
 int tpAddCircle(TP_STRUCT * tp, EmcPose end,
 		PmCartesian center, PmCartesian normal, int turn, int type,
-                double vel, double ini_maxvel, double acc)
+                double vel, double ini_maxvel, double acc, unsigned char enables)
 {
     TC_STRUCT tc;
     PmCircle circle;
@@ -376,6 +377,7 @@
 
     tc.synchronized = tp->synchronized;
     tc.uu_per_rev = tp->uu_per_rev;
+    tc.enables = enables;
 
     if (tcqPut(&tp->queue, tc) == -1) {
 	return -1;
@@ -509,6 +511,8 @@
         tp->execId = 0;
         tp->motionType = 0;
         tpResume(tp);
+	// when not executing a move, use the current enable flags
+	emcmotStatus->enables_queued = emcmotStatus->enables_new;
         return 0;
     }
 
@@ -528,10 +532,6 @@
         tc = tcqItem(&tp->queue, 0, period);
         if(!tc) return 0;
     }
-
-    // report our line number to the guis
-    tp->execId = tc->id;
-
     // this is no longer the segment we were waiting for
     if(waiting && waiting != tc->id) 
         waiting = 0;
@@ -654,13 +654,13 @@
 		nexttc->feed_override = 1.0;
 		if(nexttc->reqvel < 0.0) nexttc->reqvel = 0.0;
 	    } else {
-		nexttc->feed_override = emcmotStatus->overallVscale;
+		nexttc->feed_override = emcmotStatus->net_feed_scale;
 	    }
 	}
     } else {
-        tc->feed_override = emcmotStatus->overallVscale;
+        tc->feed_override = emcmotStatus->net_feed_scale;
         if(nexttc) {
-	    nexttc->feed_override = emcmotStatus->overallVscale;
+	    nexttc->feed_override = emcmotStatus->net_feed_scale;
 	}
     }
     /* handle pausing */
@@ -740,9 +740,15 @@
         if(tc->currentvel > nexttc->currentvel) {
             tp->motionType = tc->canon_motion_type;
 	    emcmotStatus->distance_to_go = tc->target - tc->progress;
+	    emcmotStatus->enables_queued = tc->enables;
+	    // report our line number to the guis
+	    tp->execId = tc->id;
         } else {
             tp->motionType = nexttc->canon_motion_type;
 	    emcmotStatus->distance_to_go = nexttc->target - nexttc->progress;
+	    emcmotStatus->enables_queued = nexttc->enables;
+	    // report our line number to the guis
+	    tp->execId = nexttc->id;
         }
 
         secondary_before = tcGetPos(nexttc);
@@ -769,6 +775,9 @@
         tp->motionType = tc->canon_motion_type;
 	emcmotStatus->distance_to_go = tc->target - tc->progress;
         tp->currentPos = primary_after;
+	emcmotStatus->enables_queued = tc->enables;
+	// report our line number to the guis
+	tp->execId = tc->id;
     }
     return 0;
 }
Index: src/emc/kinematics/tp.h
===================================================================
RCS file: /cvs/emc2/src/emc/kinematics/tp.h,v
retrieving revision 1.20
diff -u -r1.20 tp.h
--- src/emc/kinematics/tp.h	30 Sep 2006 14:45:52 -0000	1.20
+++ src/emc/kinematics/tp.h	5 Nov 2006 03:29:11 -0000
@@ -69,10 +69,10 @@
 extern int tpSetTermCond(TP_STRUCT * tp, int cond, double tolerance);
 extern int tpSetPos(TP_STRUCT * tp, EmcPose pos);
 extern int tpAddLine(TP_STRUCT * tp, EmcPose end, int type, double vel, double
-        ini_maxvel, double acc);
+        ini_maxvel, double acc, unsigned char enables);
 extern int tpAddCircle(TP_STRUCT * tp, EmcPose end, PmCartesian center,
         PmCartesian normal, int turn, int type, double vel, double ini_maxvel,
-        double acc);
+        double acc, unsigned char enables);
 extern int tpRunCycle(TP_STRUCT * tp, long period);
 extern int tpPause(TP_STRUCT * tp);
 extern int tpResume(TP_STRUCT * tp);
Index: src/emc/motion/command.c
===================================================================
RCS file: /cvs/emc2/src/emc/motion/command.c,v
retrieving revision 1.72
diff -u -r1.72 command.c
--- src/emc/motion/command.c	5 Nov 2006 02:15:15 -0000	1.72
+++ src/emc/motion/command.c	5 Nov 2006 03:29:15 -0000
@@ -805,7 +805,7 @@
 	    /* append it to the emcmotDebug->queue */
 	    tpSetId(&emcmotDebug->queue, emcmotCommand->id);
 	    rtapi_print_msg(RTAPI_MSG_DBG, "SET_LINE");
-	    if (-1 == tpAddLine(&emcmotDebug->queue, emcmotCommand->pos, emcmotCommand->motion_type, emcmotCommand->vel, emcmotCommand->ini_maxvel, emcmotCommand->acc)) {
+	    if (-1 == tpAddLine(&emcmotDebug->queue, emcmotCommand->pos, emcmotCommand->motion_type, emcmotCommand->vel, emcmotCommand->ini_maxvel, emcmotCommand->acc, emcmotStatus->enables_new)) {
 		reportError("can't add linear move");
 		emcmotStatus->commandStatus = EMCMOT_COMMAND_BAD_EXEC;
 		tpAbort(&emcmotDebug->queue);
@@ -852,7 +852,7 @@
 		    emcmotCommand->center, emcmotCommand->normal,
 		    emcmotCommand->turn, emcmotCommand->motion_type,
                     emcmotCommand->vel, emcmotCommand->ini_maxvel,
-                    emcmotCommand->acc)) {
+                    emcmotCommand->acc, emcmotStatus->enables_new)) {
 		reportError("can't add circular move");
 		emcmotStatus->commandStatus = EMCMOT_COMMAND_BAD_EXEC;
 		tpAbort(&emcmotDebug->queue);
@@ -954,7 +954,7 @@
 	    if (emcmotCommand->scale < 0.0) {
 		emcmotCommand->scale = 0.0;	/* clamp it */
 	    }
-	    emcmotStatus->qVscale = emcmotCommand->scale;
+	    emcmotStatus->feed_scale = emcmotCommand->scale;
 	    break;
 
 	case EMCMOT_FS_ENABLE:
@@ -962,10 +962,11 @@
 	    /* can happen at any time */
 	    if ( emcmotCommand->mode != 0 ) {
 		rtapi_print_msg(RTAPI_MSG_DBG, "FEED SCALE: ON");
+		emcmotStatus->enables_new |= FS_ENABLED;
             } else {
 		rtapi_print_msg(RTAPI_MSG_DBG, "FEED SCALE: OFF");
+		emcmotStatus->enables_new &= ~FS_ENABLED;
 	    }
-	    emcmotStatus->fo_mode = emcmotCommand->mode; //0 means no override is possible
 	    break;
 
 	case EMCMOT_FH_ENABLE:
@@ -973,10 +974,11 @@
 	    /* can happen at any time */
 	    if ( emcmotCommand->mode != 0 ) {
 		rtapi_print_msg(RTAPI_MSG_DBG, "FEED HOLD: ENABLED");
+		emcmotStatus->enables_new |= FH_ENABLED;
             } else {
 		rtapi_print_msg(RTAPI_MSG_DBG, "FEED HOLD: DISABLED");
+		emcmotStatus->enables_new &= ~FH_ENABLED;
 	    }
-	    /*FIXME : JMK does something usefull here with emcmotCommand->mode; //0 means feed_hold is not taken into consideration*/
 	    break;
 
 	case EMCMOT_SPINDLE_SCALE:
@@ -994,22 +996,22 @@
 	    /* can happen at any time */
 	    if ( emcmotCommand->mode != 0 ) {
 		rtapi_print_msg(RTAPI_MSG_DBG, "SPINDLE SCALE: ON");
+		emcmotStatus->enables_new |= SS_ENABLED;
             } else {
 		rtapi_print_msg(RTAPI_MSG_DBG, "SPINDLE SCALE: OFF");
+		emcmotStatus->enables_new &= ~SS_ENABLED;
 	    }
-	    emcmotStatus->so_mode = emcmotCommand->mode; //0 means no override is possible
 	    break;
 
-
 	case EMCMOT_AF_ENABLE:
 	    /* enable/disable adaptive feedrate override from HAL pin */
 	    /* can happen at any time */
 	    if ( emcmotCommand->flags != 0 ) {
 		rtapi_print_msg(RTAPI_MSG_DBG, "ADAPTIVE FEED: ON");
-		emcmotStatus->adaptiveEnabled = 1;
+		emcmotStatus->enables_new |= AF_ENABLED;
             } else {
 		rtapi_print_msg(RTAPI_MSG_DBG, "ADAPTIVE FEED: OFF");
-		emcmotStatus->adaptiveEnabled = 0;
+		emcmotStatus->enables_new &= ~AF_ENABLED;
 	    }
 	    break;
 
@@ -1176,7 +1178,7 @@
 
 	    /* append it to the emcmotDebug->queue */
 	    tpSetId(&emcmotDebug->queue, emcmotCommand->id);
-	    if (-1 == tpAddLine(&emcmotDebug->queue, emcmotCommand->pos, emcmotCommand->motion_type, emcmotCommand->vel, emcmotCommand->ini_maxvel, emcmotCommand->acc)) {
+	    if (-1 == tpAddLine(&emcmotDebug->queue, emcmotCommand->pos, emcmotCommand->motion_type, emcmotCommand->vel, emcmotCommand->ini_maxvel, emcmotCommand->acc, emcmotStatus->enables_new)) {
 		reportError("can't add probe move");
 		emcmotStatus->commandStatus = EMCMOT_COMMAND_BAD_EXEC;
 		tpAbort(&emcmotDebug->queue);
Index: src/emc/motion/control.c
===================================================================
RCS file: /cvs/emc2/src/emc/motion/control.c,v
retrieving revision 1.79
diff -u -r1.79 control.c
--- src/emc/motion/control.c	16 Oct 2006 22:23:05 -0000	1.79
+++ src/emc/motion/control.c	5 Nov 2006 03:29:22 -0000
@@ -363,9 +363,10 @@
 static void process_inputs(void)
 {
     int joint_num;
-    double abs_ferror, tmp;
+    double abs_ferror, tmp, scale;
     axis_hal_t *axis_data;
     emcmot_joint_t *joint;
+    unsigned char enables;
 
     /* read probe input */
     if (*(emcmot_hal_data->probe_input)) {
@@ -406,30 +407,48 @@
     }
     /* read spindle angle (for threading, etc) */
     emcmotStatus->spindleRevs = *emcmot_hal_data->spindle_revs;
-    if ( emcmotStatus->adaptiveEnabled ) {
-	/* read and clamp (0.0 to 1.0) adaptive feed pin */
+    /* compute net feed and spindle scale factors */
+    if ( emcmotStatus->motion_state == EMCMOT_MOTION_COORD ) {
+	/* use the enables that were queued with the current move */
+	enables = emcmotStatus->enables_queued;
+    } else {
+	/* use the enables that are in effect right now */
+	enables = emcmotStatus->enables_new;
+    }
+    /* feed scaling first:  feed_scale, adaptive_feed, and feed_hold */
+    scale = 1.0;
+    if ( enables & FS_ENABLED ) {
+	scale *= emcmotStatus->feed_scale;
+    }
+    if ( enables & AF_ENABLED ) {
+	/* read and clamp (0.0 to 1.0) adaptive feed HAL pin */
 	tmp = *emcmot_hal_data->adaptive_feed;
 	if ( tmp > 1.0 ) {
 	    tmp = 1.0;
 	} else if ( tmp < 0.0 ) {
 	    tmp = 0.0;
 	}
-	/* set overall scale to user command times hal value */
-	/* if fo_mode == 0, override = 0, and we travel at 100% Feed_override (leave adaptive still working)*/
-	if (emcmotStatus->fo_mode == 0) {
-	    emcmotStatus->overallVscale = tmp;
-	} else {
-	    emcmotStatus->overallVscale = tmp * emcmotStatus->qVscale;
-	}
-    } else {
-	/* set overall scale based on user command only */
-	/* if fo_mode == 0, override = 0, and we travel at 100% Feed_override*/
-	if (emcmotStatus->fo_mode == 0) {
-	    emcmotStatus->overallVscale = 1;
-	} else {
-	    emcmotStatus->overallVscale = emcmotStatus->qVscale;
+	scale *= tmp;
+    }
+/* FIXME = the feed hold pin doesn't exist yet */
+#if 0
+    if ( enables & FH_ENABLED ) {
+	/* read feed hold HAL pin */
+	if ( *emcmot_hal_data->feed_hold ) {
+	    scale = 0;
 	}
     }
+#endif
+    /* save the resulting combined scale factor */
+    emcmotStatus->net_feed_scale = scale;
+
+    /* now do spindle scaling: only one item to consider */
+    scale = 1.0;
+    if ( enables & SS_ENABLED ) {
+	scale *= emcmotStatus->spindle_scale;
+    }
+    /* save the resulting combined scale factor */
+    emcmotStatus->net_spindle_scale = scale;
 
     /* read and process per-joint inputs */
     for (joint_num = 0; joint_num < EMCMOT_MAX_AXIS; joint_num++) {
@@ -1732,7 +1751,7 @@
 		}
 		/* velocity limit = planner limit * global scale factor */
 		/* the global factor is used for feedrate override */
-		vel_lim = joint->free_vel_lim * emcmotStatus->overallVscale;
+		vel_lim = joint->free_vel_lim * emcmotStatus->net_feed_scale;
 		/* must not be greater than the joint physical limit */
 		if (vel_lim > joint->vel_limit) {
 		    vel_lim = joint->vel_limit;
@@ -2229,7 +2248,7 @@
 	 * (together) but this requires some interaction that
 	 * isn't implemented yet.
 	 */ 
-        v_max = 0.5 * joint->vel_limit * emcmotStatus->overallVscale;
+        v_max = 0.5 * joint->vel_limit * emcmotStatus->net_feed_scale;
         a_max = 0.5 * joint->acc_limit;
         v = joint->backlash_vel;
         if (joint->backlash_corr >= 0.0) {
@@ -2340,15 +2359,8 @@
     emcmot_hal_data->coord_mode = GET_MOTION_COORD_FLAG();
     emcmot_hal_data->teleop_mode = GET_MOTION_TELEOP_FLAG();
     emcmot_hal_data->coord_error = GET_MOTION_ERROR_FLAG();
-    
-    /* if so_mode == 0, override is not possible, we use  100% Spindle speed*/
-    if (emcmotStatus->so_mode == 0) {
-	*(emcmot_hal_data->spindle_speed_out) = emcmotStatus->spindle.speed;
-	*(emcmot_hal_data->spindle_on) = (emcmotStatus->spindle.speed != 0) ? 1 : 0;
-    } else {
-	*(emcmot_hal_data->spindle_speed_out) = emcmotStatus->spindle.speed * emcmotStatus->spindle_scale;
-	*(emcmot_hal_data->spindle_on) = ((emcmotStatus->spindle.speed * emcmotStatus->spindle_scale) != 0) ? 1 : 0;
-    }
+    *(emcmot_hal_data->spindle_speed_out) = emcmotStatus->spindle.speed * emcmotStatus->spindle_scale;
+    *(emcmot_hal_data->spindle_on) = ((emcmotStatus->spindle.speed * emcmotStatus->net_spindle_scale) != 0) ? 1 : 0;
     *(emcmot_hal_data->spindle_forward) = (emcmotStatus->spindle.speed > 0) ? 1 : 0;
     *(emcmot_hal_data->spindle_reverse) = (emcmotStatus->spindle.speed < 0) ? 1 : 0;
     *(emcmot_hal_data->spindle_brake) = (emcmotStatus->spindle.brake != 0) ? 1 : 0;
@@ -2359,8 +2371,8 @@
        and copy elsewhere if you want to observe an automatic variable that
        isn't in scope here. */
     emcmot_hal_data->debug_bit_0 = joints[1].free_tp_active;
-    emcmot_hal_data->debug_bit_1 = emcmotStatus->adaptiveEnabled;
-    emcmot_hal_data->debug_float_0 = emcmotStatus->overallVscale;
+    emcmot_hal_data->debug_bit_1 = emcmotStatus->enables_new & AF_ENABLED;
+    emcmot_hal_data->debug_float_0 = emcmotStatus->net_feed_scale;
     emcmot_hal_data->debug_float_1 = 0.0;
     *emcmot_hal_data->spindle_sync = emcmotStatus->spindleSync;
 
Index: src/emc/motion/motion.c
===================================================================
RCS file: /cvs/emc2/src/emc/motion/motion.c,v
retrieving revision 1.82
diff -u -r1.82 motion.c
--- src/emc/motion/motion.c	3 Nov 2006 19:38:38 -0000	1.82
+++ src/emc/motion/motion.c	5 Nov 2006 03:29:25 -0000
@@ -782,12 +782,11 @@
     emcmotStatus->vel = VELOCITY;
     emcmotConfig->limitVel = VELOCITY;
     emcmotStatus->acc = ACCELERATION;
-    emcmotStatus->qVscale = 1.0;
-    emcmotStatus->fo_mode = 1;
-    emcmotStatus->so_mode = 1;
+    emcmotStatus->feed_scale = 1.0;
     emcmotStatus->spindle_scale = 1.0;
-    emcmotStatus->overallVscale = 1.0;
-    emcmotStatus->adaptiveEnabled = 0;
+    emcmotStatus->net_feed_scale = 1.0;
+    emcmotStatus->enables_new = 0;
+    emcmotStatus->enables_queued = 0;
     emcmotStatus->id = 0;
     emcmotStatus->depth = 0;
     emcmotStatus->activeDepth = 0;
Index: src/emc/motion/motion.h
===================================================================
RCS file: /cvs/emc2/src/emc/motion/motion.h,v
retrieving revision 1.69
diff -u -r1.69 motion.h
--- src/emc/motion/motion.h	5 Nov 2006 02:15:16 -0000	1.69
+++ src/emc/motion/motion.h	5 Nov 2006 03:29:27 -0000
@@ -419,6 +419,15 @@
 #define HOME_USE_INDEX		2
 #define HOME_IS_SHARED		4
 
+
+/* flags for enabling spindle scaling, feed scaling,
+   adaptive feed, and feed hold */
+
+#define SS_ENABLED 0x01
+#define FS_ENABLED 0x02
+#define AF_ENABLED 0x04
+#define FH_ENABLED 0x08
+
 /* This structure contains all of the data associated with
    a single joint.  Note that this structure does not need
    to be in shared memory (but it can, if desired for debugging
@@ -557,11 +566,16 @@
 	int commandNumEcho;	/* echo of input command number */
 	cmd_status_t commandStatus;	/* result of most recent command */
 	/* these are config info, updated when a command changes them */
-	double qVscale;		/* velocity scale factor for all motion */
+	double feed_scale;	/* velocity scale factor for all motion */
 	double spindle_scale;	/* velocity scale factor for spindle speed */
-	int adaptiveEnabled;	/* non-zero when adaptive feed is enabled */
-	double overallVscale;	/* net scale factor (includes adaptive, and uses 1 for qVscale if mode = 0) */
+	unsigned char enables_new;	/* flags for FS, SS, etc */
+		/* the above set is the enables in effect for new moves */
 	/* the rest are updated every cycle */
+	double net_feed_scale;	/* net scale factor for all motion */
+	double net_spindle_scale;	/* net scale factor for spindle */
+	unsigned char enables_queued;	/* flags for FS, SS, etc */
+		/* the above set is the enables in effect for the
+		   currently executing move */
 	motion_state_t motion_state; /* operating state: FREE, COORD, etc. */
 	EMCMOT_MOTION_FLAG motionFlag;	/* see above for bit details */
 	EmcPose carte_pos_cmd;	/* commanded Cartesian position */
@@ -586,9 +600,6 @@
 
 	spindle_status spindle;	/* data types for spindle status */
 
-	unsigned char fo_mode;	/* mode for feed_override. while 0 no feed_override will be possible. will work at 100% */
-	unsigned char so_mode;	/* mode for spindle_override. while 0 no spindle_override will be possible. will work at 100% */
-
 /*! \todo FIXME - all structure members beyond this point are in limbo */
 
 	/* dynamic status-- changes every cycle */
Index: src/emc/task/taskintf.cc
===================================================================
RCS file: /cvs/emc2/src/emc/task/taskintf.cc,v
retrieving revision 1.59
diff -u -r1.59 taskintf.cc
--- src/emc/task/taskintf.cc	5 Nov 2006 02:15:22 -0000	1.59
+++ src/emc/task/taskintf.cc	5 Nov 2006 03:29:30 -0000
@@ -1080,7 +1080,7 @@
     }
 
     stat->paused = emcmotStatus.paused;
-    stat->scale = emcmotStatus.qVscale;
+    stat->scale = emcmotStatus.feed_scale;
     stat->spindle_scale = emcmotStatus.spindle_scale;
 
     stat->position = emcmotStatus.carte_pos_cmd;