Hello Guest it is January 22, 2020, 08:57:10 PM

Author Topic: Mach 4 Screen Editor GCode Help  (Read 619 times)

0 Members and 1 Guest are viewing this topic.

Mach 4 Screen Editor GCode Help
« on: October 09, 2019, 10:58:01 AM »
Please can somebody help out with a screen editor question:

I require a button on a Mach4 screen that moves the Y axis on my router table forward by 10mm, and then once the button is toggled again it should move back 10mm to its original location. I would also like for this to be triggered by an input on my Hicon Integra motion controller if possible?

I would imagine it would require running a line of GCode, but I don't know where to start with the LUA script  :(

Thanks!

Offline Chaoticone

*
  • *
  •  5,634 5,634
  • Precision Chaos
    • View Profile
Re: Mach 4 Screen Editor GCode Help
« Reply #1 on: October 09, 2019, 11:33:14 AM »
What is the purpose of this?
;D If you could see the things I have in my head, you would be laughing too. ;D

My guard dog is not what you need to worry about!
Re: Mach 4 Screen Editor GCode Help
« Reply #2 on: October 09, 2019, 11:43:30 AM »
What is the purpose of this?

I sometimes mount a chop saw on the end of my router table and use the Y axis as a back stop for the material I’m cutting which has worked great (I’m very limited in space in my workshop!)

It would be good to have the Y Axis move forward slightly once the material  to be cut has been clamped. Then after the cut the axis should move back into place for the next cut.

At the moment I’m achieving this manually by inputting GCode in the MDI each time.

« Last Edit: October 09, 2019, 11:46:07 AM by BGEvents »

Offline Chaoticone

*
  • *
  •  5,634 5,634
  • Precision Chaos
    • View Profile
Re: Mach 4 Screen Editor GCode Help
« Reply #3 on: October 09, 2019, 01:08:11 PM »
Hmmmmmmm, ok. I like it.  :)

This will move the Y axis 10 + from current position

Code: [Select]
local inst = mc.mcGetInstance()
local YMach, rc = mc.mcAxisGetMachinePos(inst, mc.Y_AXIS)
rc = mc.mcCntlMdiExecute(inst, string.format("G0 G53 Y%4.4f", (YMach + 10)))

This will move the Y 10 - from current position

Code: [Select]
local inst = mc.mcGetInstance()
local YMach, rc = mc.mcAxisGetMachinePos(inst, mc.Y_AXIS)
rc = mc.mcCntlMdiExecute(inst, string.format("G0 G53 Y%4.4f", (YMach - 10)))

Plop you a toggle button on the screen and put one script in the buttons Up script event and the other script in the buttons Down script event. Put whatever you want for the buttons up and down colors and text. That will take care of the button.
;D If you could see the things I have in my head, you would be laughing too. ;D

My guard dog is not what you need to worry about!

Offline Chaoticone

*
  • *
  •  5,634 5,634
  • Precision Chaos
    • View Profile
Re: Mach 4 Screen Editor GCode Help
« Reply #4 on: October 09, 2019, 01:14:16 PM »
Also set your button you add enabled states to something that won't get you into trouble. For example, I'm pretty sure you don't want this to happen if the axis is executing a gcode move already and you hit the button.
;D If you could see the things I have in my head, you would be laughing too. ;D

My guard dog is not what you need to worry about!
Re: Mach 4 Screen Editor GCode Help
« Reply #5 on: October 09, 2019, 01:28:24 PM »
Also set your button you add enabled states to something that won't get you into trouble. For example, I'm pretty sure you don't want this to happen if the axis is executing a gcode move already and you hit the button.


Legend! Thanks a lot for this - will test it out later  :)

Is it quite straightforward to link this to an input on my motion controller so I can have a foot switch toggle the button as well?

Offline Chaoticone

*
  • *
  •  5,634 5,634
  • Precision Chaos
    • View Profile
Re: Mach 4 Screen Editor GCode Help
« Reply #6 on: October 09, 2019, 02:42:40 PM »
Quote
Is it quite straightforward to link this to an input on my motion controller so I can have a foot switch toggle the button as well?

Yes, get the button working first. You can then add the input to the sigLib in screenload script and set the buttons state based on the state of the input.
;D If you could see the things I have in my head, you would be laughing too. ;D

My guard dog is not what you need to worry about!

Offline Bill_O

*
  •  250 250
    • View Profile
Re: Mach 4 Screen Editor GCode Help
« Reply #7 on: October 09, 2019, 03:39:07 PM »
You might want to have a g91 before those moves in case the current position is not at 0 then switch back to g90

Offline Chaoticone

*
  • *
  •  5,634 5,634
  • Precision Chaos
    • View Profile
Re: Mach 4 Screen Editor GCode Help
« Reply #8 on: October 09, 2019, 05:00:21 PM »
Not necessary Bill.

The way he described it he just wants to move 10 + or - from where he is at. This is why I am getting the current position and moving + or - of it. And I'm doing it using a G53 so I don't have to get, change and set back modal modes he may be in when he wants to do this. If he wanted to go to an absolute position every time I would still do it with G53 for the same reasons listed above but I would not need to get the current position or do any math to it to find out where I wanted to end up.
;D If you could see the things I have in my head, you would be laughing too. ;D

My guard dog is not what you need to worry about!

Offline Chaoticone

*
  • *
  •  5,634 5,634
  • Precision Chaos
    • View Profile
Re: Mach 4 Screen Editor GCode Help
« Reply #9 on: October 09, 2019, 05:14:01 PM »
Also, not a good idea to just "switch back to g90". How do you know it was in G90 when the script ran? You don't unless you check. May well have been in G91 before the script ran, Gcode is perfect and doing exactly what it should (setting G91 mode) when it should. Then you run the script and that script changes it to G90. How does the Gcode know this changed and how does it overcome this? Well, it doesn't. That is why if you set any modal modes in your script you better check what they were before you set them and set them back to previous status before you finish your script. 
;D If you could see the things I have in my head, you would be laughing too. ;D

My guard dog is not what you need to worry about!