rendered paste bodyIndex: configs/sim/tkemc.ini
===================================================================
RCS file: /cvs/emc2/configs/sim/tkemc.ini,v
retrieving revision 1.4
diff -u -r1.4 tkemc.ini
--- configs/sim/tkemc.ini 10 Sep 2006 20:58:36 -0000 1.4
+++ configs/sim/tkemc.ini 25 Sep 2006 21:59:05 -0000
@@ -18,8 +18,8 @@
# Debug level, 0 means no messages. See src/emc/nml_int/emcglb.h for others
#DEBUG = 0x00000003
# DEBUG = 0x00000007
-# DEBUG = 0x7FFFFFFF
-DEBUG = 0
+ DEBUG = 0x7FFFFFFF
+#DEBUG = 0
# Sections for display options ------------------------------------------------
[DISPLAY]
@@ -115,8 +115,8 @@
# COORDINATES = X Y Z R P W
COORDINATES = X Y Z
HOME = 0 0 0
-LINEAR_UNITS = 0.03937007874016
-ANGULAR_UNITS = 1.0
+LINEAR_UNITS = inch
+ANGULAR_UNITS = degree
CYCLE_TIME = 0.010
DEFAULT_VELOCITY = 0.0167
MAX_VELOCITY = 1.2
@@ -131,7 +131,6 @@
[AXIS_0]
TYPE = LINEAR
-UNITS = 0.03937007874016
HOME = 0.000
MAX_VELOCITY = 1.2
MAX_ACCELERATION = 20.0
@@ -153,7 +152,6 @@
[AXIS_1]
TYPE = LINEAR
-UNITS = 0.03937007874016
HOME = 0.000
MAX_VELOCITY = 1.2
MAX_ACCELERATION = 20.0
@@ -175,7 +173,6 @@
[AXIS_2]
TYPE = LINEAR
-UNITS = 0.03937007874016
HOME = 0.0
MAX_VELOCITY = 1.2
MAX_ACCELERATION = 20.0
Index: nc_files/gridprobe.ngc
===================================================================
RCS file: /cvs/emc2/nc_files/gridprobe.ngc,v
retrieving revision 1.3
diff -u -r1.3 gridprobe.ngc
--- nc_files/gridprobe.ngc 3 Sep 2006 16:47:04 -0000 1.3
+++ nc_files/gridprobe.ngc 25 Sep 2006 21:59:05 -0000
@@ -32,6 +32,7 @@
O3 else
G0X[#1+#2*[#3-#10-1]]
O3 endif
+ M1
G38.2Z#8
G0Z#7
#10=[#10+1]
Index: src/emc/ini/iniaxis.cc
===================================================================
RCS file: /cvs/emc2/src/emc/ini/iniaxis.cc,v
retrieving revision 1.24
diff -u -r1.24 iniaxis.cc
--- src/emc/ini/iniaxis.cc 14 Sep 2006 20:47:41 -0000 1.24
+++ src/emc/ini/iniaxis.cc 25 Sep 2006 21:59:07 -0000
@@ -183,14 +183,41 @@
("invalid inifile value for [%s] UNITS: %s\n",
axisString, inistring);
}
- units = 1.0; // default
+ if (axisType == EMC_AXIS_LINEAR) {
+ units = emcTrajGetLinearUnits(); // get the default UNITS read in the TRAJ section
+ if (EMC_DEBUG & EMC_DEBUG_CONFIG) {
+ rcs_print("using LINEAR_UNITS from TRAJ %d\n", units);
+ }
+ } else if (axisType == EMC_AXIS_ANGULAR) {
+ units = emcTrajGetAngularUnits();
+ if (EMC_DEBUG & EMC_DEBUG_CONFIG) {
+ rcs_print("using ANGULAR_UNITS from TRAJ %d\n", units);
+ }
+ } else {
+ units = 1.0; // default
+ if (EMC_DEBUG & EMC_DEBUG_CONFIG) {
+ rcs_print_error("bad axisType=%d , no known UNITS from TRAJ, using 1.0\n", axisType);
+ }
+ }
}
} else {
// not found at all
- units = 1.0; // default
- if (EMC_DEBUG & EMC_DEBUG_DEFAULTS) {
- rcs_print_error("can't find [%s] UNITS, using default\n",
- axisString);
+ if (axisType == EMC_AXIS_LINEAR) {
+ units = emcTrajGetLinearUnits(); // get the default UNITS read in the TRAJ section
+ if (EMC_DEBUG & EMC_DEBUG_CONFIG) {
+ rcs_print_error("can't find [%s] UNITS, using LINEAR_UNITS from TRAJ %lf\n", axisString, units);
+ }
+ } else if (axisType == EMC_AXIS_ANGULAR) {
+ units = emcTrajGetAngularUnits();
+ if (EMC_DEBUG & EMC_DEBUG_CONFIG) {
+ rcs_print_error("can't find [%s] UNITS, using ANGULAR_UNITS from TRAJ %lf\n", axisString, units);
+ }
+ } else {
+ units = 1.0; // default
+ if (EMC_DEBUG & EMC_DEBUG_DEFAULTS) {
+ rcs_print_error("can't find [%s] UNITS, don't know the axisType (%d) using default %lf\n",
+ axisString, axisType, units);
+ }
}
}
if (0 != emcAxisSetUnits(axis, units)) {
Index: src/emc/ini/initraj.cc
===================================================================
RCS file: /cvs/emc2/src/emc/ini/initraj.cc,v
retrieving revision 1.15
diff -u -r1.15 initraj.cc
--- src/emc/ini/initraj.cc 11 Sep 2006 18:55:37 -0000 1.15
+++ src/emc/ini/initraj.cc 25 Sep 2006 21:59:07 -0000
@@ -65,11 +65,13 @@
const char *inistring;
int axes;
double linearUnits;
+ char linearUnitsName[LINELEN], angularUnitsName[LINELEN];
double angularUnits;
double vel;
double acc;
unsigned char coordinateMark[6] = { 1, 1, 1, 0, 0, 0 };
int t;
+ unsigned char i;
int len;
char homes[LINELEN];
char home[LINELEN];
@@ -106,41 +108,51 @@
if (NULL != (inistring = trajInifile->find("LINEAR_UNITS", "TRAJ"))) {
if (1 == sscanf(inistring, "%lf", &linearUnits)) {
// found, and valid
- } else {
- // found, but invalid
- if (EMC_DEBUG & EMC_DEBUG_INVALID) {
- rcs_print
- ("invalid inifile value for [TRAJ] LINEAR_UNITS: %s\n",
- inistring);
+ } else { //didn't find a number, check for a string
+ if (1 == sscanf(inistring, "%s", linearUnitsName)) {
+ //got a string check in the linear_nv_pairs
+ for (i=0; i < MAX_LIN_NV_PAIRS ; i++) {
+ if (strcmp(linearUnitsName, linear_nv_pairs[i].name) == 0) {
+ linearUnits = linear_nv_pairs[i].value;
+ if (EMC_DEBUG & EMC_DEBUG_CONFIG) {
+ rcs_print("got LINEAR_UNITS '%s' : %lf\n", linearUnitsName, linearUnits);
+ }
+ }
+ }
+ } else {
+ if (EMC_DEBUG & EMC_DEBUG_INVALID) {
+ rcs_print
+ ("invalid inifile value for [TRAJ] LINEAR_UNITS: %s\n",
+ inistring);
+ }
+ linearUnits = 1; // default
}
- linearUnits = 1; // default
- }
- } else {
- // not found at all
- if (EMC_DEBUG & EMC_DEBUG_DEFAULTS) {
- rcs_print("can't find [TRAJ] LINEAR_UNITS, using default\n");
}
- linearUnits = 1; // default
}
-
if (NULL != (inistring = trajInifile->find("ANGULAR_UNITS", "TRAJ"))) {
if (1 == sscanf(inistring, "%lf", &angularUnits)) {
// found, and valid
- } else {
- // found, but invalid
- if (EMC_DEBUG & EMC_DEBUG_INVALID) {
- rcs_print
- ("invalid inifile value for [TRAJ] ANGULAR_UNITS: %s\n",
- inistring);
+ } else { //didn't find a number, check for a string
+ if (1 == sscanf(inistring, "%s", angularUnitsName)) {
+ //got a string check in the linear_nv_pairs
+ for (i=0; i < MAX_CIR_NV_PAIRS ; i++) {
+ if (strcmp(angularUnitsName, circular_nv_pairs[i].name) == 0) {
+ angularUnits = circular_nv_pairs[i].value;
+ if (EMC_DEBUG & EMC_DEBUG_CONFIG) {
+ rcs_print("got ANGULAR_UNITS '%s' : %lf\n", angularUnitsName, angularUnits);
+ }
+ }
+ }
+ } else {
+ // found, but invalid
+ if (EMC_DEBUG & EMC_DEBUG_INVALID) {
+ rcs_print
+ ("invalid inifile value for [TRAJ] ANGULAR_UNITS: %s\n",
+ inistring);
+ }
+ angularUnits = 1; // default
}
- angularUnits = 1; // default
- }
- } else {
- // not found at all
- if (EMC_DEBUG & EMC_DEBUG_DEFAULTS) {
- rcs_print("can't find [TRAJ] ANGULAR_UNITS, using default\n");
}
- angularUnits = 1; // default
}
if (0 != emcTrajSetUnits(linearUnits, angularUnits)) {
Index: src/emc/nml_intf/emc.hh
===================================================================
RCS file: /cvs/emc2/src/emc/nml_intf/emc.hh,v
retrieving revision 1.36
diff -u -r1.36 emc.hh
--- src/emc/nml_intf/emc.hh 14 Sep 2006 20:47:39 -0000 1.36
+++ src/emc/nml_intf/emc.hh 25 Sep 2006 21:59:11 -0000
@@ -456,6 +456,8 @@
extern int emcTrajSetSpindleScale(double scale);
extern int emcTrajSetAdaptiveFeed(unsigned char enable);
extern int emcTrajSetMotionId(int id);
+extern double emcTrajGetLinearUnits();
+extern double emcTrajGetAngularUnits();
extern int emcTrajInit();
extern int emcTrajHalt();
Index: src/emc/nml_intf/emcglb.h
===================================================================
RCS file: /cvs/emc2/src/emc/nml_intf/emcglb.h,v
retrieving revision 1.6
diff -u -r1.6 emcglb.h
--- src/emc/nml_intf/emcglb.h 23 May 2005 01:54:49 -0000 1.6
+++ src/emc/nml_intf/emcglb.h 25 Sep 2006 21:59:11 -0000
@@ -36,6 +36,32 @@
#define RS274NGC_STARTUP_CODE_MAX 256
extern char RS274NGC_STARTUP_CODE[RS274NGC_STARTUP_CODE_MAX];
+#define INCH_MM 0.03937007874016
+#define PIl 3.1415926535897932384626433832795029L /* pi */
+
+struct nameval {
+ char *name;
+ double value;
+};
+
+#define MAX_LIN_NV_PAIRS 4
+const struct nameval linear_nv_pairs[MAX_LIN_NV_PAIRS] = {
+ { "mm", 1.0 },
+ { "metric", 1.0 },
+ { "inch", INCH_MM },
+ { "imperial", INCH_MM },
+ };
+
+#define MAX_CIR_NV_PAIRS 6
+const struct nameval circular_nv_pairs[MAX_CIR_NV_PAIRS] = {
+ { "deg", 1.0 },
+ { "degree", 1.0 },
+ { "grad", 0.9 },
+ { "gon", 0.9 },
+ { "rad", PIl / 180 },
+ { "radian", PIl / 180 },
+ };
+
/* debug bitflags */
/* Note: these may be hard-code referenced by the GUI (e.g., emcdebug.tcl).
If you change the assignments here, make sure and reflect that in
Index: src/emc/task/taskintf.cc
===================================================================
RCS file: /cvs/emc2/src/emc/task/taskintf.cc,v
retrieving revision 1.48
diff -u -r1.48 taskintf.cc
--- src/emc/task/taskintf.cc 18 Sep 2006 19:55:07 -0000 1.48
+++ src/emc/task/taskintf.cc 25 Sep 2006 21:59:14 -0000
@@ -1074,6 +1074,16 @@
return 0;
}
+double emcTrajGetLinearUnits()
+{
+ return localEmcTrajLinearUnits;
+}
+
+double emcTrajGetAngularUnits()
+{
+ return localEmcTrajAngularUnits;
+}
+
int emcTrajSetSpindleSync(double sync)
{
emcmotCommand.command = EMCMOT_SET_SPINDLESYNC;
@@ -1295,13 +1305,14 @@
int r2;
int axis;
+ r2 = emcTrajInit(); // we want to check Traj first, the sane defaults for units are there
+
r1 = -1;
for (axis = 0; axis < EMCMOT_MAX_AXIS; axis++) {
if (0 == emcAxisInit(axis)) {
r1 = 0; // at least one is okay
}
}
- r2 = emcTrajInit();
if (r1 == 0 && r2 == 0) {
emcmotion_initialized = 1;