Dear fellow developers,
The attached patch file adds the ability to un-home an axis (clear its homed
flag), namely through the new [AXIS_n]VOLATILE_HOME ini file option, the
EMC_AXIS_UNHOME NML message, and the emcAxisUnhome(int axis) call. See
http://www.linuxcnc.org/irc/irc.freenode.net:6667/emc/2008-02-14.txt and
http://www.linuxcnc.org/irc/irc.freenode.net:6667/emc/2008-02-15.txt on the
discussion of "unhom*".

After applying and (re-)compiling, setting VOLATILE_HOME to 1 for any
particular axis will cause it to lose its homed flag upon ESTOP and OFF.

The syntax for the milltask API call is almost identical to its homing
counterpart. Setting the "axis" variable to n unhomes the n-th joint;
setting it to -1, unhomes all joints with the permitting ini entry. Ditto
for the NML message.

jepler suggested that the ini file permit three possible values for
VOLATILE_HOME: "never," "amplifier-off," and "estop." SWPadnos emphasized
the ability to cause unhoming from a HAL module. It should be relatively
easy to move the emcAxisUnhome calls around inside emcTaskSetState to
satisfy the former. As for the latter, an "unhome" pin could be added to
ioControl.cc (or halusr?) which, when triggered, cause it to send the
EMC_AXIS_UNHOME packet. I implemented neither of the two in my patch because
my original purpose was simply to provide the function calls upon which this
feature could be further developed.


Enjoy,
Bryant
diff -Naur emc2/src/emc/ini/iniaxis.cc emc2-unhome/src/emc/ini/iniaxis.cc
--- emc2/src/emc/ini/iniaxis.cc	2007-11-12 12:23:08.000000000 -0500
+++ emc2-unhome/src/emc/ini/iniaxis.cc	2008-02-15 09:09:05.000000000 -0500
@@ -94,6 +94,7 @@
     bool ignore_limits;
     bool is_shared;
     int sequence;
+    int unhome;
     int comp_file_type; //type for the compensation file. type==0 means nom, forw, rev. 
     double maxVelocity;
     double maxAcceleration;
@@ -203,11 +204,13 @@
         axisIniFile->Find(&ignore_limits, "HOME_IGNORE_LIMITS", axisString);
         sequence = -1;	                // default
         axisIniFile->Find(&sequence, "HOME_SEQUENCE", axisString);
+        unhome = 0;	                // default
+        axisIniFile->Find(&unhome, "VOLATILE_HOME", axisString);
 
         // issue NML message to set all params
         if (0 != emcAxisSetHomingParams(axis, home, offset, search_vel,
                                         latch_vel, (int)use_index, (int)ignore_limits,
-                                        (int)is_shared, sequence)) {
+                                        (int)is_shared, sequence, unhome)) {
             if (EMC_DEBUG & EMC_DEBUG_CONFIG) {
                 rcs_print_error("bad return from emcAxisSetHomingParams\n");
             }
diff -Naur emc2/src/emc/motion/command.c emc2-unhome/src/emc/motion/command.c
--- emc2/src/emc/motion/command.c	2008-01-29 01:33:24.000000000 -0500
+++ emc2-unhome/src/emc/motion/command.c	2008-02-15 08:56:43.000000000 -0500
@@ -320,6 +320,7 @@
 void emcmotCommandHandler(void *arg, long period)
 {
     int joint_num;
+    int n;
     emcmot_joint_t *joint;
     double tmp1;
     emcmot_comp_entry_t *comp_entry;
@@ -524,6 +525,7 @@
 	    joint->home_latch_vel = emcmotCommand->latch_vel;
 	    joint->home_flags = emcmotCommand->flags;
 	    joint->home_sequence = emcmotCommand->home_sequence;
+	    joint->unhome = emcmotCommand->unhome;
 	    break;
 
 	case EMCMOT_OVERRIDE_LIMITS:
@@ -1205,6 +1207,45 @@
 #endif
 	    break;
 
+	case EMCMOT_UNHOME:
+		/* unhome the specified joint */
+		/* any mode, except while homing */
+		rtapi_print_msg(RTAPI_MSG_DBG, "UNHOME");
+		rtapi_print_msg(RTAPI_MSG_DBG, " %d", joint_num);
+
+		if (joint)
+		{
+			if (!joint->unhome)
+			{
+				reportError("can't unhome this axis");
+				break;
+			}
+			if (GET_JOINT_HOMING_FLAG(joint))
+			{
+				reportError("can't clear homed flag(s) while homing");
+				break;
+			}
+			else
+			{
+				SET_JOINT_HOMED_FLAG(joint, 0);
+			}
+		}
+		else
+		{
+			if (joint_num==-1)
+			{
+				for (n = 0; n < num_joints; n++)
+				{
+					/* point at joint data */
+					joint = &(joints[n]);
+					/* clear flag */
+					if (joint->unhome)
+						SET_JOINT_HOMED_FLAG(joint, 0);
+				}
+			}
+		}
+		break;
+
 	case EMCMOT_DISABLE_WATCHDOG:
 	    rtapi_print_msg(RTAPI_MSG_DBG, "DISABLE_WATCHDOG");
 /*! \todo Another #if 0 */
diff -Naur emc2/src/emc/motion/motion.h emc2-unhome/src/emc/motion/motion.h
--- emc2/src/emc/motion/motion.h	2007-11-23 16:24:33.000000000 -0500
+++ emc2-unhome/src/emc/motion/motion.h	2008-02-15 08:44:23.000000000 -0500
@@ -123,6 +123,7 @@
 	EMCMOT_OVERRIDE_LIMITS,	/* temporarily ignore limits until jog done */
 
 	EMCMOT_HOME,		/* home a joint */
+	EMCMOT_UNHOME,		/* taint (and clear) joint's homed flag */
 	EMCMOT_JOG_CONT,	/* continuous jog */
 	EMCMOT_JOG_INCR,	/* incremental jog */
 	EMCMOT_JOG_ABS,		/* absolute jog */
@@ -218,6 +219,7 @@
 	double latch_vel;	/* home latch velocity */
 	int flags;		/* homing config flags, other boolean args */
 	int home_sequence;      /* order in homing sequence */
+	int unhome; /* conditions for clearing the homed flag */
 	double minFerror;	/* min following error */
 	double maxFerror;	/* max following error */
 	int wdWait;		/* cycle to wait before toggling wd */
@@ -456,6 +458,7 @@
 	double home_offset;	/* dir/dist from switch to home point */
 	double home;		/* joint coordinate of home point */
 	int home_flags;		/* flags for various homing options */
+	int unhome;
 	double backlash;	/* amount of backlash */
 	int home_sequence;      /* Order in homing sequence */
 	emcmot_comp_t comp;	/* leadscrew correction data */
diff -Naur emc2/src/emc/nml_intf/emc.cc emc2-unhome/src/emc/nml_intf/emc.cc
--- emc2/src/emc/nml_intf/emc.cc	2007-11-05 15:19:06.000000000 -0500
+++ emc2-unhome/src/emc/nml_intf/emc.cc	2008-02-15 08:51:22.000000000 -0500
@@ -104,6 +104,9 @@
     case EMC_AXIS_HOME_TYPE:
 	((EMC_AXIS_HOME *) buffer)->update(cms);
 	break;
+    case EMC_AXIS_UNHOME_TYPE:
+	((EMC_AXIS_UNHOME *) buffer)->update(cms);
+	break;
     case EMC_AXIS_INCR_JOG_TYPE:
 	((EMC_AXIS_INCR_JOG *) buffer)->update(cms);
 	break;
@@ -565,6 +568,8 @@
 	return "EMC_AXIS_HALT";
     case EMC_AXIS_HOME_TYPE:
 	return "EMC_AXIS_HOME";
+    case EMC_AXIS_UNHOME_TYPE:
+	return "EMC_AXIS_UNHOME";
     case EMC_AXIS_INCR_JOG_TYPE:
 	return "EMC_AXIS_INCR_JOG";
     case EMC_AXIS_INIT_TYPE:
@@ -2589,6 +2594,13 @@
 
 }
 
+void EMC_AXIS_UNHOME::update(CMS * cms)
+{
+
+    EMC_AXIS_CMD_MSG::update(cms);
+
+}
+
 /*
 *	NML/CMS Update function for EMC_AXIS_INIT
 *	Automatically generated by NML CodeGen Java Applet.
@@ -2866,6 +2878,7 @@
     cms->update(latch_vel);
     cms->update(use_index);
     cms->update(ignore_limits);
+    cms->update(unhome);
 
 }
 
diff -Naur emc2/src/emc/nml_intf/emc.hh emc2-unhome/src/emc/nml_intf/emc.hh
--- emc2/src/emc/nml_intf/emc.hh	2007-11-15 15:13:56.000000000 -0500
+++ emc2-unhome/src/emc/nml_intf/emc.hh	2008-02-15 08:48:42.000000000 -0500
@@ -84,6 +84,7 @@
 #define EMC_AXIS_ENABLE_TYPE                         ((NMLTYPE) 121)
 #define EMC_AXIS_DISABLE_TYPE                        ((NMLTYPE) 122)
 #define EMC_AXIS_HOME_TYPE                           ((NMLTYPE) 123)
+#define EMC_AXIS_UNHOME_TYPE                           ((NMLTYPE) 135)
 #define EMC_AXIS_JOG_TYPE                            ((NMLTYPE) 124)
 #define EMC_AXIS_INCR_JOG_TYPE                       ((NMLTYPE) 125)
 #define EMC_AXIS_ABS_JOG_TYPE                        ((NMLTYPE) 126)
@@ -399,7 +400,7 @@
 extern int emcAxisSetHomingParams(int axis, double home, double offset,
 				  double search_vel, double latch_vel,
 				  int use_index, int ignore_limits,
-				  int is_shared, int home_sequence);
+				  int is_shared, int home_sequence, int unhome);
 extern int emcAxisSetMaxVelocity(int axis, double vel);
 extern int emcAxisSetMaxAcceleration(int axis, double acc);
 
@@ -409,6 +410,7 @@
 extern int emcAxisEnable(int axis);
 extern int emcAxisDisable(int axis);
 extern int emcAxisHome(int axis);
+extern int emcAxisUnhome(int axis);
 extern int emcAxisJog(int axis, double vel);
 extern int emcAxisIncrJog(int axis, double incr, double vel);
 extern int emcAxisAbsJog(int axis, double pos, double vel);
diff -Naur emc2/src/emc/nml_intf/emc_nml.hh emc2-unhome/src/emc/nml_intf/emc_nml.hh
--- emc2/src/emc/nml_intf/emc_nml.hh	2007-11-12 17:23:54.000000000 -0500
+++ emc2-unhome/src/emc/nml_intf/emc_nml.hh	2008-02-15 08:50:32.000000000 -0500
@@ -277,6 +277,7 @@
     int ignore_limits;
     int is_shared;
     int home_sequence;
+    int unhome;
 };
 
 class EMC_AXIS_SET_MAX_VELOCITY:public EMC_AXIS_CMD_MSG {
@@ -352,6 +353,16 @@
     void update(CMS * cms);
 };
 
+class EMC_AXIS_UNHOME:public EMC_AXIS_CMD_MSG {
+  public:
+    EMC_AXIS_UNHOME():EMC_AXIS_CMD_MSG(EMC_AXIS_UNHOME_TYPE,
+				     sizeof(EMC_AXIS_UNHOME)) {
+    };
+
+    // For internal NML/CMS use only.
+    void update(CMS * cms);
+};
+
 class EMC_AXIS_JOG:public EMC_AXIS_CMD_MSG {
   public:
     EMC_AXIS_JOG():EMC_AXIS_CMD_MSG(EMC_AXIS_JOG_TYPE,
diff -Naur emc2/src/emc/task/emctask.cc emc2-unhome/src/emc/task/emctask.cc
--- emc2/src/emc/task/emctask.cc	2007-11-12 17:23:54.000000000 -0500
+++ emc2-unhome/src/emc/task/emctask.cc	2008-02-15 09:06:19.000000000 -0500
@@ -194,6 +194,7 @@
 	for (t = 0; t < emcStatus->motion.traj.axes; t++) {
 	    emcAxisDisable(t);
 	}
+	emcAxisUnhome(-1);
 	emcTrajDisable();
 	emcLubeOff();
 	emcTaskAbort();
@@ -224,6 +225,7 @@
 	for (t = 0; t < emcStatus->motion.traj.axes; t++) {
 	    emcAxisDisable(t);
 	}
+	emcAxisUnhome(-1);
 	emcTrajDisable();
 	emcLubeOff();
 	emcTaskAbort();
diff -Naur emc2/src/emc/task/emctaskmain.cc emc2-unhome/src/emc/task/emctaskmain.cc
--- emc2/src/emc/task/emctaskmain.cc	2008-01-22 20:46:52.000000000 -0500
+++ emc2-unhome/src/emc/task/emctaskmain.cc	2008-02-15 08:52:03.000000000 -0500
@@ -300,6 +300,7 @@
 static EMC_AXIS_DISABLE *disable_msg;
 static EMC_AXIS_ENABLE *enable_msg;
 static EMC_AXIS_HOME *home_msg;
+static EMC_AXIS_UNHOME *unhome_msg;
 static EMC_AXIS_JOG *jog_msg;
 static EMC_AXIS_ABORT *axis_abort_msg;
 static EMC_AXIS_INCR_JOG *incr_jog_msg;
@@ -531,6 +532,7 @@
 	    case EMC_AXIS_SET_OUTPUT_TYPE:
 	    case EMC_AXIS_LOAD_COMP_TYPE:
 	    case EMC_AXIS_SET_STEP_PARAMS_TYPE:
+	    case EMC_AXIS_UNHOME_TYPE:
 	    case EMC_TRAJ_SET_SCALE_TYPE:
 	    case EMC_TRAJ_SET_SPINDLE_SCALE_TYPE:
 	    case EMC_TRAJ_SET_FO_ENABLE_TYPE:
@@ -619,6 +621,7 @@
 	    case EMC_AXIS_ABORT_TYPE:
 	    case EMC_AXIS_HALT_TYPE:
 	    case EMC_AXIS_HOME_TYPE:
+	    case EMC_AXIS_UNHOME_TYPE:
 	    case EMC_AXIS_JOG_TYPE:
 	    case EMC_AXIS_INCR_JOG_TYPE:
 	    case EMC_AXIS_ABS_JOG_TYPE:
@@ -717,6 +720,7 @@
 		case EMC_AXIS_SET_MIN_FERROR_TYPE:
 		case EMC_AXIS_SET_OUTPUT_TYPE:
 		case EMC_AXIS_SET_STEP_PARAMS_TYPE:
+		case EMC_AXIS_UNHOME_TYPE:
 		case EMC_TRAJ_PAUSE_TYPE:
 		case EMC_TRAJ_RESUME_TYPE:
 		case EMC_TRAJ_ABORT_TYPE:
@@ -814,6 +818,7 @@
 		case EMC_AXIS_SET_MIN_FERROR_TYPE:
 		case EMC_AXIS_SET_OUTPUT_TYPE:
 		case EMC_AXIS_SET_STEP_PARAMS_TYPE:
+		case EMC_AXIS_UNHOME_TYPE:
 		case EMC_TRAJ_PAUSE_TYPE:
 		case EMC_TRAJ_RESUME_TYPE:
 		case EMC_TRAJ_ABORT_TYPE:
@@ -1019,6 +1024,7 @@
 		case EMC_AXIS_SET_MIN_FERROR_TYPE:
 		case EMC_AXIS_SET_OUTPUT_TYPE:
 		case EMC_AXIS_SET_STEP_PARAMS_TYPE:
+		case EMC_AXIS_UNHOME_TYPE:
 		case EMC_TRAJ_PAUSE_TYPE:
 		case EMC_TRAJ_RESUME_TYPE:
 		case EMC_TRAJ_ABORT_TYPE:
@@ -1101,6 +1107,7 @@
 		case EMC_AXIS_SET_MIN_FERROR_TYPE:
 		case EMC_AXIS_SET_OUTPUT_TYPE:
 		case EMC_AXIS_SET_STEP_PARAMS_TYPE:
+		case EMC_AXIS_UNHOME_TYPE:
 		case EMC_TRAJ_PAUSE_TYPE:
 		case EMC_TRAJ_RESUME_TYPE:
 		case EMC_TRAJ_ABORT_TYPE:
@@ -1200,6 +1207,7 @@
 	    case EMC_AXIS_SET_MIN_FERROR_TYPE:
 	    case EMC_AXIS_SET_OUTPUT_TYPE:
 	    case EMC_AXIS_SET_STEP_PARAMS_TYPE:
+	    case EMC_AXIS_UNHOME_TYPE:
 	    case EMC_TRAJ_SET_SCALE_TYPE:
 	    case EMC_TRAJ_SET_SPINDLE_SCALE_TYPE:
 	    case EMC_TRAJ_SET_FO_ENABLE_TYPE:
@@ -1469,6 +1477,11 @@
 	retval = emcAxisHome(home_msg->axis);
 	break;
 
+    case EMC_AXIS_UNHOME_TYPE:
+	unhome_msg = (EMC_AXIS_UNHOME *) cmd;
+	retval = emcAxisUnhome(unhome_msg->axis);
+	break;
+
     case EMC_AXIS_JOG_TYPE:
 	jog_msg = (EMC_AXIS_JOG *) cmd;
 	retval = emcAxisJog(jog_msg->axis, jog_msg->vel);
@@ -1508,7 +1521,8 @@
 					set_homing_params_msg->use_index,
 					set_homing_params_msg->ignore_limits,
 					set_homing_params_msg->is_shared,
-					set_homing_params_msg->home_sequence);
+					set_homing_params_msg->home_sequence,
+					set_homing_params_msg->unhome);
 	break;
 
     case EMC_AXIS_SET_FERROR_TYPE:
diff -Naur emc2/src/emc/task/taskintf.cc emc2-unhome/src/emc/task/taskintf.cc
--- emc2/src/emc/task/taskintf.cc	2008-01-07 19:55:52.000000000 -0500
+++ emc2-unhome/src/emc/task/taskintf.cc	2008-02-15 08:42:16.000000000 -0500
@@ -226,7 +226,7 @@
 int emcAxisSetHomingParams(int axis, double home, double offset,
 			   double search_vel, double latch_vel,
 			   int use_index, int ignore_limits, int is_shared,
-			   int sequence)
+			   int sequence,int unhome)
 {
     if (axis < 0 || axis >= EMCMOT_MAX_JOINTS) {
 	return 0;
@@ -240,6 +240,7 @@
     emcmotCommand.latch_vel = latch_vel;
     emcmotCommand.flags = 0;
     emcmotCommand.home_sequence = sequence;
+    emcmotCommand.unhome = unhome;
     if (use_index) {
 	emcmotCommand.flags |= HOME_USE_INDEX;
     }
@@ -441,6 +442,18 @@
     return usrmotWriteEmcmotCommand(&emcmotCommand);
 }
 
+int emcAxisUnhome(int axis)
+{
+	if (axis < -1 || axis >= EMCMOT_MAX_JOINTS) {
+		return 0;
+	}
+
+	emcmotCommand.command = EMCMOT_UNHOME;
+	emcmotCommand.axis = axis;
+
+	return usrmotWriteEmcmotCommand(&emcmotCommand);
+}
+
 int emcAxisJog(int axis, double vel)
 {
     if (axis < 0 || axis >= EMCMOT_MAX_JOINTS) {
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Emc-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-developers

Reply via email to