Hello Guest it is April 18, 2024, 07:59:20 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 - DazTheGas

361
Mach4 Plugins / Re: Pokeys Mach4 plugin LUA reference for LCD
« on: December 07, 2016, 02:57:02 AM »
Chaotione is right, lose the Number it should be just hReg, and also moving to havin a function in the screen load script would be much cleaner, it could be called from the dro update with (axis,lcd) and also set to run on 1st loop of the plc.

DazTheGas

362
Mach4 General Discussion / Re: Restart required to edit scripts
« on: December 05, 2016, 08:50:06 AM »
Quote
Seems to me that there are two problems, the first is that depending on the sequence of events the USB pendant interferes with
the ESS establishing comms, a hardware conflict issue.

As you would of gathered by now Mach4 is quite reliant on lua, this is used within the gui and in macros etc.. we all have a tinker and tweek the scripts to our liking but we also dont always see some of the problems with a tiny bit of code thats just not quite right. In light of this it can sometimes crash parts of mach4 that we are not aware of, this can lead to parts not working like they should or an incomplete shutdown cycle.
I know from experience that unless mach4 shuts down gracefully it will not find the ESS until a power cycle is done, this is because the ESS still thinks its connected.

Sorry not a remedy but just some things to consider like check the m40/41 codes are working and they are not causing the fault, or disable the pendant plugin to eliminate the conflict between them.

DazTheGas

363
Mach4 General Discussion / Re: Mini ITX Motherboard for Mach4
« on: December 05, 2016, 04:44:57 AM »
If you have a router at home for your broadband then perhaps plug it in there and disable the wireles, if your ethernet port is working then you will be able to get the cheeky miss google or something, if its not working then check what protocals you have installed.

DazTheGas

364
Mach4 General Discussion / Re: Copy DRO to external display
« on: December 05, 2016, 04:39:18 AM »
I you go into the screen editor and highlight the dro you want to copy then highlight the events tab you will find a script section with onUpdate script.

Something like this should be ok.

Code: [Select]
local inst = mc.mcGetInstance()
local Xcoords = scr.GetProperty("droCurrentX","Value")
local hreg = mc.mcRegGetHandle(inst, string.format("Sim0/test0")) -- this line will need changing to the register you want to update IE "PoKeys_32062/LCD Line1"
mc.mcRegSetValueString(hreg, tostring(Xcoords))

DazTheGas

365
Mach4 Plugins / Re: mcX360 Plugin for Lua
« on: December 04, 2016, 06:04:53 PM »
The return code from the controller (32670) is divided by 330 to give 99, I based this on velocity etc being set by percentage which I believe is the best approach, totally agree with NOT having 2 controllers ;-)

So just a few pointers to help you on your quest, I have downloaded and tested your script but unfortunately it kills any other form of jogging in mach4 - IE jog buttons and even the shuttle. You could do with setting some more  'if' statements.

You dont have to run everything in 1 timer, windows is an event driven os so use what is required.

There are many ways of retrieving a registry try

return mc.mcRegGetValueLong(hreg) instead of converting strings with tostring

Heres a few snippets from my script.


Code: [Select]
local mInst = 0

-- Enable
Xenabled = 0
JogRate = 0
Enable_Panel = wx.wxPanel( wx.NULL, wx.wxID_ANY, wx.wxDefaultPosition, wx.wxDefaultSize)
Enable_Timer = wx.wxTimer(Enable_Panel)
-- Velocity
Vel_Panel = wx.wxPanel( wx.NULL, wx.wxID_ANY, wx.wxDefaultPosition, wx.wxDefaultSize)
Vel_Timer = wx.wxTimer(Vel_Panel)
-- DPad
DPad_Panel = wx.wxPanel( wx.NULL, wx.wxID_ANY, wx.wxDefaultPosition, wx.wxDefaultSize)
DPad_Timer = wx.wxTimer(DPad_Panel)

As you can see its possible to run many timers, these are a few and the only timer that is running const is the enable timer which is looking/waiting for the left trigger, on the left trigger value being over 150 it starts all the other timers and on release stops them.

Code: [Select]
Enable_Panel:Connect(wx.wxEVT_TIMER, function (event)
if GetXin("LTR_Val") > 150 and Xenabled == 0 then
JogRate = mc.mcJogGetRate(mInst, mc.X_AXIS)
EStop_Timer:Start(50)
DPad_Timer:Start(100)
Vel_Timer:Start(100)
LTH_Timer:Start(100)
RTH_Timer:Start(100)
BTN_Timer:Start(100)
Xenabled = 1
elseif GetXin("LTR_Val") < 50 and Xenabled == 1 then
DPad_Timer:Stop()
Vel_Timer:Stop()
EStop_Timer:Stop()
LTH_Timer:Stop
RTH_Timer:Stop()
BTN_Timer:Stop()
Xenabled = 0
mc.mcJogSetRate(mInst, mc.X_AXIS, JogRate)
mc.mcJogSetRate(mInst, mc.Y_AXIS, JogRate)
mc.mcJogSetRate(mInst, mc.Z_AXIS, JogRate)
end
end)
   
As you can see after releasing the left trigger my jograte is returned to what it was before and throughout the script is lots and lots of if and more if`s with the main goal of keeping overheads towards the gui at a minimum when the controller is not in use.

Must be time for a choccy biccy now ;-)

DazTheGas

366
Mach4 Plugins / Re: mcX360 Plugin for Lua
« on: November 29, 2016, 03:06:37 AM »
Quote
When running the Log Facillity i noticed the script hammers Velocity Stop so i fixed that...

It takes a lot more code but makes a lot of sense to reframe from too many "else" statements, i tend to use "elseif" and give it something to check against, another thing I need to mention is it is an error to quit without stopping the timer, in your screen unload script you need to be placing a timer:Stop() command for the panel

DazTheGas

367
Mach4 Plugins / Re: mcX360 Plugin for Lua
« on: November 27, 2016, 06:26:19 PM »
By using the mcSignalSetState on the axis it gives me the advantage of using the same routine whether I am in cont or inc mode, by using mcJogVelocityStart you will have to write another routine for mcJogIncStart.

DazTHeGas

368
Keep your homing the same I thought you had mill..

DazTheGas

369
The first thing you need to do at this stage is update to a newer screen, at present you are using the old wxMach screen.

Load up mach4 and click on view in the menubar, from there load a new screen and select wx4 - dont worry this will not change anything in your config but will give you a better starting point.

As a quick look in the ESS config I would remove the index pins from both Inputs tab and Homing.

As a quick look in the Mach config your homing is setup to home in the order of Y X then Z?? is this correct for you machine as Z normally wants to go safe before any other movement, personally mine is set for Z then both X and Y together.

Hope this get you on track

DazTheGas

370
Mach4 Plugins / Re: mcX360 Plugin for Lua
« on: November 27, 2016, 04:46:11 PM »
Here`s a little snippet of what I use for buttons as remember if you turn on a button you also need to turn it off, that might help you on the way ;-)

Code: [Select]
local XPState = false
local XNState = false
local YPState = false
local YNState = false

    function GetXin(xinput)
    local hreg = mc.mcRegGetHandle(inst, string.format("mcX360_LUA/%s", xinput))
    return mc.mcRegGetValueString(hreg)
    end


    X360_Panel:Connect(wx.wxEVT_TIMER, function (event)

-- Y++
if GetXin("DPad_UP") == "1" and YPState == false then
mc.mcSignalSetState (mc.mcSignalGetHandle (inst, mc.ISIG_JOGYP), 1)
YPState = true
end
if GetXin("DPad_UP") == "0" and YPState == true then
mc.mcSignalSetState (mc.mcSignalGetHandle (inst, mc.ISIG_JOGYP), 0)
YPState = false
end

-- Y--
if GetXin("DPad_DOWN") == "1" and YNState == false then
mc.mcSignalSetState (mc.mcSignalGetHandle (inst, mc.ISIG_JOGYN), 1)
YNState = true
end
if GetXin("DPad_DOWN") == "0" and YNState == true then
mc.mcSignalSetState (mc.mcSignalGetHandle (inst, mc.ISIG_JOGYN), 0)
YNState = false
end

-- X++
if GetXin("DPad_RIGHT") == "1" and XPState == false then
mc.mcSignalSetState (mc.mcSignalGetHandle (inst, mc.ISIG_JOGXP), 1)
XPState = true
end
if GetXin("DPad_RIGHT") == "0" and XPState == true then
mc.mcSignalSetState (mc.mcSignalGetHandle (inst, mc.ISIG_JOGXP), 0)
XPState = false
end

-- X--
if GetXin("DPad_LEFT") == "1" and XNState == false then
mc.mcSignalSetState (mc.mcSignalGetHandle (inst, mc.ISIG_JOGXN), 1)
XNState = true
end
if GetXin("DPad_LEFT") == "0" and XNState == true then
mc.mcSignalSetState (mc.mcSignalGetHandle (inst, mc.ISIG_JOGXN), 0)
XNState = false
end

end)

DazTheGas