Hello Guest it is March 28, 2024, 12:14:48 PM

Author Topic: Need help getting started Mach4  (Read 4057 times)

0 Members and 1 Guest are viewing this topic.

Need help getting started Mach4
« on: January 16, 2017, 09:49:35 PM »
Building a CNC router and have the control box built and turning motors. I need some help with inputs set up like feed stop buttons and cycle start on the machine. Got them wired in to input pin 1,2 and ground on the bob but not getting setup in Mach4.  Any help on this would be great. This is the first time running Mach4 and not doing so well.
Stop Drop and Roll
Re: Need help getting started Mach4
« Reply #1 on: January 17, 2017, 05:47:56 AM »
Try using the PMC to connect your hardwired buttons to Mach4. It uses ladder logic and for the basic stuff it is real easy.
We never have the time or money to do it right the first time, but we somehow manage to do it twice and then spend the money to get it right.

Offline Chaoticone

*
  • *
  •  5,624 5,624
  • Precision Chaos
    • View Profile
Re: Need help getting started Mach4
« Reply #2 on: January 17, 2017, 04:45:24 PM »
This topic may help if you want to write some custom script.........

http://www.machsupport.com/forum/index.php/topic,33956.msg235406.html#msg235406
;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!
Re: Need help getting started Mach4
« Reply #3 on: January 17, 2017, 06:39:56 PM »
Thanks I will take a look...
Stop Drop and Roll
Re: Need help getting started Mach4
« Reply #4 on: January 17, 2017, 07:03:00 PM »
How do I get to the lua code to mod it. That is just what I,m looking for
Thanks
Stop Drop and Roll

Offline Chaoticone

*
  • *
  •  5,624 5,624
  • Precision Chaos
    • View Profile
;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!
Re: Need help getting started Mach4
« Reply #6 on: January 18, 2017, 10:00:33 AM »
That was a good video.. But I can not find how to add inputs from the machine like Feed hold and cycle start buttons. I can view the lua code but not mod it.
Any more help would be great, Thanks
 
Stop Drop and Roll
Re: Need help getting started Mach4
« Reply #7 on: January 20, 2017, 11:48:00 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

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Re: Need help getting started Mach4
« Reply #8 on: January 20, 2017, 02:25:36 PM »
You seem to be doubling up the function, try cutting down too

Code: [Select]
--------------------------------------------
----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
New For 2022 - Instagram: dazthegas
Re: Need help getting started Mach4
« Reply #9 on: January 20, 2017, 10:08:21 PM »
Thanks for your help... I,m new to this and need all the help I can get. I changed my code to match your and
I get error???  I checked and rechecked. (Inst) is giving the error not returning a number... returning a function.
Stop Drop and Roll