Hello Guest it is September 17, 2021, 02:47:10 AM

Author Topic: External button scripts in Mach4  (Read 175 times)

0 Members and 1 Guest are viewing this topic.

External button scripts in Mach4
« on: September 09, 2021, 04:52:57 AM »
Hi

I am retrofitting 16A20 lathe and using Mach 4 with CSMIO IP-S controller. I built operation panel with push buttons but don´t know how to script the programm.
For START, FEEDHOLD and STOP I´ve got it worked, but need also script for SET Z OFFSET, SET X OFFSET, REF ALL, REF Z, REF X, MDI tab, GCode tab, Fixture Offset, Turn Cycles, Spindle CW, Spindle CWW etc.

Can anyone give some advice or tutorial?

Thanks in advance,
Henri
Re: External button scripts in Mach4
« Reply #1 on: September 09, 2021, 05:18:30 PM »
Hi,
all of those features are already included in Mach4. If you go into 'Screen Edit' mode and click on each feature
you will be able to see how NFS coded each.....all you require is to duplicate that for each feature in the SigLib table,
one entry in the table per external button.

Craig
My wife left with my best friend...
     and I miss him!
Re: External button scripts in Mach4
« Reply #2 on: September 13, 2021, 03:45:47 AM »
Hi,
all of those features are already included in Mach4. If you go into 'Screen Edit' mode and click on each feature
you will be able to see how NFS coded each.....all you require is to duplicate that for each feature in the SigLib table,
one entry in the table per external button.

Craig

Thank you, Craig!
I tried to script the REF ALL, but it is giving LUA error. Do you have any examples how do you have it done?

Henri
Re: External button scripts in Mach4
« Reply #3 on: September 13, 2021, 04:23:18 AM »
Hi,
I haven't had any problem with <RefAll>.

What you need to do is assign an input signal, say ISIG_INPUT10 to your external button via your controller.
In the SigLib table whenever that input goes high have it call the existing <RefAll> script, you are just using an external
button to trigger an existing Mach4 function.

Post the error message. You may have noted that the standard <RefAll> script homes all four axes....but if you only have three then
it will fault. You need to go to the RefAll script in the ScreenLoad script and edit the fourth  axis out of the sequence.

Craig
My wife left with my best friend...
     and I miss him!
Re: External button scripts in Mach4
« Reply #4 on: September 14, 2021, 03:02:04 AM »
Hi,
I haven't had any problem with <RefAll>.

What you need to do is assign an input signal, say ISIG_INPUT10 to your external button via your controller.
In the SigLib table whenever that input goes high have it call the existing <RefAll> script, you are just using an external
button to trigger an existing Mach4 function.

Post the error message. You may have noted that the standard <RefAll> script homes all four axes....but if you only have three then
it will fault. You need to go to the RefAll script in the ScreenLoad script and edit the fourth  axis out of the sequence.

Craig

Hi

It gives following Lua error: error while running chunk. Have no idea how to repair it.
I added some pics about the Signal Library and the error.

henri
Re: External button scripts in Mach4
« Reply #5 on: September 14, 2021, 03:20:27 AM »
Hi,
that's what the stack dump is for.

Open your Screenscript.lua and look at line locations 242, 84 and 620. There or there abouts is the error or errors. Note that the Screenscrpit.lua
IS NOT editable, it is the compiled chunk that includes ALL the Lua chunks and macros. You have to go back the the source script to edit it,
thereafter a new Screenscript.lua will be compiled and include the changes you have made.

Craig
My wife left with my best friend...
     and I miss him!

Offline DazTheGas

*
  •  761 761
  • DazTheGas
    • View Profile
Re: External button scripts in Mach4
« Reply #6 on: September 14, 2021, 07:51:53 AM »
If you are just wanting the external button to do what the screen button does then all you need to do is add the script from the screen button to the siglib IE:

Code: [Select]
[mc.ISIG_INPUT5] = function (state)
if (state == 1) then   
wait = coroutine.create (RefAllHome)
    end

end,

But remember you must add some more code to check that the controller is in a state that will allow you to home too

DazTheGas
Theres always time for a choccy biccy
Re: External button scripts in Mach4
« Reply #7 on: September 15, 2021, 04:13:20 AM »
Thank you for advice. ""RefAllHome" works!
Have you anybody an idea how to script SET X and Z OFFSET? Is it right to copy all the script from SETTOOLXOFFSET (Clicked script) to Signal Library or is there any shortcut for that?
And also how to script tabs (between GCode and MDI)?

henri