Hello Guest it is March 29, 2024, 06:16:02 AM

Author Topic: easy way i can make "Enable, Cycle start,ect" in mach 4 work with key stroke  (Read 8909 times)

0 Members and 1 Guest are viewing this topic.

using mach 4 on win 10

 there is a keyboard plugin in mach 4 but it has loaded with keystrokes you can map to keys but its limited in what functions you can map to a key,...or is ther a way to add some that arent ther into it...
whats the easiest way i can make mach4 buttons like "CYCLE START" , "FEED HOLD", "STOP", ''ENABLE"  need to start when i hit a key on keyboard,... im thinking its in the lua script or code im guessing but i have not a clue in how to do it or use it, ive tried to figure the script out but its just to much right now im pulling my hair out tryn to figure it out, Therese no vids that i know of unless yal can point me in right direction
« Last Edit: June 30, 2018, 08:30:28 PM by jbraddock »
Hi.
can't help with all of those questions but I can show you how to do a few of them.

Have you watched the 'Edit Screen' video....you need to watch it.

In edit screen mode have a look at the <Cycle Start> button events. I have posted a screen shot of it. Note that the event has a 'left up script' That means when the screen button
is released the nominated script executes. In this case its not a script per se but rather a Lua function CycleStart().

Just as a matter of interest this is the source code of the function.....its in the screen load script:
Code: [Select]
---------------------------------------------------------------
-- Cycle Start() function.
---------------------------------------------------------------
function CycleStart()
    local rc;
    local tab, rc = scr.GetProperty("MainTabs", "Current Tab")
    local tabG_Mdione, rc = scr.GetProperty("nbGCodeMDI1", "Current Tab")
    local tabG_Mditwo, rc = scr.GetProperty("nbGCodeMDI2", "Current Tab")
   
    --See if we have to do an MDI command and if so, which one
    if ((tonumber(tab) == 0 and tonumber(tabG_Mdione) == 1) or (tonumber(tab) == 2 and tonumber(tabG_Mditwo) == 1 )) then
        local state = mc.mcCntlGetState(inst);
        if (state == mc.MC_STATE_MRUN_MACROH) then
            mc.mcCntlCycleStart(inst);
            mc.mcCntlSetLastError(inst, "Do Cycle Start");
        else
            if (tonumber(tab) == 0) then 
                scr.ExecMdi('mdi1');
                mc.mcCntlSetLastError(inst, "Do MDI 1");
            else
                scr.ExecMdi('mdi2');
                mc.mcCntlSetLastError(inst, "Do MDI 2");
            end
        end
    elseif tonumber(tab) > 2 then --No G Code or MDI panel is displayed so Do Nothing
        mc.mcCntlSetLastError(inst, "Nothing to Start");
    else --Do CycleStart
        mc.mcCntlSetLastError(inst, "Do Cycle Start");
        mc.mcCntlCycleStart(inst);       
    end
end

Don't concern yourself with the code....I only mentioned it so that you could see in fact there is a bunch of code that runs when you call what looks like such a simple function call CycleStart().

In order that you can hit a remote button and have the cycle start what you want to do is have an input to Mach from the physical button call CycleStart() as if you'd hit the screen button.

In the ESS or PoKeys plugin assign an input pin to the physical button. Then in the Input Signals page in the ESS plugin (presumably the PoKeys plugin is similar but I'm not familiar with it)
connect that pin to a general purpose input signal ISIG_INPUT10 say.

Now you will need to put in the SigLib table an entry to tell Mach we are interested if the signal ISIG_INPUT10 triggers.

Code: [Select]
[mc.ISIG_INPUT10]=function(state)
if state==1 then
CycleStart()
end
end

And THAT'S IT!  If you put that little piece of code into the SigLib table which is at the top of the screenload script you have coded all that is required to have Mach4 monitor an input
and execute a function when the input triggers. How easy is that?

You might have noticed that I attached a second screenshot of the <FeedHold> button. Note that it has a left up action. An action is internal to Mach and the  above method wont work
for that action. I'm sure it can be done but need to think about it a bit more yet.

If in edit screen mode you click on various buttons that about half have either a script or a fuction as an event for which the recipie above will work and the rest have actions as events.
I will do some more thinking and research and get back to you.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Hi,
oops, sorry forgot to attach the screen shots....

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Whay will trigger the esz input 5v or grnd?
Hi,
on the ESS Pins Config page you have the choice of active high OR active low.

I don't know how you've wired your button and whether your BoB has a pull-up or a pull down resistor. Active high OR active low will depend
on those details.

Just another idea is that on Machs Machine Diagnostics tab, at least in the wx4.set screen set, there is a whole bunch of LEDs, in particular notice the Iinput0 through Input5
in the Inputs panel. If you chose to attach your ESS/BoB input pin to ISIG_INPUT0 say, rather than my earlier suggestion of ISISG_INPUT10 then every time you hit your button
you should see the LED light up. Very simple and convenient way to test to button and circuit.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
I dont want to burn it up by hooking + or - into wrong input
Hi,
yes I understand your caution.

Are you using the ESS? If so what breakout board are you using, or even are you using a breakout board?

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Hi,
I've attached a representative circuit diagram of an ESS input.

Provided you don't put MORE than 5V on the OR less than 0V then you cant blow the ESS by hooking up either + or -.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Hi,
it is perfectly possible to hook direct to the pins of the ESS but preference is given to hooking up a breakout board. Firstly because they have screw terminal
you are less likely to accidently bridge two pins causing a fault. I use MB2s from Homan Designs in Austrailia, near enough to local for me.
I see the C10 board is reasonably priced and doesn't have to much in the way of specialised pin circuitry to interfere with flexibility.

Given the cost of the ESS and how central it is to my mill I would not contemplate using any port of the ESS WITHOUT a breakout board.
I work with electronics day in day out and I value any methods/procedures/designs that limit unintentional damage to boards, especially so if I have to
pay for a replacement!

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
C11g i believe  but im using 10 through 15 for  limits an emergency stop so i think im out of inputs they are labeled outputs in diagram but i belive thst a typo those are inputs

https://www.automationtechnologiesinc.com/products-page/breakout-boards-mpg/c11g-multifunction-cnc-board/
« Last Edit: June 30, 2018, 11:51:14 PM by jbraddock »