Tuesday 7 May 2019

Newker Macros - crash course

Why the macros?
It all sounded rather straightforward last time round. The macros for setting tool length offsets and the top of the workpiece look reasonable and seem to do something. But what exactly?

What I want them to do is to be able to populate the tool offsets and possibly even set the WCS zero in Z. However, after a fair bit of buggerage (aka trial and error) I think I have managed to demonstrate to myself that the M880, M882 and M883 macros are actually of rather limited usefulness.

These are what Newker describe as "user defined" macros, so fairly simple to access and indeed to modify. There's no sensible means of doing so on the Newker controller itself, so you have to use the "backup" function to save them to USB, edit them on a PC using a text editor (that doesn't introduce and formatting characters) and then "restore" them back to the controller. Nothing too challenging there, although it is a bit of a PITA.

Rather like G-codes, this wasn't something I'd planned on getting into right away but suspected I might tackle at some later date. But without sensible probing and tool length setting functions, life could be rather painful. 

Let's have a look at what we've got here, starting with the 3 main macros which seem to be something to do with the tool setter ie most likely for tool lengths and work heights.

These are the user programmable macros that some by default:

M880 macro (set current WCS Z0 at bottom of tool setter):
STATUSINFO(Automatic tool setting operation is being performed!);
IF (+#387) THEN; // In auto mode
MOVE(G90,F#386,Z#382); // Move to Z#382 height
MOVE(G90,F#386,X#380,Y#381); // Move to X#380, Y#381 position
ENDIF; // 
#50=#5023; // Save Z machine coo
MOVE(G90,F#383,Z#388,W+25); // Move to Z#388, stop once X25 valid
PAUS160; // Pause for 160ms
IF (-X25) THEN; // Error - didn't see X25 go invalid....
MESSAGEBOX(Fault: The tool setting signal cannot be detected!)
ERREXIT; // End macro due to error
ENDIF; // 
MOVE(G90,F#384,Z#1929,W-25); // Move to Z#1929 until X25 goes invalid
IF (+X25) THEN; // Error - didn't see X25 go invalid
MESSAGEBOX(Fault: The tool setting signal cannot be released!)
ERREXIT; // End macro due to error
ENDIF; // 
#51=#385+#389; // Save Z (WCS) + height of setter
SETWK(Z#51); // Set WCS height of setter
MOVE(G90,F#386,Z#50); // Return to original #5023 Z position
MESSAGEBOX(Automatic tool setting is successful!)
RETURN;

My comments, Chinese messages translated to English etc.

M882 (automatically touch off on top of workpiece and stop there):
STATUSINFO(Automatic tool setting Z-axis drop setting!);
IF (+#387) THEN; // In Auto mode
MOVE(G90,F#386,Z#382); // Move to Z#382 height
MOVE(G90,F#386,X#380,Y#381); // Move to X#380, Y#381 position
ENDIF; // 
MOVE(G90,F#383,Z#388,W+25); // Move to Z#388 until X25 goes valid
PAUS160; // Pause for 160ms
IF (-X25) THEN; // Error - didn't see X25 go valid
MESSAGEBOX(Fault: The tool setting signal cannot be detected!);
ERREXIT; // End macro due to error
ENDIF; // 
MOVE(G90,F#384,Z#1929,W-25); // Move to Z#1929 until X25 goes invalid
IF (+X25) THEN; // Error - didn't see X25 go invalid....
MESSAGEBOX(Fault: The tool setting signal cannot be released!);
ERREXIT; // End macro due to error
ENDIF; // 
#50=#5023; // Save current Z coord to #50
MESSAGEBOX(Manually move the tool tip to the upper surface of the workpiece and run the M883 command!)
RETURN; // Told to run M883 now:

M883 (manually touch off on top of workpiece, then store setter height "gap"):
#389=#50-#5023; // Stores height of setter in #389
MESSAGEBOX(The automatic tool setting Z axis drop setting is completed!)
RETURN;

So in fact, despite M880, M882 & M883, there's no obvious means of:
  • Acquiring tool length offsets
  • Adding tool lengths after changing work or knee height
All we have there is setting the current WCS zero on the top surface of the workpiece, based on touching off on the tool setter Sitting on the workpiece) and subtracting the tool setter height from the current Z coordinate. M883 uses manual touch off to determine the height ("gap") of the tool setter.

M884 (find mid point of workpiece in X axis):
#52=#50-555;         // 
IF (+#52) THEN; // 
#50=555;         // 
#51=#5021; // 
ENDIF; // 
IF (-#52) THEN; // 
#53=#5021; // 
#53=#53-#51; // 
#54=#53/2; // 
#50=0; // 
SETWK(X#54);          // 
MESSAGEBOX(X axis mid point set!)
ENDIF;                             // 

RETURN;

M885 (find mid point of workpiece in Y axis):
#52=#50-555;         // 
IF (+#52) THEN  // 
#50=555;          // 
#51=#5022; // 
ENDIF; // 
IF (-#52) THEN;         // 
#53=#5022-#51; // 
#54=#53/2; // 
#50=0; // 
SETWK(Y#54);          // 
MESSAGEBOX(Y axis mid point set!)
ENDIF;          // 
RETURN;

Newker's macro language:
Somewhat disappointingly perhaps, Newker have chosen to use some obscure or unique dialect. There are distinct similarities with mainstream CNC macro languages, such as Fanuc (Macro B), Okuma (Task 2) or Fadal (Macro) but there are many differences. Fanuc Macro B seems to be closest but you'd be disappointed if you thought you'd be able to create Newker macros coming from from a Fanuc background.

Argument passing:
G65 argument passing is how arguments are passed to macros. 
eg "G65 PXXXX Ln A B C", where A, B, C etc are the arguments passed.
You can't simply pass an argument such as "H5" to a macro and expect to use it by referring to the "H" variable directly within the macro. Instead, you need to know that argument H is variable #6. You need to look up the argument variable number from the following table - which is naturally different to the dialects above.
A 0
B 1
C 2
D 3
E 4
F 5
G N/A - reserved for G codes
H 6
I 7
J 8
K 9
L N/A - call times
M 10
N N/A - reserved for line numbers
O N/A - reserved for program numbers
P N/A - reserved for program numbers
Q 11
R 12
S 13
T 14
U 15
V 16
W 17
X 18
Y 19

Z 20

Next - look at developing a macro that actually does something useful...

No comments:

Post a Comment

Final assembly and test of the spindle nose adaptor - RESULT!!

After the recent distraction caused by the 3D scanner, resurrecting the 3D printer and buggering about with the throttle bodies for my Honda...