Someone mentioned on the forum that M67 doesn't work (he wanted to use
it for controlling laser power)
This is undeniably true.
Pavel found a set of IRC logs on the subject showing that many have
tried, but none have succeeded in making it work.
So, Pavel had a go (patch at the end).
It seems to work, to an extent. I am not entirely sure what the best
test would be to demonstrate the difference between M67 and M68. I
tried a 4-quadrant circle with an AIO change at 12, 3, 6, 9 'o'clock.
First, M68: Timing is good, but velocity stutters:
http://imagebin.org/171202
Then with the M67 patch:
http://imagebin.org/171203
The velocity still stutters fractionally, but is much better.
I don't understand why both have pretty much equally good timing, that
doesn't fit with my understanding of the motion queue.

The patched version badly fails the test suite:
Runtest: 49 tests run, 38 successful, 11 failed + 0 expected
Failed:
        .
        ./tests/ccomp/lathe-comp
        ./tests/ccomp/mill-g90g91g92
        ./tests/ccomp/mill-line-arc-entry
        ./tests/interp/cam-nisley
        ./tests/interp/g10/g10-l11
        ./tests/interp/g10/g10-l1-l10
        ./tests/interp/g10/g10-l1
        ./tests/interp/g76
        ./tests/m70-m73/m70m72-restore.0
        ./tests/m70-m73/m73autorestore.0

So there is work needed.
Here is the patch for discussion. (From Pavel, I am just the one still awake).
I imagine that a final version would not hold AIO in a struct named DIO.
There is an implicit limit of 32 of each channel as iomask_t is a u32.
This would need to change as current EMCMOT_MAX_DIO is 64 and
EMC_MOT_MAX_AIO is 16. (Both seem low to me)


=========================================================

>From ee1d4aa907bc9ce1ff85b9e648c899071d5c9cac Mon Sep 17 00:00:00 2001
From: Pavel Shramov <p...@lebu.psha.org.ru>
Date: Tue, 6 Sep 2011 01:15:50 +0400
Subject: [PATCH 8/8] tp: Fix M67 synced AIO

Duplicate DIO code and add fields for AIO into syncdio_t struct.
Since they share same syncdio.anychange variable both are flushed.

v2: Fix tpSetAout function
v3: Fix command submission (minLimit/maxLimit instead of start/end)

tp: Don't overwrite old values when they are not changed

Hold bitmask for aio and dio arrays and only overwrite values
that were changed using tpSetDout and tpSetAout
---
 src/emc/kinematics/tc.h  |    5 +++++
 src/emc/kinematics/tp.c  |   18 ++++++++++++++++++
 src/emc/motion/command.c |    2 +-
 3 files changed, 24 insertions(+), 1 deletions(-)

diff --git a/src/emc/kinematics/tc.h b/src/emc/kinematics/tc.h
index c60764d..71da2aa 100644
--- a/src/emc/kinematics/tc.h
+++ b/src/emc/kinematics/tc.h
@@ -45,9 +45,14 @@ typedef enum {
     TAPPING, REVERSING, RETRACTION, FINAL_REVERSAL, FINAL_PLACEMENT
 } RIGIDTAP_STATE;

+typedef unsigned long iomask_t;
+
 typedef struct {
     char anychanged;
+    iomask_t dio_mask;
+    iomask_t aio_mask;
     signed char dios[EMCMOT_MAX_DIO];
+    double aios[EMCMOT_MAX_AIO];
 } syncdio_t;

 typedef struct {
diff --git a/src/emc/kinematics/tp.c b/src/emc/kinematics/tp.c
index 3f2c386..d53b48c 100644
--- a/src/emc/kinematics/tp.c
+++ b/src/emc/kinematics/tp.c
@@ -54,10 +54,15 @@ int tpCreate(TP_STRUCT * tp, int _queueSize,
TC_STRUCT * tcSpace)
 // anychanged signals if any DIOs need to be changed
 // dios[i] = 1, DIO needs to get turned on, -1 = off
 int tpClearDIOs() {
+    //XXX: All IO's will be flushed on next synced aio/dio! Is it ok?
     int i;
     syncdio.anychanged = 0;
+    syncdio.dio_mask = 0;
+    syncdio.aio_mask = 0;
     for (i = 0; i < num_dio; i++)
        syncdio.dios[i] = 0;
+    for (i = 0; i < num_aio; i++)
+       syncdio.aios[i] = 0;

     return 0;
 }
@@ -621,9 +626,14 @@ void tpToggleDIOs(TC_STRUCT * tc) {
     int i=0;
     if (tc->syncdio.anychanged != 0) { // we have DIO's to turn on or off
        for (i=0; i < num_dio; i++) {
+            if (!(tc->syncdio.dio_mask & (1 << i))) continue;
            if (tc->syncdio.dios[i] > 0) emcmotDioWrite(i, 1); // turn DIO[i] on
            if (tc->syncdio.dios[i] < 0) emcmotDioWrite(i, 0); // turn DIO[i] 
off
        }
+       for (i=0; i < num_aio; i++) {
+            if (!(tc->syncdio.aio_mask & (1 << i))) continue;
+           emcmotAioWrite(i, tc->syncdio.aios[i]); // set AIO[i]
+        }
        tc->syncdio.anychanged = 0; //we have turned them all on/off,
nothing else to do for this TC the next time
     }
 }
@@ -1239,6 +1249,13 @@ int tpActiveDepth(TP_STRUCT * tp)
 }

 int tpSetAout(TP_STRUCT *tp, unsigned char index, double start, double end) {
+    if (0 == tp) {
+       return -1;
+    }
+    syncdio.anychanged = 1; //something has changed
+    syncdio.aio_mask |= (1 << index);
+    syncdio.aios[index] = start;
+    rtapi_print_msg(RTAPI_MSG_ERR, "tpSetAout(%d,%f,%f)\n", index, start, end);
     return 0;
 }

@@ -1247,6 +1264,7 @@ int tpSetDout(TP_STRUCT *tp, int index, unsigned
char start, unsigned char end)
        return -1;
     }
     syncdio.anychanged = 1; //something has changed
+    syncdio.dio_mask |= (1 << index);
     if (start > 0)
        syncdio.dios[index] = 1; // the end value can't be set from canon
currently, and has the same value as start
     else
diff --git a/src/emc/motion/command.c b/src/emc/motion/command.c
index 523fc4f..1278b24 100644
--- a/src/emc/motion/command.c
+++ b/src/emc/motion/command.c
@@ -1476,7 +1476,7 @@ check_stuff ( "before command_handler()" );
                emcmotAioWrite(emcmotCommand->out, emcmotCommand->minLimit);
            } else { // we put it on the TP queue, warning: only room for
one in there, any new ones will overwrite
                tpSetAout(&emcmotDebug->queue, emcmotCommand->out,
-                   emcmotCommand->start, emcmotCommand->end);
+                   emcmotCommand->minLimit, emcmotCommand->maxLimit);
            }
            break;

-- 
1.7.0.4


-- 
atp
"Torque wrenches are for the obedience of fools and the guidance of wise men"

------------------------------------------------------------------------------
Special Offer -- Download ArcSight Logger for FREE!
Finally, a world-class log management solution at an even better 
price-free! And you'll get a free "Love Thy Logs" t-shirt when you
download Logger. Secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsisghtdev2dev
_______________________________________________
Emc-developers mailing list
Emc-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-developers

Reply via email to