Pendant button for Auto Tool Zero

MSM Mill mode support
Post Reply
zkmiller
Posts: 5
Joined: Mon Feb 25, 2013 6:19 pm

Pendant button for Auto Tool Zero

Post by zkmiller »

I am trying out the iPad MachPendant app. It appears to work really well except for a couple of buttons. On is the 'AUTO TOOL ZERO' button. This button is supposed to remotely press the same button in Mach. The problem is that that button needs to have code behind it. In standard Mach screens there is a button that could be edited. However, in MSM it doesn't exist. When I press the button on the iPad the Mach screen goes blank. How can I create an 'AUTO TOOL ZERO' button in MSM to do a Probe Z function to set Z-Zero?
User avatar
DaveCVI
Site Admin
Posts: 798
Joined: Mon Feb 04, 2013 3:15 pm
Contact:

Re: Pendant button for Auto Tool Zero

Post by DaveCVI »

Hi,
I think there is some misunderstanding here (at least on my part ;) ) ...
The description of how things work does not match my understanding of how mach actually does work.
To explain I'm going to have to go thru some technical details of what screen sets are and how mach implements them.

To most users a "screen set" is the set of stuff that they see visually on the screen. That is true, but to get to your question we have to consider what happens in mach when you "click a button".

When mach starts, it has the name of a screen set to load as one of the things stored in the mach profile that is being started. Mach defaults to "1024.set" for a mill and when you're using MSM it is "MachStdMIll.set".

So mach will load up the specified screen set.
But what is a screen set?
A screen set file is a binary format file that contains several things.

For this discussion we are interested in:
Buttons: The screen set file has a list of "buttons" that are defined in the screen set, Each button has a size (width and height) and a location on the screen. Buttons can also have a bitmap associated with them - this is how you make the buttons look different to the human.

When you click the mouse on a mach button you are actually doing is:
a) sending a click event to windows, which sends it to mach. A click envent says "the mouse button was clicked at location X,Y on the screen".
b) mach gets the click event and looks at the coordinates of the event (X,Y) it then compares that location to the list of button "areas" that it built up when loading the screen set. If the click is within a button area of the screen, then mach "runs that button".
NOTE that buttons are not invoked by a button name. Mach does all windows event handling internal to mach and there are no programming interfaces exposed by mach at the mach script interface that deal with windows events.

What does "running a mach button" mean? For each button defined in a screen set there are a couple of different action that can happen.
Each button can do one of three things:
1) A very common situation is that a button can have associated with it a command code to issue to mach itself. These are the "OEM button" codes that you hear people talk about. Click the button, and mach issues itself the command code stored in the screen set for the button. For example feed hold will issue mach command code 1 - which is the magic number for feed hold to mach.
2) a button can execute some gcode. The gcode to run is stored in the screen set file.
3) a button can execute a Cypress basic script. The script to be run is stored in the screen set file as part of the button definition.

It is this third case that applies to the "auto tool zero" button that is in the 1024 screen set. That button is set to run this single line of mach script:
Message("Not Yet Implemented')
and when you click the button when running 1024.set that is exactly what you get - a dialog with that message.

The button is useless as supplied with the 1024 screen set. To get it to do anything you would have to put whatever script code you wanted it to run in the 1024 screen set (welcome to customizing mach screen set files).

I did not put a useless "auto tool zero" button in MSM - as that would be rather silly given that MSM provides a lot of enhanced functionality to handling tool offsets.

Now, what it important here is to understand that a mach button is not a magic predefined thing. A button only has meaning within the context of the screen set within which it is defined. Buttons do not have names or numbers and they are not common between screen sets. There is no way I know of to "Click a button" programatically - they are simply not defined outside of mach's internal code.

So... with all that as background, when the pendent program author says that they "click the auto tool zero button - my first reaction is "Huh"? That statement makes no sense form a technical stand point - there is no such animal as a "auto tool zero" button pre-defined for all screen sets.

Which rather begs the question of what is that iOS program is doing to talk to mach?
Specifically, what does it think it is doing when you use a button that is apparently defined in the iOS application, which therefore appears to be assuming that anything that exists in 1024 also exist in all other screen sets - which is a very bad and wrong assumption.

To figure this out further, you'll need to ask the pendant code author what the pendant code is doing.
How does the pendant communicate between the pendant and Mach? what is the physical link between them?
How is that communication link interfaced to mach?
When you "click a button on the pendant" what is generated and sent over that link from the pendant to mach?
How does that message from the link get into mach and what command does mach see as a result?

Alas, these are all questions that only the pendant code author can help with.
i suspect that as a user, you really don't want to care about the details of this. Please invite whoever the pendant author is to contact me directly, I"ll be happy to talk to them about the technical details and see what we can figure out.

Finally, would you provide me a list of the buttons in the pendant that do not work as expected?

Dave
Productivity Software for Personal CNC Machinists
http://www.CalypsoVentures.com
zkmiller
Posts: 5
Joined: Mon Feb 25, 2013 6:19 pm

Re: Pendant button for Auto Tool Zero

Post by zkmiller »

Dave,
Thank you so much for that great explanation. I guess I have been looking at this at to high a level. You are right, I need to find out just what the iPad is sending to the PC. I neglected to mention that it communicates with Mach via a 'server' application running on the PC that manages the connection. I will try to get some more information. I guess I was thinking that there was some keyboard sequence, like the right, left, up and down arrows for jogging, that would equate to the 'auto tool zero'.

I will do a little more homework and see what I can learn.

Thanks,

Zeke
User avatar
DaveCVI
Site Admin
Posts: 798
Joined: Mon Feb 04, 2013 3:15 pm
Contact:

Re: Pendant button for Auto Tool Zero

Post by DaveCVI »

I suspect it will eventually come down to these questions:

1) What is the connection between the Pendant PC side app and mach?
2) what interface into mach does that connection use?
(call mach as a com object or some private protocol into mach via a pendant com plugin are two possibilities).
3) what goes into mach as a result of clicking "auto tool zero" on the pendant?

This is where I suspect something odd is going on...
I took a look at the pendant web site (pretty pictures, but no tech info). Most of the buttons on the pendant are implemented in mach by standard MACH OEM codes. So they will map directly from a pendant button to a mach OEM code. I can see the system just passing a mach OEM code form the iOS side to the PC side and then into mach.

The nice thing about mach OEM codes is that they are understood by mach itself - and thus they will be common across (independent of) screen sets.

If a button is running gcoce, then pendant could ship the gcode across from the pendant to the PC app and then issue the gcode to mach to execute. That too would be independent of screen sets. It appears that the pendant has the ability to move gcode files from the iOS device to the PC. I could see this being leveraged to handle gcode buttons.

But the third case - user scripts - is not as nice.
If the pendant had the user level script to be executed resident in the pendant, it could treat it similar to gcode (pass it over to mach nd have mach execute it) and things would be fine.
But the claim is that the pendant is expecting to magically find some script in mach to execute... and that means the pendant design is making assumptions about some user scripts being common to all installs of mach for all screen sets. If ti's doing that, it is making a bad assumption.

I also don't see how the pendant app on the PC can "Click the set auto zero button"... the buttons are not available by name at a mach interface - so this implies something kludgy (or maybe something very clever that I am not thinking of) like issuing a mouse event to mach. That would be a (IMHO) a horrid design as mach would see the mouse event and execute whatever button was at that screen coordinate... and that is not going to be common across screen sets - that would not even be the same on all pages of a single screen set!
Remember that a fundamental reason for people creating different screen sets is to move things around on the page....

Same problem for key mappings - as screen sets (and users) can alter key mappings - it's not safe to assume that key mappings are invariant.

Most pendants issue an OEMtrigger code to mach when a button is pressed. This is what those are designed for - they are an "OEM defined trigger" - mach just provides a way to input 15 OEM triggers. Then at the mach side some way is provided for the user to map the specific trigger code (1-15) to a mach action.

But that would not be described by saying "maybe the problem is that the screen set does not have a "auto tool zero" button.

Dave
Productivity Software for Personal CNC Machinists
http://www.CalypsoVentures.com
zkmiller
Posts: 5
Joined: Mon Feb 25, 2013 6:19 pm

Re: Pendant button for Auto Tool Zero

Post by zkmiller »

Dave,
It appears that the pendant is sending a DoOemButton(34) command to Mach. We don't see any reference for an OEMbutton 34 if he were to change it to something else that could be user implemented what code would be best?

Zeke
User avatar
DaveCVI
Site Admin
Posts: 798
Joined: Mon Feb 04, 2013 3:15 pm
Contact:

Re: Pendant button for Auto Tool Zero

Post by DaveCVI »

OEMButton codes 1-99 are "go to screen set page #".
So DoOEMBUtton(34) will make mach display screen set page 34 - and there is no page 34 in the MSM screen set. There is also no page 34 in the 1024 screen set. So issuing this command will result in a blank mach page (and one without any buttons to get back to a page that does exist in the screen set).

So I gotta ask: why would clicking a button labeled "auto tool zero" on a pendant want to make mach go to screen page 34?

Another interesting (at least to me) question is why do you want the "auto tool zero" button in MSM?
I mean there is lots of tool handling functionality in MSM, so much so that no one has asked for something that MSM does not do in several years.... What are you hoping to accomplish with the pendant button?

Dave
Productivity Software for Personal CNC Machinists
http://www.CalypsoVentures.com
zkmiller
Posts: 5
Joined: Mon Feb 25, 2013 6:19 pm

Re: Pendant button for Auto Tool Zero

Post by zkmiller »

Actually I don't want an 'auto tool zero' button. What I want that button to do is a probe-z so that I can set z-zero after a manual tool change. What you described would happen if a doOemButton(34) is called is just what happens when I press that button on the iPad. What I want is the iPad to tell MSM to do one of it's functions by pressing that button.
zkmiller
Posts: 5
Joined: Mon Feb 25, 2013 6:19 pm

Re: Pendant button for Auto Tool Zero

Post by zkmiller »

Mike (the app author) doesn't know why he put that code there. I'm looking for a suggestion of what he could put there to do what I want and other users could configure Mach to do in MSM, 1024 or any screen set.
User avatar
DaveCVI
Site Admin
Posts: 798
Joined: Mon Feb 04, 2013 3:15 pm
Contact:

Re: Pendant button for Auto Tool Zero

Post by DaveCVI »

Hi,
zkmiller wrote:Mike (the app author) doesn't know why he put that code there. I'm looking for a suggestion of what he could put there to do what I want and other users could configure Mach to do in MSM, 1024 or any screen set.
OK, the goal appears to be to hit a button on the pendant and run a user supplied script in mach. That would give a general facility that would let any button on the pendant run any script.

There is a mach API interface called "RunScript" (it was added for MSM when I first developed it). This call allows one to tell mach to run a mach script that lives on the hard disk. See the programmers ref manual for the RunScript call documentation. The only downside is that this API is only available in mach 3.43.6+ series; and a change was made to the interface in 3.43.19 - so the pendant code will need to check the running mach version to know what to do (this is in the RunScript documentation).

I'd suggest that the pendant author provide a way for the user to assign script names to pendant buttons that are intended to have user specified functions. The when the button is clicked, the pendant can send the script name to the pendant windows program, and that will make the mach RunScript call passing in the script name. Note that when I say Name here, I really mean a QFN ("Qualified File Name").

This would allow you to run any mach script from the pendant button.

Hum, since I'm helping designing this guy's pendant and mach interface, shall I be expecting a royalty check ;)

Dave
Productivity Software for Personal CNC Machinists
http://www.CalypsoVentures.com
Post Reply