Friday, 1 May 2020

Newker 990MDCa Auto tool setting macros - SORTED

Newker tool setter macros:
The Newker controllers ship with several basic macros that claim to carry out automatic tool length and workpiece height measurement. However, I couldn't get them to do anything sensible or helpful, despite hours of trying to understand WTF the manual was on about. I ended up sort of reverse engineering the system parameters that were being referred to - and some of the other likely suspects that are shown in the rather cryptic list of system variables and parameters provided by Newker.

In the end, I found I needed to make use of some parameters that weren't referenced by the original macros and finally, after much buggerage and frustration, I seem to have cracked it. 

What was the problem, Fatty?
Connecting up the TTS (aka electronic tool setter) wasn't challenging but what I was rather hoping for was what you'd expect / hope to find on any normal CNC controller. For instance, the Centroid Acorn (CNC12) controller software has a reasonably sensible means of automatically measuring tool lengths and populating the tool table with length offsets. The frustration here being that although there were the 3 aforementioned macros, they lacked the effect I was hoping to see.

Firstly, I was hoping to be able to bang in my tools and automatically measure the length offsets and populate the tool table. Then secondly, set the workpiece height, also using the TTS. Seems that was optimistic.

Getting a macro to position the tool on the top of the TTS wasn't too difficult of course - and one of the Newker macros was 90% of the way there. The task was mainly to translate the popup text to English and add some comments so it made sense.

The second part requires the controller to use its knowledge of the current tool number to look up the relevant tool length offset from the tool table along with the known height of the TTS and apply these to the machine coordinates to determine where the bottom of the TTS is in the current WCS. 

If you've just touched off on the top of the TTS with the TTS resting on your workpiece, it should hardly be rocket science to do the basic arithmetic and then set Z0 (part origin height) on the top surface of the workpiece. But the original macro didn't seem to take the current tool length offset into account.

Given that the list of parameters and variables turned out to be full of errors (quite a lot of bollocks in there, in fact), I ended up having to do lots of trial and error work using a basic macro to see which parameters and variables changed when I made changes to the active tool, active length offset, entries in the tool table etc. And sure enough, now that I have finally got the behaviour I want, I find my working macro contains stuff that the original was missing. The original Newker macro was never going to work. Perhaps it was intended for a different machine configuration. We may never know - nor indeed care.

What you got, Meester Peeg?

The first macro enables you to populate the tool table with tool length offsets. All it does is touch the tool off on the TTS, then back off slowly until the signal is released. At this point, you have a measure of the length of that tool relative to the machine coordinate height. Generally on my machine the Z height in machine coordinates are going to be something like zero when it's at the home position. So the difference is simply the tool length offset.

Here's the tool length offset measurement macro, M887 (aka UserProgram7):

MESSAGEBOX(Insert the next tool and position it above the TTS);
MOVE(G90,F#386,Z#382);             // Move to machine coordinate Z#382
IF (+#387) THEN;                   // Setter is in "fixed" position
STATUSINFO(Moving to tool setter location);
MOVE(G90,F#386,X#380,Y#381);       // Move to machine coordinate X#380, Y#381
ENDIF;                             // 
// Now seek the tool setter
STATUSINFO(Seeking tool setter);
MOVE(G90,F#383,Z#388,W+25);        // Move to Z#388, stop once X25 goes high
PAUS160;                           // Pause for 160ms
IF (-X25) THEN;                    // Error - didn't see X25 go high....
MESSAGEBOX(Fault: The tool setting signal wasn't detected!);
ERREXIT;                           // End macro due to error
ENDIF;                             // 
// Now back off and release the tool setter
STATUSINFO(Backing off from tool setter);
MOVE(G90,F#384,Z#382,W-25);        // Move towards Z#382 (Zmax) until X25 goes low
IF (+X25) THEN;                    // Error - didn't see X25 go low again
MESSAGEBOX(Fault: The tool setting signal wasn't released!);
ERREXIT;                           // End macro due to error
ENDIF;     
// Tool is now touched off on tool setter - you need to "redeem" this tool length in the table
MESSAGEBOX(NB: Now REDEEM the CURRENT tool offset in the tool table!!!);
RETURN;

Once this has been run, you need to press the "Redeem" button which takes you into the tool table, then press "A" to save the current MCS height as the offset for this active tool. If you previously told it which tool number you are measuring (G43 H* etc), it is clever enough to assume that is the offset you should be storing.

Here's the macro for setting the workpiece height. I called it M888 (aka UserProgram8):
Once the tool table has been populated with the tool length offsets for the tools you plan to use, you can use any of them to set the workpiece height. It already knows the height of the TTS (stored in parameter #389). The macro assumes the TTS is sitting on top of the workpiece, under the tool. Obviously you need to tell it which tool number it is working with - or more accurately, it needs to know which tool length offset eg H01 etc. For this, you need to issue a G43 command eg "G43 T2 H2" for Tool 2. Then it can apply the appropriate length offset. 

STATUSINFO(Find TTS with CURRENT tool and set WCS Z0 at TTS base);
MESSAGEBOX(Select tool using G43 Hx. Position TTS above work surface)
MOVE(G90,F#386,Z#382);           // Move to machine coordinate Z#382
IF (+#387) THEN;                 // Setter is in "fixed" position
STATUSINFO(Moving to TTS location);
MOVE(G90,F#386,X#380,Y#381);     // Move to machine coordinate X#380, Y#381
ENDIF;                           
// Now seek the tool setter
STATUSINFO(Seeking TTS);
MOVE(G90,F#383,Z#388,W+25);      // Move to Z#388, stop once X25 goes high
PAUS160;                         // Pause for 160ms
IF (-X25) THEN;                  // Error - didn't see X25 go high....
MESSAGEBOX(Fault: The TTS signal wasn't detected!)
ERREXIT;                         // End macro due to error
ENDIF;                           
// Now back off and release the tool setter
STATUSINFO(Backing off from TTS);
MOVE(G90,F#384,Z#382,W-25);      // Move towards Z#382 (Zmax) until X25 goes low
// Tool is now touching TTS - need to subtract setter height to find Z0
MESSAGEBOX(Now setting WCS Z0 at BASE of TTS with CURRENT tool!);
#385=(#(1000+(#4111)))/1000;     // #4111 is current tool length offset NUMBER
                                 // So #1002 is the VALUE of H02 in um etc
                                 // And #389 is height of TTS
#51=#385+#389;                   // #385+#389 is top of TTS in current WCS
SETWK(Z#51);                     // SETWK(Z..) sets the current WCS Z coordinate
RETURN;                          // Phew!

If all went well, the current WCS height coordinate displayed on the DRO should be the same as the height of the TTS (as stored in parameter #389). If you remove the TTS and jog the tool down to the surface of the workpiece, it should touch at around Z0 in the current WCS (G54 or whatever). 

Once this WCS height is established, you can change the final position of the WCS Z0 by pressing the "Setup" button and typing in a height value for the Z axis, if you want the WCS origin set at a different height, such as the bottom of the workpiece.

Anything else?
Bear in mind that every time the height of the workpiece / table / knee is moved, the basis for measuring the offsets will change. As long as you don't change any of the tools or need to add any new ones, this isn't a problem. However, if you need to add or change any tools, the whole tool table will need to be remeasured. 

This is a royal PITA but I don't see any way to write back the tool length offsets, as the relevant parameters are read only. And without being able to write to the length offsets from within a macro, I can't compensate for any vertical movement relative to the machine coordinates between measurements. Bugger. 

It may be that there are parameters that CAN be written to but if so, they aren't mentioned anywhere and I can't see anything helpful in any of the other examples or macros.

Bollocks - at least I can now move on and - who knows - possibly even consider some form of machining on the damned thing? After all, it is supposed to be a machine tool, not some infernal Chinese torture puzzle.

No comments:

Post a comment

4th axis action - wrapped 2D Adaptive test

Let's try this thing out! There are only 3 simultaneous 4th axis operations available in Fusion (2D Adaptive, 2D Contour and 2D Pocket...