Machsupport Forum

Third party software and hardware support forums. => PoKeys => Topic started by: TDAY on April 23, 2016, 12:05:55 PM

Title: Pokeys57E,Mach4 External Push Button
Post by: TDAY on April 23, 2016, 12:05:55 PM
Hello,
 Does anyone have an example of how to configure Mach4&Pokeys57E plugin for a External Push button or switch? Example: I have Pokeys pin 28 set as Digital Input, which is wired to my Cycle Start button. How do you configure plugin and Mach4 so Mach4 knows this input is Cycle Start?

Thanks,
Troy
Title: Re: Pokeys57E,Mach4 External Push Button
Post by: NeoTO on April 25, 2016, 04:29:48 PM
Hi, Troy

Please follow the tutorial on our blog page: http://blog.poscope.com/mach4-tutorial-custom-signal-mapping/

Regards,
Matevž
Title: Re: Pokeys57E,Mach4 External Push Button
Post by: TDAY on April 26, 2016, 07:14:40 AM
Hello Matevz,
 That looks great :) I will reply back here with results.
Thanks again,
Troy
Title: Re: Pokeys57E,Mach4 External Push Button
Post by: TDAY on April 26, 2016, 03:43:14 PM
Ok. Tutorial worked great, as Cycle Start button is now working. Thought i could use this tutorial for all my other inputs by copying the code for CycleStart and just change the ISIP input and the CycleStart() like below for CycleStop....

[mc.ISIG_INPUT27] = function (state)
if (state == 1) then   
        CycleStop()
    end

but did not work.

I have more external buttons and switches to add like the CycleStart, is there a list or literature i should be referring to for the LUA script and Mach4 commands? Iam only somewhat familiar with Mach3 and the OEM codes in VisualBasic. Any help is much appreciated.
Thanks,
Troy
Title: Re: Pokeys57E,Mach4 External Push Button
Post by: dude1 on April 26, 2016, 07:52:10 PM
there is a Mach4 programming manual in the manual folder in the Mach4 folder on your C drive

you will have to make a table
Title: Re: Pokeys57E,Mach4 External Push Button
Post by: TDAY on April 27, 2016, 11:03:33 AM
I read the manual and found a short description of a Table, but not enough info for me on how to make one or where to place it and how to use it. Is there a example on how to make one for adding more inputs for physical external buttons and switches?
Title: Re: Pokeys57E,Mach4 External Push Button
Post by: NeoTO on April 27, 2016, 12:10:42 PM
If you look at the code in the script, you will notice that you have somewhere in the beginning

Code: [Select]
---------------------------------------------------------------
-- Signal Library
---------------------------------------------------------------
SigLib = {

Then, one block as following for each signal

Code: [Select]
[mc.<signal name>] = function (state)
 < code >
end

So, SigLib is a Table name, which contains handler functions for all signals in the list. The SigLib ends somewhere later on (around row 70) with a '}'
To add a new signal handler, make sure that you insert it in the Table and that you put a comma at the end of it.

Code: [Select]
---------------------------------------------------------------
-- Signal Library
---------------------------------------------------------------
SigLib = {
[mc.SIGNAL1] = function (state)
 < code >
end,
[mc.SIGNAL2] = function (state)
 < code >
end,
[mc.SIGNAL3] = function (state)
 < code >
end,
...

[mc.SIGNALn] = function (state)
 < code >
end
}



Title: Re: Pokeys57E,Mach4 External Push Button
Post by: TDAY on April 27, 2016, 03:59:22 PM
Here is what i tried to do for CycleStop....
Title: Re: Pokeys57E,Mach4 External Push Button
Post by: TDAY on April 27, 2016, 04:01:02 PM
But when i press the external cycle stop during a Gcode MDI run i get the following error.....
Title: Re: Pokeys57E,Mach4 External Push Button
Post by: dude1 on April 27, 2016, 04:08:04 PM
have it in it's own section the end end stops the table and state 1 on, state 0 off
Title: Re: Pokeys57E,Mach4 External Push Button
Post by: TDAY on April 28, 2016, 02:24:02 PM
I dont understand what you are saying...
Title: Re: Pokeys57E,Mach4 External Push Button
Post by: dude1 on April 28, 2016, 03:35:54 PM
how NeoTO says to have is how it is to be done not like what you have
Title: Re: Pokeys57E,Mach4 External Push Button
Post by: Brian Barker on April 29, 2016, 08:27:54 AM
TDAY, if you would like  I can post how to do it... you should be able to modify the other output to make it work. You will find with this system you can do ANYTHING. But the cost is it is a bit more complex.

Looked again at your error and it is nothing to do with your signal script. You are calling set last error and not sending the Inst , String . Please look at your code in the CycleStop() function. If you post a screen shot we can have a look at it .