On 11/09/2013 07:40 PM, alan wrote:
> To test it I have quickly rewritten my g-code wheels program see
> attached file.
> It currently works only for paths cut in XY plane using XY movements. I
> cannot check this but  the axis path plot look ok.

I made some small changes to the code. It runs a bit faster than the
original version.


Please note, gcmc 1.1.1 cannot compile it, you need version 1.1.2 or the
git version. Version 1.1.1 lacks the ability to accept function calls as
arguments in the creation of vector-lists (dies on an assert()).

Get version 1.1.2 at:
  http://www.vagrearg.org/content/gcmc

The documentation is also updated.

-- 
Greetings Bertho

(disclaimers are disclaimed)
/********************************************************/
/* Code to produce wheels paths                         */
/* Using GCMC Compiler                                  */
/* Author: Alan Battersby                               */
/* Version: 1.0                                         */
/********************************************************/

/********************************************************/
/* Each wheel is a vector of three components           */
/* Radius - The radius of the wheel                     */
/* Speed  - The speed of the wheel                      */
/* Phase  - The phase of the wheel                      */

function Radius(wheel)
{
        return wheel[0];
}

function Speed(wheel)
{
        return wheel[1];
}

function Phase(wheel)
{
        return wheel[2];
}

function CreateWheel(r, s, p)
{
        return [r,s,p];
}

/* Wheels are held in global vector list called wheels  */

function CalcPoint(wheels, angle)
{
        local at, posn, r, s, p, w;

        posn = [0, 0];

        foreach (wheels; w)
        {
                r = Radius(w);
                s = Speed(w);
                p = Phase(w);
                at = s * angle + p;
                posn += [r * cos(at), r * sin(at) ];
        }

        return posn;
}

function CutPath(wheels, start, inc, end, cdepth, scale)
{
        local angle, point;
        /* move to first point at safe height */
        for(angle = start; angle <= end; angle += inc)
        {
                if (angle == start)
                {
                  /* we should be at safe height */
                  /* so move to cutting depth    */
                        point = CalcPoint(wheels, angle);
                        point = ScaleBy(scale, point);
                        goto(point);
                        goto([-,-,cdepth * scale[2]]);
                }
                else
                {
                        point = CalcPoint(wheels, angle);
                        point = ScaleBy(scale, point);
                        move(point);
                }
        }
}
/******************* Library ****************************/
function GoAtSafeHeight(x,y)
{
        goto([-,-,safeheight]);
        goto([x,y,safeheight]);
}

function ScaleBy(sv, v)
{
        return [sv[0] * v[0], sv[1] * v[1]];
}
/******************* main program ***********************/
safeheight = 1mm;
cuttingdepth = -1mm;
svec = [5,5,1];
wheels = {
        CreateWheel(10, 1, 0deg),
        CreateWheel(5, 7, 0deg),
        CreateWheel(3.333, -17, 90deg)
};
feedrate(60);
GoAtSafeHeight(0, 0);
CutPath(wheels, 0deg, 0.01deg, 360deg, cuttingdepth, svec);
GoAtSafeHeight(0, 0);

------------------------------------------------------------------------------
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore
techniques for threading, error checking, porting, and tuning. Get the most 
from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
_______________________________________________
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users

Reply via email to