Author Topic: PoKeys 57U, Mach4, Buttons and you.  (Read 194 times)

0 Members and 1 Guest are viewing this topic.

Offline brooks

  • Holding
  • Posts: 2
    • View Profile
PoKeys 57U, Mach4, Buttons and you.
« on: December 26, 2018, 06:32:40 PM »
Hey guys - n00b here. So, first, I tried the search function and didn't come up with anything since it's apparently broken. I did google it, and found a thread with what appears to be exactly what I need, but can't get to the thread. ugh.

So... first off, I am relatively 'technical', but LUA is confusing.

I am looking to map signals via Pokeys 57U to physical buttons for the normal stuff, like coolant/mist on/off, spindle etc. I have the simple stuff working - like cycle start/stop. I am 100000% certain this has been covered, but again, with the broken search - it's nearly impossible to locate. I'm hoping someone has a link saved, etc.

BTW, I have the PoBlog link and that got me started, but it seems very generic. If I had a working script in front of me, I could dissect and reassemble for my setup.

TIA

 -Brooks

Offline ZASto

  • Active Member
  • Posts: 116
    • View Profile
Make no mistake between my personality and my attitude.
My personality is who I am.
My attitude depends on who you are.

Offline thosj

  • Active Member
  • Posts: 325
    • View Profile
Re: PoKeys 57U, Mach4, Buttons and you.
« Reply #2 on: December 27, 2018, 06:11:57 PM »
Here's some code for you! You'll need to setup your inputs in your device settings and Mach4 settings then code like this goes in the Screen Start script in the Signal Library section. I included ALL of mine, but it should give you a clue where to start. There's coolant/mist, spindle on, setting speed to 1000 (Mach4 doesn't remember the last speed when shut down so this is a work around for me trying to start the spindle with no speed set!!!) It's commented so you should be able to figure some stuff out for the basics.

Tom

Code: [Select]
---------------------------------------------------------------
-- Signal Library
---------------------------------------------------------------
SigLib = {
[mc.OSIG_MACHINE_ENABLED] = function (state)
    machEnabled = state;
    ButtonEnable()
end,

-- PoKeys pin 9, Mach4 Input 0
-- Physical Cycle Start Button
[mc.ISIG_INPUT0] = function (state)
    if (state == 0) then
        CycleStart()
    end
end,

-- PoKeys pin 10, Mach4 Input 1
-- Physical Feed Hold Button
[mc.ISIG_INPUT1] = function (state)
    if (state == 1) then
        mc.mcCntlFeedHold (0)
    end
end,

-- PoKeys pin 11, Mach4 Input 2
-- Physical Stop Button
[mc.ISIG_INPUT2] = function (state)
    if (state == 1) then
        CycleStop()
    end
end,

--PMDX-108 Port 2 Pin 6 Mach4 Input 10
--HLFB_X ERROR
[mc.ISIG_INPUT10]= function(state)
    if (state==1) then
          mc.mcCntlCycleStop(inst)
          mc.mcCntlSetLastError(inst, "HLFB_X Servo Error")
    end
end,

--PMDX-108 Port 2 Pin 7 Mach4 Input 11
--HLFB_Y ERROR
[mc.ISIG_INPUT11]= function(state)
    if (state==1) then
          mc.mcCntlCycleStop(inst)
          mc.mcCntlSetLastError(inst, "HLFB_Y Servo Error")
    end
end,

--PMDX-108 Port 2 Pin 8 Mach4 Input 12
--HLFB_A ERROR
[mc.ISIG_INPUT12]= function(state)
    if (state==1) then
          mc.mcCntlCycleStop(inst)
          mc.mcCntlSetLastError(inst, "HLFB_A Servo Error")
    end
end,

--PMDX-108 Port 2 Pin 9 Mach4 Input 13
--HLFB_Z ERROR
[mc.ISIG_INPUT13]= function(state)
    if (state==1) then
          mc.mcCntlCycleStop(inst)
          mc.mcCntlSetLastError(inst, "HLFB_Z Servo Error")
    end
end,

----------Mach4 Input 17 PoKeys Pin 17-----
----------Toggle Coolant M8----------------
[mc.ISIG_INPUT17] = function (state)
if (state == 1) then
     local inst = mc.mcGetInstance();
     local sigh = mc.mcSignalGetHandle(inst, mc.OSIG_COOLANTON);
     local sigState = mc.mcSignalGetState(sigh);
     if (sigState == 0) then
         local OSigCool = mc.mcSignalGetHandle (inst,mc.OSIG_COOLANTON)
         mc.mcSignalSetState(OSigCool,1)
         mc.mcCntlSetLastError(inst, "Coolant On")
     else
         local OSigCool = mc.mcSignalGetHandle (inst,mc.OSIG_COOLANTON)
         mc.mcSignalSetState(OSigCool,0)
         mc.mcCntlSetLastError(inst, "Coolant Off")
     end
end
   
end,

----------Mach4 Input 14 PoKeys Pin 14--
----------Toggle Mist M7----------------
[mc.ISIG_INPUT14] = function (state)
if (state == 1) then
     local inst = mc.mcGetInstance();
     local sigh = mc.mcSignalGetHandle(inst, mc.OSIG_MISTON);
     local sigState = mc.mcSignalGetState(sigh);
     if (sigState == 0) then
         local OSigMist = mc.mcSignalGetHandle (inst,mc.OSIG_MISTON)
         mc.mcSignalSetState(OSigMist,1)
         mc.mcCntlSetLastError(inst, "Mist On")
     else
         local OSigMist = mc.mcSignalGetHandle (inst,mc.OSIG_MISTON)
         mc.mcSignalSetState(OSigMist,0)
         mc.mcCntlSetLastError(inst, "Mist Off")
     end
end
   
end,

------------Mach4 Input 8 PoKeys Pin 8----------------
------------Toggle SpinCW-----------------------------
[mc.ISIG_INPUT8] = function (state)
if (state == 1) then
     local inst = mc.mcGetInstance();
     local sigh = mc.mcSignalGetHandle(inst, mc.OSIG_SPINDLEON);
     local sigState = mc.mcSignalGetState(sigh);
     if (sigState == 1) then
         mc.mcSpindleSetDirection(inst, 0);
     else
         SpinCW()
     end
end

end,

------------Mach4 Input 7 PoKeys Pin 7------------
------------Set S1000-----------------------------
[mc.ISIG_INPUT7] = function (state)
    if (state == 1) then   
        mc.mcCntlGcodeExecuteWait(inst, "S1000");
mc.mcCntlSetLastError(inst, 'Speed Set to 1000')
    else
        --mc.mcCntlFeedHold (0)
    end

end,

--sample input use that was originally in here!!
[mc.ISIG_INPUT60] = function (state)
   -- if (state == 1) then   
--        CycleStart()
--    --else
--        --mc.mcCntlFeedHold (0)
--    end

end,
--
Tom Hesselman

Offline brooks

  • Holding
  • Posts: 2
    • View Profile
Re: PoKeys 57U, Mach4, Buttons and you.
« Reply #3 on: December 27, 2018, 09:28:40 PM »
Awesome! Thanks a million guys!