Hello Guest it is April 26, 2024, 07:36:18 AM

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 - DazTheGas

341
Mach4 Videos / Re: Creating a function for the Screen Load Script
« on: December 14, 2016, 12:34:06 PM »
You could achieve this from the Enable button itself using a dialog box.

On pressing enable can give you a dialog box with ok and cancel buttons, warning that pressing ok will home the machine and set softlimits and pressing cancel will leave machine disabled. A simple variable can be set withing the button to check if the machine is homed or not.

DazTheGas

342
Mach4 Videos / Re: Creating a function for the Screen Load Script
« on: December 14, 2016, 10:58:49 AM »
Quote
no machining should be done before referencing all axes.

Well I have to admit, the fact that I know I have proximity switches kind of makes me lazy and dont always home the machine as small parts I just zero the axis. This being said it is good practice to home the machine.

I like Chaoticone`s idea of using the ref home btn as this would benefit those who use softlimits whether it be just for max limit - min limit - or home in place even, this combined with the ref home button flashing in red if any defined axis is not homed.

DazTheGas

343
Mach4 General Discussion / Re: mcCntlGetGcodeFileName ...Crashes M4
« on: December 14, 2016, 08:40:57 AM »
Perhaps post all the code or zip n PM if its sensative or even better use the package profile in the help menu then I might be able to get a better picture of what you are trying to do. I have looked at autoleveller and have a rough gist of what you are trying to do.

Correct me if I am wrong ;-)

Now autoleveller outputs a gcode file, this file has been created from a gcode that you loaded into it, it then inserts some probe routines at the begining of this gcode file then saves it.
The idea is to then load in "mach3" (as it doesnt say its compatible with 4) and it will do the probing and use the params for Z height during the gcode.

How am I doing so far??

DazTheGas

344
Mach4 Videos / Re: Creating a function for the Screen Load Script
« on: December 14, 2016, 07:45:16 AM »
Thats a good point, prob could do with another if statement in the function like mcAxisIsHomed.

DazTheGas

345
Mach4 General Discussion / Re: mcCntlGetGcodeFileName ...Crashes M4
« on: December 14, 2016, 06:00:35 AM »
Firstly take a look at your m code function M41, it is normal practice for all m codes to be declared in lower case as lua is case sensitive and it sets the norm,

After declaring your m function you have also tried to declare "function OpenRPF(inst)" inside of it, all functions must be declared on top level, if you open up the m code in the editor you will see the error of "'end' expected (to close 'function' at line 1) " but saying that I cant see the function being called from anywhere in the script so perhaps just delete that line so the m code becomes the function. There is also a function called "function OpenGcode(inst)" thats not called in anyway and lots of "return error" thats not being returned to anything?

consider an approach something like this

Code: [Select]
hreg, rc = mc.mcRegGetHandle(inst,"iRegs0/ALfile")
if rc ~= 0 then
    wx.wxMessageBox("register ALfile not found...Abort") -- could add the returned rc code here too
    return -- nothing to return just quit (this is only quitting the m code you might need to Stop the gcode??)
else
    --everything was fine so lets get value from Reg
    local pathRPF = mc.mcRegGetValueString(hreg)
    if pathRPF == "" then
        wx.wxMessageBox("register ALfile empty...Abort")
        return
    end
end

-- so now you if you get here do something with the reg value.


Cant test any further than that as dont know whats contained in "mc.mcRegGetHandle(inst,"iRegs0/ALfile")" I can only assume its a file path?

DazTheGas

347
Mach4 Videos / Creating a function for the Screen Load Script
« on: December 13, 2016, 03:54:53 PM »
Ever wanted a function to run in the PLC but not sure how to do it well try this way.

Click Here For Video




Code: [Select]
local inst = mc.mcGetInstance()

mc.MC_ALL = 20

function SetSoftLimits(axis, state)
    local m_axis = 0
if axis == mc.MC_ALL then
repeat
enabled = mc.mcAxisIsEnabled(inst, m_axis)
if enabled == 1 then
mc.mcSoftLimitSetState(inst, m_axis, state)
end
m_axis = m_axis + 1
        until(m_axis == 6)
    else
        mc.mcSoftLimitSetState(inst, axis, state)
    end
end

SetSoftLimits(mc.MC_ALL, mc.MC_ON)

DazTheGas

348
Video completed just uploading ;-)

DazTheGas

349
Mach4 General Discussion / Re: mcCntlGetGcodeFileName ...Crashes M4
« on: December 13, 2016, 05:32:29 AM »
Something like this should work

Code: [Select]
local inst = mc.mcGetInstance()

local GCode = mc.mcCntlGetGcodeFileName(inst)

if GCode == "" then
    wx.wxMessageBox("No Code Loaded")
else
    wx.wxMessageBox(GCode.." GCode Loaded")
end

DazTheGas

350
Mach4 General Discussion / Re: mcCntlGetGcodeFileName ...Crashes M4
« on: December 13, 2016, 05:21:43 AM »
Your not in a function so where are you returning the error too??

DazTheGas