Author Topic: Mach4  (Read 8817 times)

Firechief

  • Posts: 26
    • View Profile
Mach4
« on: January 17, 2017, 08:35:33 PM »
Trying to edit lua in Mach4. I can view it but not edit it. Can you edit the demo system or do you have to have a lic version.
« Last Edit: February 13, 2017, 11:17:25 AM by Firechief »
Stop Drop and Roll

Firechief

  • Posts: 26
    • View Profile
Re: Mach4
« Reply #1 on: January 20, 2017, 11:19:21 AM »
I found out that you can edit Mach4 in the Demo mode.
« Last Edit: February 13, 2017, 11:19:18 AM by Firechief »
Stop Drop and Roll

Firechief

  • Posts: 26
    • View Profile
Re: Mach4
« Reply #2 on: January 20, 2017, 11:44:29 AM »
Just for someone that is starting out with Mach4, I was trying to add Button input from the machine panel to Mach4 and here is what I did.

My first problem was trying to find out were the add some lua code for the inputs to work:
Open Mach4... 1- up top click on the Operator menu, then EDIT SCREEN. 2- In the tree manger (left side top box) click on wxrouter or the top item. 3- In the Properties (left side bottom box) click on the events button (middle one), then click on the SIGNAL SCRIPT line (Should be the bottom line), then a button should show up to the right of the line, click on the button and a mclua editor page will open. Then the code I added was at the end of what was there.

You will need to set up you inputs in Mach4 to match what is in the code

-------------------------------------------
----- My Code for input from Machine
-------------------------------------------
--------------------------------------------
----Cycle Start buttons on MachMate
--------------------------------------------
if (sig == mc.ISIG_INPUT1) and (state == 1) then
local inst = mc.mcGetInstance()
mc.mcCntlCycleStart(inst)
end
SignalTable = {
[mc.ISIG_INPUT1] = function (on_off)
if (on_off == 1) then
mc.mcCntlCycleStart(inst)
end
end
}
---------------------------------------------
----Feed Hold Buttons on MachMate
----------------------------------------------
if (sig == mc.ISIG_INPUT2) and (state == 1) then
local inst = mc.mcGetInstance()
mc.mcCntlFeedHold(inst)
end
SignalTable = {
[mc.ISIG_INPUT2] = function (on_off)
if (on_off == 1) then
mc.mcCntlFeedHold(inst)
end
end
}

Hope this help someone out.
Stop Drop and Roll

hooked

  • Posts: 27
    • View Profile
Re: Mach4
« Reply #3 on: January 20, 2017, 12:20:04 PM »
THANKS.  I'm just starting out with Mach4 and PMDX-416.  Just getting all the components together to build my second machine.  First one was Arduino based.

This forum seems extremely quiet.  I'm still awaiting a response to an issue I posted.

Cheers

Daryl

Steve Stallings

  • Administrator
  • Posts: 527
  • www.PMDX.com/Images/Avatar120.jpg
    • View Profile
Re: Mach4
« Reply #4 on: January 20, 2017, 03:09:14 PM »
I see that DazTheGas has offered an improved bit of code for this in your thread
on the MachSupport forum. Quoted below>>>



You seem to be doubling up the function, try cutting down too

Code:

--------------------------------------------
----Cycle Start buttons on MachMate
--------------------------------------------
local inst = mc.mcGetInstance

SigLib = {
[mc.ISIG_INPUT1] = function (state)
     if (state == 1) then   
        mc.mcCntlCycleStart(inst)
end,

---------------------------------------------
----Feed Hold Buttons on MachMate
----------------------------------------------
[mc.ISIG_INPUT2] = function (state)
     if (state == 1) then   
        mc.mcCntlFeedHold(inst)
end,

[mc.ISIG_INPUT3] = function (state)
     if (state == 1) then   
        -- do something
end,

[mc.ISIG_INPUT4] = function (state)
     if (state == 1) then   
        -- do something
end,

[mc.ISIG_INPUT5] = function (state)
     if (state == 1) then   
        -- do something
end
} -- etc.............................


DazTheGas
Steve Stallings
www.PMDX.com

Firechief

  • Posts: 26
    • View Profile
Re: Mach4
« Reply #5 on: January 20, 2017, 10:19:08 PM »
Steve
I have tried this new code and can not get it to work.  It return some errors. I will keep trying.

Stop Drop and Roll

Firechief

  • Posts: 26
    • View Profile
Re: Mach4
« Reply #6 on: January 20, 2017, 10:21:28 PM »
THANKS.  I'm just starting out with Mach4 and PMDX-416.  Just getting all the components together to build my second machine.  First one was Arduino based.

This forum seems extremely quiet.  I'm still awaiting a response to an issue I posted.

Cheers

Daryl

I will try to help out, but I,m in the same boat
Stop Drop and Roll

Steve Stallings

  • Administrator
  • Posts: 527
  • www.PMDX.com/Images/Avatar120.jpg
    • View Profile
Re: Mach4
« Reply #7 on: January 21, 2017, 02:27:50 PM »
DazTheGas has updated his code again to fix an omission. Here is
a copy of his post on the MachSupport forum:

//////////////////////////////////////////////////////////////////////
OOOppps TYPO ALERT

mc.mcGetInstance is a function and is missing the () at the end, so should of been mc.mcGetInstance() - although if this is in the screen load script then it is already declared at the beginning.

I also noticed I had`nt ended any of the if statements, so heres the same code without the typo`s

Code:

--------------------------------------------
----Cycle Start buttons on MachMate
--------------------------------------------
local inst = mc.mcGetInstance()

SigLib = {
[mc.ISIG_INPUT1] = function (state)
    if (state == 1) then   
        mc.mcCntlCycleStart(inst)
    end
end,

---------------------------------------------
----Feed Hold Buttons on MachMate
----------------------------------------------
[mc.ISIG_INPUT2] = function (state)
    if (state == 1) then   
        mc.mcCntlFeedHold(inst)
    end
end,

[mc.ISIG_INPUT3] = function (state)
     if (state == 1) then   
        -- do something
     end
end,

[mc.ISIG_INPUT4] = function (state)
    if (state == 1) then   
        -- do something
    end
end,

[mc.ISIG_INPUT5] = function (state)
    if (state == 1) then   
        -- do something
    end
end
} -- etc.............................

//////////////////////////////////////////////////////////

Firechief, who posted the original question, has reported
success with this new code.
Steve Stallings
www.PMDX.com

Firechief

  • Posts: 26
    • View Profile
Re: Mach4
« Reply #8 on: January 22, 2017, 08:47:01 AM »
After I updated to the corrected code it work great. Remember that you have to go into config Mach menu and then inputs and set them. The first line in the input Mach4 you used,  the middle line is your board you are using and the last line is your input that your board was wired to. Then click the X mark to change it to a check mark to activate it. In your code you will use the first line in Mach4 input you set in the config menu. 
Good luck, hope this makes sense.
Thanks for all your help Steve.
« Last Edit: January 22, 2017, 08:59:54 AM by Firechief »
Stop Drop and Roll

Firechief

  • Posts: 26
    • View Profile
Re: Mach4
« Reply #9 on: January 24, 2017, 10:49:11 AM »
Here is some pic of my control box... Let me know what you think.
Stop Drop and Roll

Steve Stallings

  • Administrator
  • Posts: 527
  • www.PMDX.com/Images/Avatar120.jpg
    • View Profile
Re: Mach4
« Reply #10 on: January 24, 2017, 11:01:26 AM »
Looking good! I see you used my favorite method of mounting
the Gecko drives and heatsink through the wall of the control
box to get the heat out of the box without drawing air through
the box.
Steve Stallings
www.PMDX.com

Firechief

  • Posts: 26
    • View Profile
Re: Mach4
« Reply #11 on: January 24, 2017, 11:32:23 AM »
You are correct... I got that from your site... Great Idea, and looks as it will work great. I think all your products and information you have is top notch. Looking forward to using some more of it soon.

Tim
« Last Edit: January 24, 2017, 11:37:55 AM by Firechief »
Stop Drop and Roll

Firechief

  • Posts: 26
    • View Profile
Re: Mach4
« Reply #12 on: January 24, 2017, 11:37:27 AM »
Some pics of it mounted on box
Stop Drop and Roll

hooked

  • Posts: 27
    • View Profile
Re: Mach4
« Reply #13 on: January 25, 2017, 12:07:06 PM »
Nice work.

Firechief

  • Posts: 26
    • View Profile
Re: Mach4
« Reply #14 on: February 13, 2017, 10:57:43 AM »
Here is the start to my router table. Got some work done this weekend.
Stop Drop and Roll