Hello Guest it is April 23, 2024, 08:07:17 AM

Author Topic: Lua script: Pause for operator to jog?  (Read 710 times)

0 Members and 1 Guest are viewing this topic.

Lua script: Pause for operator to jog?
« on: November 09, 2022, 10:38:03 AM »
I'm writing a Lua script that will tap a fixed touch off plate and then ask the operator to jog to a location on the table and move Z down so that the bit touches the table surface.

The idea is to have the script be able to measure the distance between the fixed touch off plate and the top of the table surface.

I have the first part done: The script goes and touches off to the fixed touch off plate and records where the touch off plate is. I have also figured out how it can do the math to figure out how far the touch plate is to the table, and to store that value in the register.

Here's the part where I'm stuck:

In this script, after the touch plate is hit I'd like a message box to pop up and say "Hey user! Go manually jog and put the put on the top of the spoilboard/table surface"

I'd like the script to then wait for the user to do that (and take as long as they'd like) Once they are done I'd like the user to push Cycle Start (or an on screen button)

This is the part I can't figure out... Is there a way for a lua script to "wait" for a user to jog around and proceed when the user presses a button?

Offline Bill_O

*
  •  563 563
    • View Profile
Re: Lua script: Pause for operator to jog?
« Reply #1 on: November 09, 2022, 04:29:01 PM »
No answer from me but I would like to know how to do this also.
Re: Lua script: Pause for operator to jog?
« Reply #2 on: November 09, 2022, 05:34:16 PM »
Hi,
I'm far from certain about this, maybe when smurph (or Daz or Tweakie or Brian or....) reads this he (they) can chime in.....

Quote
. Is there a way for a lua script to "wait" for a user to jog around and proceed when the user presses a button?

My understanding is no. The reasoning goes that if a script is running the Gcode interpreter which is reading and digesting the code has control of Machs central
trajectory planner. Even if the script is paused the trajectory planner is still 'busy' and therefore the GUI which is responsible for the jog input commands cannot
secure the services of the trajectory planner and thereby jog the machine.

To my way of thinking you'd have to split your script into two pieces. The first section would progress until the moment when operator jog inputs are required.
The first section of the script would terminate, not just pause. That would release the trajectory planner which would then be free to execute GUI sourced jog
input commands. Once the jogging is complete the second section of the script would be launched.

Craig

« Last Edit: November 09, 2022, 05:35:50 PM by joeaverage »
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'

Offline Graham Waterworth

*
  • *
  •  2,673 2,673
  • Yorkshire Dales, England
    • View Profile
Re: Lua script: Pause for operator to jog?
« Reply #3 on: November 09, 2022, 08:36:13 PM »
Is the table going to move?

If not then the touch off distance is not going to change so all you need to do is let a tool touch the setter, zero out on the touch point, move and touch the tool on the table with a feeler gauge or paper and the difference in reading is your value.

If table position changes you need 2 scripts, one to touch the table and one to touch the setter.

Without engineers the world stops
Re: Lua script: Pause for operator to jog?
« Reply #4 on: November 10, 2022, 08:29:38 AM »
The position for the second touch (or measurement) will change every time. The idea is that the operator would need to put the bit on top of the table (a table that can get resurfaced).

This will "teach" the script where the top of the table actually is.

Even if I do split this up into two scripts it still is hard/impossible to do the way that I want... Ultimately I need the user to be instructed to put the bit on top of the spoilboard (and to have the opportunity to fool around with just right height by using a piece of paper or feeler gauge)

Even if that was in a second script they'd have to be instructed to do so, so I'd still need a "pause for operator" prompt.

Offline MN300

*
  •  298 298
    • View Profile
Re: Lua script: Pause for operator to jog?
« Reply #5 on: November 10, 2022, 08:53:49 AM »
Could you reverse the order of the operations? If the tap of the fixed touch off plate can be done by the Lua script do the manual table touch first and then let the script take over and find the touch off point.
Re: Lua script: Pause for operator to jog?
« Reply #6 on: November 10, 2022, 02:28:21 PM »
That doesn't really solve the problem... At the beginning of the script I'd have to ask the user if the bit was there on the table, and if it wasn't they'd have to quit out and start over.

I guess I could do that, but it feels a little awkward.

Offline Bill_O

*
  •  563 563
    • View Profile
Re: Lua script: Pause for operator to jog?
« Reply #7 on: November 11, 2022, 01:13:51 PM »
Here is how I would do it.

Check to see if the table or tool setter has been done.
Push a button to do the table.
Set a register for the value from machine home.
Set a register that that operation has been done.
Pop up message window telling them to do the other operation.
When they click OK it exits the macro.
Jog to the position you need and push a different button to do tool set operation.
Check if the table has been done.
If not pop up message window telling them to do it first and exit the macro.
Set a register for the value from machine home.
Set the done register for the table back to not done.
Do your math and tool offset for the tool number.


Offline smurph

*
  • *
  •  1,546 1,546
  • "That there... that's an RV."
    • View Profile
Re: Lua script: Pause for operator to jog?
« Reply #8 on: November 17, 2022, 01:32:27 AM »
mcFileHoldAquire(inst, 'A textual reason for the File Hold', axisJogBits);

Supply the instance, and the reason for the File Hold, and the bitmask of the axes that you want to be able to Jog.  The bitmask is 7 for axes X, Y, and Z.

This is what is used behind the scenes in mcCntlToolChangeManual(). 

WARNING!  You have to command the axis back to the original position. 

Steve
Re: Lua script: Pause for operator to jog?
« Reply #9 on: November 17, 2022, 02:21:18 PM »
Hi,

Quote
mcFileHoldAquire

I've been using Mach4 for years and yet I haven't seen that one before, but it looks like exactly the sort of function required by OP.

I can well imagine that you have to restore the machine position BEFORE releasing the file hold otherwise bad things happen, just like RunFromHere command.
Misusing RunFromHere has given me more crashes than all other Mach functions combined!

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'