Hello Guest it is April 18, 2024, 06:44:57 AM

Author Topic: script and mach 4  (Read 5305 times)

0 Members and 1 Guest are viewing this topic.

Offline mark4

*
  •  167 167
    • View Profile
script and mach 4
« on: June 07, 2016, 09:02:22 PM »
i am a machine up-grader and i have a lathe and mill i am making mach 4 the first post will be about the mill. i have an Ethernet smooth stepper i have been setting up limits and motors this has been going well except last night i did something and the ess stopped talking to mach 4 i still don't know what i did but it is working again. question is there a work around for user account control or do i just turn it off. 2 i am starting with two external buttons cycle start and feed hold. so far i go into edit screen then wxmach click on the lightning bolt the scripts come up i have looked them over and determined i haven't the foggiest idea where to start IE should the added button script be in plc script or signal script please point me in the right direction or to where i can find an example i know something about vb not much lua structure is going to be a learning experience thank you for your help
mark

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Re: script and mach 4
« Reply #1 on: June 08, 2016, 03:06:15 AM »
Go for the startup script there is an example in there called sigLib, this is where is best to put your scripts for external buttons

DazTheGas
New For 2022 - Instagram: dazthegas
Re: script and mach 4
« Reply #2 on: June 08, 2016, 02:01:50 PM »
Except... mark4 mentions editing"wxmach" which means he is using the wxMach screen set, not the wx4 screen set.  The two screen sets handle signal scripts differently.  See this post on our forums (step 6, though if you are going to be changing the screen set you really should make a copy of it, as described starting in step 4):
        http://www.pmdx.com/PMDX-Forums/index.php?topic=271.msg1127#msg1127

For wxMach-based screen sets you put the code to handle the button presses in the "Signal Script".  For wx4-based screen sets, you put then in the "Screen Load" script.

The code in the link above does something other than what you want. First, map your two buttons to two of the "Input #x" Mach4 input signals (for example, "Input #0" and "Input #1").   For the wxMach screen set, you want something like this (appended to the bottom/end of the existing script):

Code: [Select]
-- *** THIS CODE IS FOR THE wxMach SCREEN SET, in the "Signal Script" ***
-- Input0 is "cycle start"
-- NOTE: This will NOT run commands from the MDI window.  It will only run GCode files.
if ( sig == mc.ISIG_INPUT0 ) then
    if (state == 1) then
        mc.mcCntlCycleStart(inst);
   end
end

-- Input1 is "feed hold"
if ( sig == mc.ISIG_INPUT1 ) then
    if (state == 1) then
        mc.mcCntlFeedHold(inst);
   end
end
As noted above, this code won't start MDI commands, only GCode files that you have loaded.  If you want to run either MDI or GCode files that gets much more involved if you are using the wxMach screen set.  I would suggest changing to the wx4 screen set, or at least taking a look at the CycleStart() function in the "screen load" script to see what it takes to run either MDI or GCode files.
[edited to correct the "sig ==" test for feed hold]

Offline mark4

*
  •  167 167
    • View Profile
Re: script and mach 4
« Reply #3 on: June 09, 2016, 05:21:16 PM »
thank you for your replies i will program and post the final. i dont know the difference in the mach screen sets i used mxmach and created a new screen set from that. the reason i used that screen set is i am using an ethernet smooth stepper and i cant find it right now but i remember reading use that screen set as the other one has some kind of problem with the ess i will have to look for that. as far as only run gcode files but not in mdi correct me if i am wrong but in mdi you program a line and hit enter and the line is run so you dont really need a cycle start in mdi you only need it to run gcode. also i will check out the forum at pmdx
mark

Offline dude1

*
  •  1,253 1,253
    • View Profile
Re: script and mach 4
« Reply #4 on: June 09, 2016, 09:28:04 PM »
mdi you need cycle start enter does not work that was Mach3

Offline Chaoticone

*
  • *
  •  5,624 5,624
  • Precision Chaos
    • View Profile
Re: script and mach 4
« Reply #5 on: June 09, 2016, 11:22:08 PM »
mdi you need cycle start enter does not work that was Mach3

Yup...... scr.ExecMdi('mdi1')

I would start with wx4 or wx6 I think. The wxMach screen has not been updated in a while and likely never will be again.
;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 mark4

*
  •  167 167
    • View Profile
Re: script and mach 4
« Reply #6 on: June 12, 2016, 06:01:20 PM »
hello
i have been doing research and starting to program so correct me if i am wrong i started with screenset wx4 opened screen load script looks like this
---------------------------------------------------------------
-- Signal Library
---------------------------------------------------------------
SigLib = {
[mc.OSIG_MACHINE_ENABLED] = function (state)
    machEnabled = state;
    scr.SetProperty('btnRefAll', 'Enabled', tostring(state));
    scr.SetProperty('btnRefAll2', 'Enabled', tostring(state));
    scr.SetProperty('btnGotoZero', 'Enabled', tostring(state));
    scr.SetProperty('tabJogging', 'Enabled', tostring(state));
    if (state == 1) then
        AxisEnable();
    end
end,
[mc.ISIG_INPUT0] = function (state)
   
end,
[mc.ISIG_INPUT1] = function (state)
   -- if (state == 1) then   
--        CycleStart()
--    --else
--        --mc.mcCntlFeedHold (0)
--    end

end,

i am modifying it to look like this

---------------------------------------------------------------
-- Signal Library
---------------------------------------------------------------
SigLib = {
[mc.OSIG_MACHINE_ENABLED] = function (state)
    machEnabled = state;
    scr.SetProperty('btnRefAll', 'Enabled', tostring(state));
    scr.SetProperty('btnRefAll2', 'Enabled', tostring(state));
    scr.SetProperty('btnGotoZero', 'Enabled', tostring(state));
    scr.SetProperty('tabJogging', 'Enabled', tostring(state));
    if (state == 1) then
        AxisEnable();
    end
end,
[mc.ISIG_INPUT0] = function (state)
    if (state == 1) then
          FeedHold()
end,
[mc.ISIG_INPUT1] = function (state)
   if (state == 1) then   
        CycleStart()
    else
        mc.mcCntlFeedHold (0) -- i dont know if i need this
   end

end,

so why do we goto feed hold if cycle start is zero or off wouldnt the machine be in feed hold automatically the real question is after this machine i have one with a big controll pannel lots of switches so do i need to end an input with feed hold like under cycle start.
this takes care of regular cycle start. now onto mdi cycle start  Chaoticone wrote this scr.ExecMdi('mdi1') is this stand alone or does it need more where do i put it thank you
mark

Offline mark4

*
  •  167 167
    • View Profile
Re: script and mach 4
« Reply #7 on: June 22, 2016, 09:03:31 PM »
hello
i have been working and learning screen load script have managed some things not others. i have determined the script for cycle start in gcode tab or mdi is already there you just have to call it this is what i have for cycle start and feed hold and it works so far.

[mc.ISIG_INPUT0] = function (state)
      if (state == 1) then
         mc.mcCntlFeedHold(0)
      end
end,

[mc.ISIG_INPUT1] = function (state)
      if (state == 1) then
         CycleStart()
      end
end,

i have a bread board setup with leds will try it on the machine tomorrow but it works so far