Hello Guest it is December 14, 2019, 12:51:44 PM

Author Topic: Movement plugin problems  (Read 4553 times)

0 Members and 1 Guest are viewing this topic.

Movement plugin problems
« on: July 12, 2008, 07:12:01 PM »
Hi,

I've been toying with the idea of building my own USB interface to stepper drives (like smooth stepper) so have just started looking at how to create a Mach plugin to control motion. I've been having a bit of trouble trying to get it going.

I have based my plugin on the "BlankMovement" plugin in the SDK, referring to the other samples for details on how to get it all to work. I have managed to get a fair bit of it working correctly including jogging but am having problems with the movement ring buffer. The problem is that each entry in the buffer does not contain correct information about the commanded movement.

From what I have read and seen in example source code, I would expect the "sx, sy, etc." members of GMoves for each buffer entry to contain the present or starting position of the move and "ex, ey, etc." to contain the ending move within the timeframe of the buffer entry. This is not the case. For example, issuing the MDI command G0X100 results in the first entry in the buffer containing zeros for sx, sy, sz, ex, ey and ez. Second and subsequent entries contain the same except for sz that contains an invalid floating point value (-1.#IND00).

The problem looks suspiciously like I am using the wrong version of the SDK headers for the version of Mach that I am using although I've tried it with a few versions. The SDK version is 2.62. The versions of Mach I've tried it with are R2.63, R3.041 plus a couple of other older versions. With each version I got a slightly different result but no correct results.

I am using VS2003 to compile the plugin.

Can anybody help?!

Thanks,

Roy

Offline da21

*
  •  87 87
    • View Profile
    • M-Machine
Re: Movement plugin problems
« Reply #1 on: July 13, 2008, 04:33:17 AM »
yes i'll give you a help , contact me directly off list and we can work through it with out cloggin up the forum

i'll need to know your setup etc

Dave
Re: Movement plugin problems
« Reply #2 on: June 17, 2009, 12:21:50 PM »
Hi everyone,

I'm having the exact same problem as the original poster above...  Could someone please help me out?

All I'm attempting to do is dump the values of the GMoves structure to a logfile, but none of the values make sense, given the simple G Code I'm running...  Mach3 does fill the ring buffer (that is to say, TrajHead is moving).

I think I'm probably missing some setting in the initialization...  I'm also using Visual Studio 2008 (if that could be a problem).

The code I currently have looks something like this (logfile bits stripped out)...


//----------------------------------------------------------------------------------------------------------------------

void myInitControl()
{
    MachView->m_PrinterOn = false;
    MainPlanner->ExternalType = EX_VMS;
    MainPlanner->ExTime = .001;
}

//----------------------------------------------------------------------------------------------------------------------

void myUpdate ()
{
    int axis;


    // Check for GMoves to handle...
    while(Engine->TrajHead != Engine->TrajIndex)
    {
        // Here is where I try to dump the sx, sy, sz, ex, ey, ez values of the GMoves structure to a logfile...
        // MainPlanner->Movements[Engine->TrajIndex].sx
        // MainPlanner->Movements[Engine->TrajIndex].sy
        // MainPlanner->Movements[Engine->TrajIndex].sz
        // MainPlanner->Movements[Engine->TrajIndex].ex
        // MainPlanner->Movements[Engine->TrajIndex].ey
        // MainPlanner->Movements[Engine->TrajIndex].ez


        axis = 0;
        while(axis < 6)
        {
            // Here is where I try to dump the DDA values of the GMoves structure to a logfile...
            // MainPlanner->Movements[Engine->TrajIndex].DDA1[axis]
            // MainPlanner->Movements[Engine->TrajIndex].DDA2[axis]
            // MainPlanner->Movements[Engine->TrajIndex].DDA3[axis]
            axis++;
        }

        // Go to the next move...
        Engine->TrajIndex = (Engine->TrajIndex+1) & 0xfff;
    }
}

//----------------------------------------------------------------------------------------------------------------------

The logfile output looks something like this...

Movement[0]
Start 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
End 0.000000 0.000000 5.388000 1.000000 0.000000 0.000000
  Axis 0...
    DDA1 == 0.0000000000
    DDA2 == 0.0000000000
    DDA3 == 0.0000000000
  Axis 1...
    DDA1 == 1.8075690409
    DDA2 == -0.0283553731
    DDA3 == -0.0283553731
  Axis 2...
    DDA1 == 0.0000000000
    DDA2 == 0.0000000000
    DDA3 == 0.0000000000
  Axis 3...
    DDA1 == 0.0000000000
    DDA2 == 0.0000000000
    DDA3 == 0.0000000000
  Axis 4...
    DDA1 == 0.0000000000
    DDA2 == 0.0000000000
    DDA3 == 0.0000000000
  Axis 5...
    DDA1 == 0.0000000000
    DDA2 == 0.0000000000
    DDA3 == 0.0000000000

...With the DDA's being handled as fixed point numbers (top 32 bits for signed whole number, lower 32 bits for unsigned portion past the decimal point)...

Any help would be greatly appreciated.

Thanks,
-Aaron