Hello Guest it is March 29, 2024, 03:08:28 AM

Author Topic: Using physical button to set Gcode for Tool Change  (Read 2165 times)

0 Members and 1 Guest are viewing this topic.

Using physical button to set Gcode for Tool Change
« on: April 04, 2017, 12:06:32 PM »
If I have a physical button hooked up to my pokeys board I know generally how to program it to do a general function such as cycle start; how do I get it to run something like G0G53X0Z0?

Also how do I get a pysical button to set feed rate? I do a lot of manual machine on my CNC lathe, i.e. using the keyboard to face a part, and for this I use different feed rates. Usually I use the slider, but that's a pain. How do I use a button to change the feedrate. I know probably where it should be just need to know the code.
Re: Using physical button to set Gcode for Tool Change
« Reply #1 on: April 22, 2017, 09:41:47 PM »
No one? Any help?

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Re: Using physical button to set Gcode for Tool Change
« Reply #2 on: April 23, 2017, 03:31:21 AM »
You may want to look at examples on the sigLib like the example in the Screen Load Script for mc.ISIG_INPUT1 / CycleStart, you can then create more to include your gcode with commands like

mc.mcCntlMdiExecute(inst, "G0G53X0Z0") or mc.mcCntlGcodeExecute(inst, "G0G53X0Z0")

For the feedrate you might want to check out the pokeys example for using an external pot  http://blog.poscope.com/mach4-tutorial-fro-using-analog-input/

DazTheGas
New For 2022 - Instagram: dazthegas
Re: Using physical button to set Gcode for Tool Change
« Reply #3 on: April 23, 2017, 01:40:53 PM »
Ok thanks I'll try that.
Re: Using physical button to set Gcode for Tool Change
« Reply #4 on: April 23, 2017, 02:00:32 PM »
Ok question. In previous post I made, someone said to look at the Mach4Core API Help file for the codes I'll need, but it doesn't list CycleStart () as such it references the code in lua as mcCntlCycleStart  so what's the difference?

Daz, how does this code look?

end,
[mc.ISIG_INPUT0] = function (state)
if (state == 1) then  
        CycleStart()
    end
end,
[mc.ISIG_INPUT2] = function (state)
if (state == 1) then  
        mc.mcCntlFeedHold()
    end
end,
[mc.ISIG_INPUT3] = function (state)
if (state == 1) then  
        mc.mcCntlMdiExecute(inst, "G01F100")
    end
end,
[mc.ISIG_INPUT4] = function (state)
if (state == 1) then  
        mc.mcCntlMdiExecute(inst, "G01F1")
    end  
end,
[mc.ISIG_INPUT5] = function (state)
if (state == 1) then  
        mc.mcCntlMdiExecute(inst, "G01F5")
    end  
end,
[mc.ISIG_INPUT6] = function (state)
if (state == 1) then  
        mc.mcCntlMdiExecute(inst, "G01F10")
    end  
end,
[mc.ISIG_INPUT7] = function (state)
if (state == 1) then  
        mc.mcCntlMdiExecute(inst, "G0G53X0Z0")
    end  
end,
[mc.ISIG_INPUT1] = function (state)
   -- if (state == 1) then  
--        CycleStart()
--    --else
--        --mc.mcCntlFeedHold (0)
--    end

end,


Also need to use a physical button to control jogging, such as moving x axis up and down. Looked at the mach4api help file and haven't found what code I need. Thanks.
Re: Using physical button to set Gcode for Tool Change
« Reply #5 on: April 25, 2017, 12:55:31 AM »
Ok. So some weird things going on.

I did what I said above. The feed hold codes and other codes didn't work. The cycle start did, kind of. Also figured out how to use the jog functions. They're further down the list in Inputs.

When I setup the cycle start it works, but then cycle start keeps running and other functions aren't useable. If I set it to active low then it automatically starts whatever is in mdi or gcode screen.

So I'm not sure what's going on, but with cycle start setup the program doesn't run correctly or shutdown correctly. Mach core is still running. It's like the cycle start is still going.

Any help would be appreciated.