Hello Guest it is March 28, 2024, 03:37:43 PM

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - thespindoctor

Pages: « 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 »
151
Mach4 General Discussion / Re: Simple Lua question
« on: March 30, 2017, 09:59:51 PM »
Still getting the error that the call for mc.mcCntlGCodeExecuteWait which is nil
The Inst is not nil  Very confusing.

Not understanding all the issues with your post Re: Mach4/Lua script do's and Dont's

Do I have to define the function for  mc.mcCntlGCodeExecuteWait as I did in the screen load script?  Below is the script I copied from an example

function GCodeExecute(GCodeString)
   local rc = mc.mcCntlGCodeExecuteWait(inst, GCodeString) --This is the standard function call for executing gcode. it waits for motor feedback before continuing in the file.
   if rc ~= mc.MERROR_NOERROR then return "GCode failed", false end
end


I have a long way to go to...

152
Mach4 General Discussion / Re: Simple Lua question
« on: March 30, 2017, 04:07:32 PM »
Rhtuttle,

The error is saying that mcCntlGCodeExecuteWait is nil  The prb.SingleSurfy line is working great.

I am not able to figure out how to program Gcode moves from Lua.  I was doing it easily in basic with Mach3.   Lua is so much more difficult.

It would be great for someone to come up with a tutorial for 'Lua for Mach4'.

Thanks!

153
Mach4 General Discussion / Re: Simple Lua question
« on: March 30, 2017, 01:32:23 PM »
I put the code in the load script for the function but that did not help.

Here is the clicked script for the button


--Single Surface Measure Y button
--PRIVATE
--from Y probe button

inst = mc.mcGetInstance()
local profile = mc.mcProfileGetName(inst)
local path = mc.mcCntlGetMachDir(inst)

package.path = path .. "\\Modules\\?.lua;" .. path .. "\\Profiles\\" .. profile .. "\\Modules\\?.lua;"

--Master module
package.loaded.MasterModule = nil
mm = require "mcMasterModule"

--Probing module
package.loaded.Probing = nil
local prb = require "mcProbing"

local ypos = scr.GetProperty("droSurfYPos", "Value")
--local work = scr.GetProperty("ledSetWork", "Value")  removed by kfc  below line added to stop fixture setup
local work = nil

prb.SingleSurfY(ypos, work)
rc = mc.mcCntlGCodeExecuteWait(inst, "G0 X-5.0") --This is the standard function call for executing gcode. it waits for motor feedback before continuing in the file.
mm.ReturnCode(rc)

prb.SingleSurfY(ypos, work)


Now it probes one time then gets to the gcode line and says an error occurred with a nil value

Not sure how to make progress here.

154
Mach4 General Discussion / Simple Lua question
« on: March 29, 2017, 09:57:48 PM »
Trying to learn Lua.  Simple try by cutting and pasting does not work.  I took the script from the Single Surface Y button on the probing screen which works fine when copied to another button.  Then I would like to move x and run the single surface y again.  So the last lines are below


prb.SingleSurfY(ypos, work)
Local rc=mc.mcCntlGcodeExecuteWait(Inst,"G0 X-5.0")
mm.ReturnCode(rc)
prb.SingleSurfY(ypos, work)


It probes twice very nicely but skips the G0 move.  Why?

Thanks

155
Mach4 General Discussion / Re: Designing a tool changer for a Mill
« on: December 22, 2016, 09:44:12 AM »
Thanks Russ!

Keith

156
Mach4 General Discussion / Re: Understanding Lua
« on: December 20, 2016, 03:02:35 PM »
Those were my mistakes and happened because I did not have the file naming conventions correct.  I think it is correct now.  The way Daz posted it was easier for me to see where to save each file type and how to name each file.  I will proof it again tonight after the first day
of skiing Copper Mountain now.  Not sure why Daz had trouble in a G code file.

Keith

157
Mach4 General Discussion / Re: Understanding Lua
« on: December 20, 2016, 08:56:53 AM »
I think your original code was successful except for the filename change to load_modules.mcs from load.modules.mcs

Daz suggestions changed the message method and

C:\Mach4Hobby\Modules\mcUserScript.mcs should be
C:\Mach4Hobby\Modules\mcUserScript.lua

Changes from Daz quote made below

This is where I have placed files

C:\Mach4Hobby\Modules\mcUserScript.lua

Code: [Select]
local mcUserScript = {}

function mcUserScript.UserMessage(Message)
if (Message == nil) then --No message was passed
Message = "No message passed" --If no message is passed this will be the default message
end
--wx.wxMessageBox(Message)
mc.mcCntlSetLastError(inst,Message)
end

return mcUserScript -- Module End

both the m110.mcs and load_modules.mcs goes in your profiles own macro directory

load_modules.mcs

Code: [Select]
local inst = mc.mcGetInstance()
local profile = mc.mcProfileGetName(inst)
local path = mc.mcCntlGetMachDir(inst)
    
package.path = path .. "\\Profiles\\" .. profile .. "\\Modules\\?.lua;" .. path .. "\\Modules\\?.lua;"

package.loaded.mcUserScript = nil
us = require "mcUserScript"

m110.mcs

Code: [Select]
function m110()

us.UserMessage("This is my message from m110")
  
  end

if (mc.mcInEditor() == 1) then
 m110()
end

DazTheGas

[/quote]

158
Mach4 General Discussion / Re: Understanding Lua
« on: December 20, 2016, 08:45:04 AM »
Next post is correct I believe

159
Mach4 General Discussion / Re: Understanding Lua
« on: December 19, 2016, 08:48:37 PM »
Works fine in all instances button script, g code, mfunction, even with wx.wxMessageBox(Message)

Keith

160
Mach4 General Discussion / Re: Understanding Lua
« on: December 19, 2016, 08:05:47 PM »
Gcode FILE  with

G0 X0Y0
M110
G0 X1Y0

works fine



Pages: « 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 »