Hello Guest it is March 28, 2024, 02:29:28 PM

Author Topic: Creating a function for the Screen Load Script  (Read 11617 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

*
  •  778 778
  • 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
New For 2022 - Instagram: dazthegas
Re: Creating a function for the Screen Load Script
« Reply #12 on: December 14, 2016, 02:26:19 PM »
Perfect, thanks!

Offline Chaoticone

*
  • *
  •  5,624 5,624
  • 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

*
  •  778 778
  • 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
New For 2022 - Instagram: dazthegas
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

*
  •  778 778
  • 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
New For 2022 - Instagram: dazthegas

Offline Azalin

*
  •  181 181
    • View Profile
Re: Creating a function for the Screen Load Script
« Reply #17 on: February 13, 2022, 12:38:40 PM »
Thanks everyone.

Offline Rimmel

*
  •  207 207
    • View Profile
Re: Creating a function for the Screen Load Script
« Reply #18 on: June 05, 2022, 01:25:15 PM »
An interesting one this, as I was looking to do the same thing. So I looked at DaztheGaz's video... Great!

However something struck me, in this instance there is already a button on the screen that does exactly the same thing (marked on the image attached). The screenshot was taken directly from the video.

Why cannot the functionality that is already provided, be tapped into  - rather than reinventing thwe wheel (so to speak).

Genuine question.

Thanks