Script/GCode interface

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

Script/GCode interface

Post by ArtF »

  How was Lunch? :)

Well, before we get to involved in the operations of the scripts, we should probably have a
clear understanding of what , exactly, the scripts are meant to do. Broadly, the answer is
everything, but the object is to hide that from the end user. Other than the GCode subsets
of script the user may wish to learn, the running of the program, though pretty much
all script, should be pretty much opaque.

    Recently, as I explained in the YouTube video, I added the GCode library, this allows
you to add GCode or M Codes to the language of the input file. Natively, Auggie knows
very few M Codes, and not all the G Codes. Ive instantiated as a system only the basic
ones. However, any G code or M Code not understood triggers a script call to a
function named GCodexx where the xx is the number you called in the GCode..
so a
G162 in the GCode file, will call :  GCode162  as script function name.

  Now if no such script exist, a message is printed on the toolpath and a log entry
is made. The file will run regardless as you may have turned off that GCode to
stop a behavior you don't want. This allows you to check a library to turn it on or off
and turn on or off or swap the meaning of a G code or M Code. It is quite
possible to have G code libraries named for a particular machine type, and select the
one that matches the device.

  The commands you add to or use from the G code libraries are not the only ones
available to the running program, basically any legal script call or function
can be put in the G code file , so long as it is between { }'s

for example , as of next update anyway, the following would be quite legal..
...
G1X100Y5Z5
{Notify("ToolChange will be coming up in about 3 minutes.");}
G1Z-.1
...
...
{Warn("ToolChange will be coming up in about 1 minutes.");}
G1X4
..
{Alert("ToolChange in a few seconds.");}


    Notify just puts text in the tool path screen, Warn and Alert do as well,
but also add a sound of urgency from the sound system. These commands
all show up in the auto type mechanism so their not hard to remember.

  The idea here is to add enough GCode and MCode scripts to allow generic GCode to
run, and to allow embellishment of the code to make it do things  that Auggie will have
the power to do. So most scripts a user writes will add a capability or simply be calls
of scripts pre-written and already in the libraries to add to the GCode.

    There is a Contours facility which will appear as a library shortly as well, which allows a user
to add points to an unlimited amount of profiles, and save them as dxf's, or use them as toolpath
lines, much like a G2 or G3, but beziers , defined shapes and such will also be possible.
  Methods like this will allow for things like constant burning of ever changing serial numbers
and such.

  The system now sends signals on any used signal that changes in either pokeys, so you
may now block on any of over 110 signal names. To have a script service a pin on the Pokeys,
just make sure its enabled. You may now have a script such as

global ServiceIOPin15 = function()
{
  while(1)
    {
      block("IOPin15");
      //do what you wish to happen
      // on pin15 change here.
    }
}

  And start the process in the main screen init script with

thread( ServiceIOPin15 );

this will send the  ServiceIOPin15 script off running on its own,
waking up only when pin15 on the IO Pokeys changes state..
What you do of course ifs up to you. This works for Analogue,
Digital (in and out) Encoders and counters.

  This means you have pretty much full control of over
100 pins of IO mixed in various ways.

  Enough for now, I thought Id try to clarify a bit what the flow of the system is
designed to be.

Thx
Art



   






   

Vangoth
Old Timer
Posts: 8
Joined: Fri Mar 16, 2018 2:49 am

Re: Script/GCode interface

Post by Vangoth »

Good night, a question my auggie does not activate the spindle with the M3 code. Should I add it?
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4586
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: Script/GCode interface

Post by ArtF »

Hi:

  Have you turned on the spindle libraries? The default one turns on a laser, so you may want to change that so it only turns on a relay. The GCode library calls
the SetSpindleState macro, you will find the laser example of that macro that may be modified.

Art
Vangoth
Old Timer
Posts: 8
Joined: Fri Mar 16, 2018 2:49 am

Re: Script/GCode interface

Post by Vangoth »

yes sir, I have it activated but when I load the code g and start doing the movement, it locks up when it finds the M3 code. and create a new script only with the option to turn on and off plasma with relay # 3 and it does not work either. Here I leave you the scrip that you wrote and the error that appears when the machine finds the M3

global SpindleOn = function ()
{
Pokeys1.SetRelay (3,1);
print ("Plasma Spindle RT Engaged");
 
};
 
global SpindleOff = function ()
{
Pokeys1.SetRelay (3,0);
print ("Plasma Spindle RT dis-engaged");
 
};


Attachments
error m3.jpg
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4586
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: Script/GCode interface

Post by ArtF »

Hi:

  The messages seem to show the script being called, can you press the log button at that point and send me a copy of the log? Does an ESTOP happen when you do this or does the spindle just not come on?

Art
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4586
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: Script/GCode interface

Post by ArtF »

Hi:

One other test to make, in your SCRIPT tab, enter the following..

Pokeys1.SetRelay(3,1);

and press RUN on thge screen. Does the relay turn on? You should hear it
click on the board. Try

Pokeys1.SetRelay (3,0);

and again press RUN, doe the relay turn off?

Art
Vangoth
Old Timer
Posts: 8
Joined: Fri Mar 16, 2018 2:49 am

Re: Script/GCode interface

Post by Vangoth »

yes sir I did the test and the relay is turned on with: Pokeys1.SetRelay (3,1); and it shuts down with Pokeys1.SetRelay (3,0); .

When I run the G code when I reach the M3, the program turns on the N (3) relay and the system locks and the error LED on the screen turns on. Annex image of the error.

I appreciate your help.
Attachments
error.jpg
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4586
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: Script/GCode interface

Post by ArtF »

Hi:

It sounds like maybe an error or typo is in the script.
Can you use the LocalEdit button in the lib to load the
Laser-Spindle Script into the script editor and show me
what the SetSpindleState macro looks like now?

  There may be soem error in there.

Thx
Art
Ya-Nvr-No
Old Timer
Posts: 188
Joined: Wed Sep 08, 2010 11:15 am

Re: Script/GCode interface

Post by Ya-Nvr-No »

it looks like the G4 X command is the error
G4 is a pause/dwell command followed by a P time value there are some controllers that use an X just not sure Auggie does

Side Note:
it is a standard practice to have the spindle M call on and S speed on the same line
most industrial controllers will also fault on if a G1 feed move is called before the feed rate is set.
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4586
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: Script/GCode interface

Post by ArtF »

Hi:

As YaNvrNo pointed out  the G04X line is an error.

G04 is a dwell but doesnt use X, remove that line and see if the error goes away..
Thx to "YaNvrNo" for pointing this out.

Thx
Art
Vangoth
Old Timer
Posts: 8
Joined: Fri Mar 16, 2018 2:49 am

Re: Script/GCode interface

Post by Vangoth »

yes sir thank you very much, indeed the error was the code G4. edit it and it works

Does that mean that I must change the postprocessor for one that does not generate a g4?
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4586
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: Script/GCode interface

Post by ArtF »

Hi:

yes, or edit the files afterwards. The G04 is allowed, but it has to be in the form of G04P.5 for example as a .5 second dwell.
Plasma usually uses this to wait for fire..

Art
Vangoth
Old Timer
Posts: 8
Joined: Fri Mar 16, 2018 2:49 am

Re: Script/GCode interface

Post by Vangoth »

yes sir, I am in the task of looking for and testing a postprocessor that will probe in the Z axis before turning on the torch and then turn on the torch with M3 and pause for 1 second depending on the thickness of the metal so that the Fire penetrate the material and start the cut.

MUCHAS GRACIAS POR SU AYUDA
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4586
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: Script/GCode interface

Post by ArtF »

You should probably just hook up a home switch on the Z that homes downwards till the switch hits the material and sets it as home.
You just tell Auggie to home the Z then. That can probably be done with a macro call or a simple macro script. Ill check into the GCode
command for telling an axis to home to switch.. I think I added it but Im not sure..

Art
Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests