PMDX Forum
General Category => General Discussion => Topic started by: Firechief 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.
-
I found out that you can edit Mach4 in the Demo mode.
-
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.
-
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 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
I have tried this new code and can not get it to work. It return some errors. I will keep trying.
-
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
-
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.
-
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.
-
Here is some pic of my control box... Let me know what you think.
-
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.
-
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
-
Some pics of it mounted on box
-
Nice work.
-
Here is the start to my router table. Got some work done this weekend.
-
Some more pics. Man in pics is a great friend (Danny) and is one of the best paint and body worker I know.
Please let me know what you think, Good or bad.
Tim
-
Some more pics. Man in pics is a great friend (Danny) and is one of the best paint and body worker I know.
Please let me know what you think, Good or bad.
Tim