Why to just say NO to setting current Tool # DRO

MSM Mill mode support
Post Reply
User avatar
DaveCVI
Site Admin
Posts: 798
Joined: Mon Feb 04, 2013 3:15 pm
Contact:

Why to just say NO to setting current Tool # DRO

Post by DaveCVI »

This comes up a couple of time a year - rather than search for this info in the posts, I've made it a sticky.

You probably got directed here after asking: "Why can't I type a tool # into the current tool DRO in MSM?

Ah, now you've done it.... you've triggered "Dave's Mach rant #23".... :(
When running Mach without MSM, if you type a tool # into the current tool # DRO, it will look as if mach has somehow magically done a tool change. The DRO now says the new T# and you think things are fine..... but they're not.

Mach3 has numerous internal logic flaws in this area and they drive one batty if you get into trying to figure out their details: "Been there, done that, have the tee shirt". Suffice it to say that if one uses the (dubious) method of changing the DRO # for current tool, that only part of mach treats it as if the tool was changed and other parts get internally confused. When this happens some mach API calls then start to return bad results - and this crashes scripts in weird ways. When I first started running into the bugs in this area, the flaws were reported; but they (like many bug reports) were not fixed.

That is not good as these bugs can leave mach is a broken state that is dangerous...

If you execute this gcode sequence:
T6 M6
G43 H6
you now have the active TLO set to the entry in row 6 of the tool table. Note how I phrased that last sentence.... I did not say "the active TLO is the value for tool 6". The distinction is important! There is no requirement in gcode that the active H# = the active T#.
Using H=T is a common convention, but it is NOT required.

This sequence is just as perfectly valid:
T6 M6
G43 H112
The active TLO value is the value from row 112 of the tool table.

Problem 1: Mach uses the tool table to store TLO values.
This is confusing. it is much more logical to store TLO values in an independent TLO table. Then you are not tempted to equate TLO table indexes with Tool table indexes. Why does mach do this? Because when that part of mach was written by Art back in the depths of mach time, Art did not understand tool offsets (as Art told me himself once upon a time). Early on, he thought there would only ever be one TLO used for one tool. .. and that assumption lead Art to decide to have "mach help the user"....
To "help", Art created the logic that when you change the current tool# DRO directly, mach tries to guess and set the TLO to "match".
The problem is that this screws up real gcode programs.

Problem 2: Part (but on all) off mach tries to short circuit tool changes when the current tool DRO is changed.

Consider this sequence:
G49 - now there is no TLO active
T4 M6 - we've changed to tool #4.. and there is STILL NO TLO ACTIVE. This is how gcode is defined to operate - and it is how the gocde part of mach does operate.

(side note: Mach took it's gcode interpreter from EMC, and EMC when implemented by NIST, implemented RS274 as it's gcode dialect. Then Mach started changing (usually without documentation) how it handles syntax and semantics for gcode - so there is no, known, up to date gcode reference for mach 3).

Now someone types "4" into the current tool DRO -
We just typed in the current tool number - you'd think that should make no difference as nothing changes right? wrong...
When you do this, Mach changes the TLO from inactive to active and sets the value for TLO from row 4 of the Tool table.

DANGER: Mach has just changed the state of the gcode interpreter behind the back of the operator and gcode programmer. This is bad news and a terrible thing (IMHO) to have done. Mach is now likely to cause a machine crash. Mach is saying that it knows better than the gcode program what the TLO value should be. B.S. :twisted:
A cnc control runs a gcode program and gcode programs are inherently state-full. Correct operation of gcode depends on the internal state of the control being what the program set it to.

Let's consider an example of using two offsets for a single tool. Think about a slitting saw. It's not uncommon to use two offsets: one to align one side/edge of the saw blade and one to align the other. So if the saw is Tool # 10, we might have one TLO value in the TLO table in entry 17 and the other in entry 18.
Now do these actions via MDI and the current tool DRO - you will crash the machine or at min cut in places you did not want....
T10 M6
G43 H17 - now we're all ready to cut with the saw....
Current tool DRO -> 10.... whoops TLO just got changed - to some value from row 10 of the tool table! :shock:

Since the TLO handling operation of mach was not going to get fixed until mach 4 (so Brian told me about 4+ years ago when this first came up), I did the only thing I could do. in MSM, I disabled the ability to type a value into the current tool DRO and I forced MSM users to use MDI to change tools.

This avoided the bugs in the mach internal code that handles current tool DRO value changes. By doing this it
a) removed the ability to use the broken parts of the mach logic associated with the current tool DRO), and
b) made all tool changes work correctly (at least wrt to TLO state and values).
When that was first done, the idea was this could be revisited when mach 4 was released (which was "any day" then, and it's still "any day now" ... 4 years later... (FYI, it was 4 years in 2013))
Ok - rant off.

What you were used to doing with the old tormach (mach 2.6 release level I think) software was using the current tool DRO.
Now at least you may have a better understanding of why that does not work in MSM.

sirbean wrote: Seeing how you have a good understanding of the G-code. If we are already in G43 , why must me add it with every tool change? Example would be this . Tool change M6T2 H2 does not work where as M6T2 G43 H2 does? You don't have to answer , but when you give me the chance to learn I will jump at the chance. Thank you again for the very quick answer to my problem and for and great answer.


You have to give the G43 command because that is how the syntax of gcode is defined.
Think of it as the G43 being the command and the H# being the parameter for the command.

Consider this sequence:
T5
<more lines of gcode>
M6

The T5 does not change the tool. T5 tells the control to prep Tool #5 to be ready to be used. That can take some time to do on older machines - it may involve rotating a tool changer to get T#5 into position to be loaded into the spindle. So the T# is often executed way before the M6. M6 is actually "load the next tool # as specified by the last T# word that was executed".
This allows parts to be made faster than doing the (simplistic and time sequential)
T5 M6

A G43 by itself should (I think) be a gcode error - no H (TLO) offset index was supplied - so the control can't know what to do.
But Mach does not error out, instead when the program says "G43", mach does "G43 H<current tool #>" - again mach is NOT doing what the gcode programmer programmed.
Yet for reasons only those with access to the mach souce code may know, H2 alone is an error.
If you subscribe to the "mach should guess" camp then maybe mach should have turned "H2" into "G43 H2" - ah but what if the current T# is not = 2 ?!? Or what if you wanted G44 instead of G43?

You can now probably tell that I'm firmly in the camp of "Computers should do what they are programmed to do and should never guess or think they know better than the programmer!". I feel particularly strong about this when talking about machines that cut off limbs just as easily as they cut off steel. I really don't like CNC machines that create "surprises".

If you want to learn the details of how most CNC controls work, I recommend that you pick up a copy of Peter SMid's "CNC Programming handbook", third edtion. It's the best reference I know for Fanuc control gcode which is the closest thing to a default standard for gcode that the industry has (each control brand has some differences). Smid's book will tell you all about weird gcode details like the ones I've talked about here.

Dave
Productivity Software for Personal CNC Machinists
http://www.CalypsoVentures.com
andy_con
Posts: 21
Joined: Fri Aug 01, 2014 1:47 pm

Re: Why to just say NO to setting current Tool # DRO

Post by andy_con »

Hi Dave,


I use version 1.1.18 of machstdmill pro, the reason being i have an old license which doesn’t work on newer versions and i think this is the last one where you can manually change the tool number in the DRO.

my machine has an ATC, in order for me to use that ATC i have to be able to manually change the tool number when i first start MSM up. I know you have your reasons why you don’t like this and why you have disabled it but i need it (not want, need) it in order to use my ATC. When i first turn my machine on and start msm the dro is always 0, but the last tool i was using could be any of them so the atc could be in position 6 for example. If i do m6 t1 it will then go to a random tool, not tool number 1 because msm doesn’t know what tool was last being used.

So if i cannot change the tool number when i first start msm i cannot use my ATC.

I want to update my license and get a newer version but i have to be able to change the dro number, can you help at all?

I have owned my cnc and msm for about 2 years now and change the dro number every single time I first turn the machine on and its never once caused a problem

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

Re: Why to just say NO to setting current Tool # DRO

Post by DaveCVI »

Hi Andy,
andy_con wrote:When i first turn my machine on and start msm the dro is always 0, but the last tool i was using could be any of them so the atc could be in position 6 for example. If i do m6 t1 it will then go to a random tool, not tool number 1 because msm doesn’t know what tool was last being used.
If you want mach (and hence MSM) to remember the last tool mounted when you shut mach down, go to mach's general config and select "Tool Selections Persistent".
andy_con wrote: So if i cannot change the tool number when i first start msm i cannot use my ATC.

I want to update my license and get a newer version but i have to be able to change the dro number, can you help at all?
Well, if you are asking if I will make the production version of MSM let you set the current tool DRO, the answer is no, for all the reasons given in the post above. The bugs still exist in mach and I have no desire to temp people into trouble by leading them to get bit by those bugs. Frankly I wish that mach had been fixed by now, but it's clear that isn't going to happen- for all practival purposes Mach3 has become unsupported software (there has not bee a single mach release in several years).

However, if you are asking: "how can I initialize the current tool DRO in case my ATC gets out of sync for some reason?". Then I would suggest that you create a customized version of MSM that has the current tool DRO on the User extension screen. That way you can easily access the DRO directly for the (exceptional) ATC error recovery cases.
andy_con wrote: I have owned my cnc and msm for about 2 years now and change the dro number every single time I first turn the machine on and its never once caused a problem

Many thanks
Andy
Alas, the fact that you have done a specific action on start up, multiple times, does not mean that all is well inside mach3. :(

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