Hello Guest it is November 22, 2019, 09:51:37 AM

Author Topic: Creating a function for the Screen Load Script  (Read 5387 times)

0 Members and 1 Guest are viewing this topic.

Re: Creating a function for the Screen Load Script
« Reply #10 on: December 14, 2016, 11:34:52 AM »
So we put in the soft limits code as done by Daz in the load script and first run of Plc but add code to code plc script to disable axes until referenced and a message to pop up requesting ref if anything else is tried including program running, jog, probe etc.  Now to see if I can figure out how to do that...

Keith

Offline DazTheGas

*
  •  750 750
  • DazTheGas
    • View Profile
Re: Creating a function for the Screen Load Script
« Reply #11 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
Theres always time for a choccy biccy
Re: Creating a function for the Screen Load Script
« Reply #12 on: December 14, 2016, 02:26:19 PM »
Perfect, thanks!

Offline Chaoticone

*
  • *
  •  5,630 5,630
  • Precision Chaos
    • View Profile
Re: Creating a function for the Screen Load Script
« Reply #13 on: December 14, 2016, 03:01:08 PM »
You might want to enable "Deref Axes in E-Stop" in general Config. and see if it does about what you want. I don't think it will do all of it but should get you at least part of the way there.
;D If you could see the things I have in my head, you would be laughing too. ;D

My guard dog is not what you need to worry about!

Offline DazTheGas

*
  •  750 750
  • DazTheGas
    • View Profile
Re: Creating a function for the Screen Load Script
« Reply #14 on: December 14, 2016, 05:12:34 PM »
Ok have a little play with something like this

in the events tab for the enable button delete the Down Action and place this in the Down Script

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

function CheckHomeState()
    local en_axis = 0
    repeat
        local Is_Enabled = mc.mcAxisIsEnabled(inst, en_axis)
            if Is_Enabled == 1 then
                local is_Homed = mc.mcAxisIsHomed(inst, en_axis)
                if is_Homed ~= 1 then
                   HomeDialog()
                return  
                end
            end
        en_axis = en_axis + 1
    until( en_axis == 6 )
mc.mcCntlEnable(inst, 1)
end

function HomeDialog()
local h_dialog = wx.wxMessageDialog(wx.NULL,"Clicking Ok will Home all Axis, Cancel will abort", "Warning Machine Not Homed",wx.wxOK + wx.wxCANCEL)
local test = h_dialog:ShowModal()
    if test == wx.wxID_OK then
        mc.mcCntlEnable(inst, 1)
        wait = coroutine.create (RefAllHome)
    else
        scr.SetProperty('tbutton2','Button State','Up')
        return
    end
end

CheckHomeState()

Seems to work ok on my machine :-)

DazTheGas
Theres always time for a choccy biccy
Re: Creating a function for the Screen Load Script
« Reply #15 on: December 14, 2016, 09:04:28 PM »
Thanks Daz, that did the trick and soft limits are on!  Wish I could return the favor but this Lua learning is slow...

Keith

Offline DazTheGas

*
  •  750 750
  • DazTheGas
    • View Profile
Re: Creating a function for the Screen Load Script
« Reply #16 on: December 15, 2016, 04:31:14 AM »
Glad it helped :-)

DazTheGas
Theres always time for a choccy biccy