Hello Guest it is December 13, 2019, 04:06:07 PM

Author Topic: Buttons and the script/gcode  (Read 513 times)

0 Members and 1 Guest are viewing this topic.

Buttons and the script/gcode
« on: February 11, 2019, 01:42:17 PM »
Hello all,
i'm new to mach4(fourth day) and looking to make a button that will make Z go to 0.2 and then
X and Y go to 0. that's it. i tried gcode but it doesn't like dat. and i'm even newer to script.
any help or point in direction would be greatly appreciated.
THANKS



Mach4hobby
win 10
64g
3.4g processor
24 ram
Kenneth

Offline MN300

*
  •  107 107
    • View Profile
Re: Buttons and the script/gcode
« Reply #1 on: February 11, 2019, 03:26:23 PM »
You need to use Lua script. In this example the first move is absolute, the second is incremental. The \n starts a new line so the G code blocks are processed separately.

--Spindle Offset
local inst = mc.mcGetInstance()
mc.mcCntlMdiExecute(inst, "G90 G00 Z0.1 \n G91 G00 X1.5 Y.8")
Re: Buttons and the script/gcode
« Reply #2 on: February 12, 2019, 07:40:53 AM »
THANKS MN300, that's actually what i need. now i need to look up Lua.
Thanks again !
Kenneth
Re: Buttons and the script/gcode
« Reply #3 on: February 12, 2019, 08:27:45 AM »
i downloaded LUA and can't even install it. looks like a Linux program.
Linux and i don't get alone :)
Thanks anyway MN300


p.s. the sample script you gave, i was able to work as i wanted. THANKS
Kenneth

Offline MN300

*
  •  107 107
    • View Profile
Re: Buttons and the script/gcode
« Reply #4 on: February 12, 2019, 08:49:57 AM »
The LUA complier is part of Mach4, you don't need to download anything else to make LUA work.
One of the choices in the help menu is Documentation Folder. There, among much other useful info, you will find a list of the Mach4 functions like mc.mcCntlMdiExecute.
Re: Buttons and the script/gcode
« Reply #5 on: February 12, 2019, 08:51:32 AM »
ok Thanks MN300.
need to start digging.
Kenneth
Re: Buttons and the script/gcode
« Reply #6 on: February 12, 2019, 09:32:00 AM »
i read thru most of the documents and looking for something to tell me how to write
script from scratch as i have NO idea what your snippet means except the xyz movements.
for instance, i know that the -- means a comment. the rest of that is martian to me.
i need a list of commands like what does "mc.mcGetInstance() mean or do :)
again thanks for any help i can get !!!!





--Spindle Offset
local inst = mc.mcGetInstance()
mc.mcCntlMdiExecute(inst, "G90 G00 Z0.1 \n G91 G00 X1.5 Y.8")
Kenneth

Offline MN300

*
  •  107 107
    • View Profile
Re: Buttons and the script/gcode
« Reply #7 on: February 12, 2019, 11:48:07 AM »
list of commands (API's)
YourDriveLetter:\Mach4Hobby\Docs\Mach4CoreAPI.chm
Re: Buttons and the script/gcode
« Reply #8 on: February 12, 2019, 11:55:03 AM »
in this script below. i know the first is a comment.
does it need the second line at all to work ?
is the second line a declaration that is not used ?


--Spindle Offset
local inst = mc.mcGetInstance()
mc.mcCntlMdiExecute(inst, "G90 G00 Z0.1 \n G91 G00 X1.5 Y.8")


Thank you MN300.
that gets me started.
Kenneth
« Last Edit: February 12, 2019, 12:00:06 PM by Kenneth »
Kenneth

Offline MN300

*
  •  107 107
    • View Profile
Re: Buttons and the script/gcode
« Reply #9 on: February 12, 2019, 01:11:41 PM »
In programming, an instance is one occurrence of a class or object. Does that help? Probably not. Scan the links to get an idea of these terms can mean.
https://www.computerhope.com/jargon/i/instance.htm
https://en.wikipedia.org/wiki/Object_(computer_science)

Google "programming instance" to be overwhelmed with similar links.

It's enough to know that you need to determine what the instance of the current environment is and to use it with API calls.