Adding a Spindle to Auggie

C Scripting questions and answers
Post Reply
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4586
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Adding a Spindle to Auggie

Post by ArtF »

  Hi:

Well, as we discussed before, things like spindles and such need to be designed
in Auggie to match your machine. This forces you to at least understand how spindles
and such operate. As of today's update , there are now 3 spindle types in Auggie, and any user
can add more. Lets take a look at how they work.. I'm sure more commands will be needed
shortly, but rudimentary spindle operations are now working.

If you look inside the GCode library script, you'll now see the function called on M3
SetSpindleState(state) is now changed to this..

//Set Spindle State.
global SetSpindleState = function( state )
{
    //1 = CW, 2 = CCW, 0 = off
    print( "Setting Spindle with " + state);
    switch( state )
    {
        case 1: { SpindleOn(); }
        case 2: { return; } //no ccw spindle on my system
        case 0: { SpindleOff(); }
    };

};

  An M3 or M4 or M5 will call this function to allow whatever
needs to be done, to be done. This library function simply calls
for SpindleOn() or SpindleOff(), I have no need of CCW, so I
havent yet implemented such a call, but if one did, this is
where youd modify the system GCode library to call
SpindleReverse() (or similar), in case:2 above.

  Now the GCode library is assuming such a function
"SpindleOn()" exists. And in fact if you check the library
again, you'll find 3 such calls. All named the same but in
different libraries. This is a method of "overriding" or
virtualizing spindles or other libraries. 

Three new libraries are now included, both as examples,
and as functional spindle controls. They are

SpindleLib-Frequency, SpindleLib-Relay, and SpindleLib-Laser.

  The idea here, is that you simply check the library you wish and leave
the others unchecked. When you see libraries with the same prefix
name, it means they are one-of libraries, ( unless your very advanced
and understand script overwrite behavior). In this case, each of the libraries
has the same function names, so whichever is checked is the active
spindle control.

  In the case of the SpindleLib-Frequency, for example, the function for
SpindleOn() looks like this..

global SpindleOn = function()
{
    FreeSetSpeed( MySpindleAxis, GlobalGet("SpindleSpeed")); //turn on spindle
    print("Frequency Spindle was turned on");
    print("Set to Frequency " + GlobalGet("SpindleSpeed"));
};

  It sets a freeaxis ( selected by the designer) to a set speed from the engine.

The variables above are declared global simply by checking the library as on.
They appear at the top of the library..

//my frequency spindle will use axis 8 step output
global MySpindleAxis = 8;
//axis 8 will be set to constant speed mode
FreeSetAxisMode(MySpindleAxis,1); //set spindle to speed mode

So if one wanted axis#8 step output to drive a spindle, its all set, if one
wanted a different axis, you would modify the library for your numbers,
or, if you wanted to be fancy, you'd write your own library as

SpindleLib-MySpindle and fill its scripts with functions to allow selection
of the axis, or positional setting if its an index-able spindle, etc. 
  Your library would simply be another type of spindle one can select
as the one to use for your system.

So while the scripts above control a frequency spindle.. The SpindleLin-Relay
has the same function name..

global SpindleOn = function()
{
    SpindleDevice.SetOC( MySpindleOutput, 1); //turn on spindle
    print("Relay Spindle was turned on with OC#" + MySpindleOutput);
};

  But in its case, it sets the OC output of the CNC57 board to on.
Just a simple relay on/off control without speed control. As these libraries
share the same names of functions, and the main GCode library calls those
names, whatever library you select will catch the call. If you select more than
one the last one loaded will get the call. To use a different output pin or relay,
youd just edit this libraries globals.

  Auggie's libraries provide the support of objects like spindles and such, its all
a matter of getting all the calls we need. So , when you find your wondering
how to get a piece of data you need, ask.. if its not available , Ill find a way
to get it..

Have fun,
Art








DanL
Old Timer
Posts: 362
Joined: Wed Sep 10, 2014 1:35 pm

Re: Adding a Spindle to Auggie

Post by DanL »

thanks art you saved me some work.
Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests