What's new
What's new

Macro for Selecting Holes, or Features on a PCD to Machine

angelw

Diamond
Joined
Sep 10, 2010
Location
Victoria Australia
Hello All,
On another Forum, a question was asked as to how to select only certain holes to machine on a PCD. Most of the answers were quite convoluted, requiring Ones, or Zeros to be hand registered in Nonvolatile Variables with the resulting Macro being much longer than required and rather cluttered.

For those interested, following is my approach for such a problem:

A single arguments could be passed to the Macro in the form of pseudo Binary. However, as Macro Variables for most controls are Decimal Numeric and not Binary, a number with Zeros as the most significant numbers in the argument being passed will be incorrectly interpreted. For example, 00110101 passed as an argument, will be interpreted as 110101. The EXP Macro function could be used, but the following, in my opinion, is an easier method to understand.

If a number such as the following is passed to a Macro:

13426587

it could be decoded to specify the order in which, holes 1 to 8 are to be machined, or with the following number:

13578

which numbered holes from 1 to 8 in the PCD are to be machined.

The total number of holes in the PCD would also be passed so as to calculate the incremental angle between successive holes.

Following is an example:

G101 A13578 (OTHER ARGUMENTS RELATING TO THE MACHINING CYCLE WOULD ALSO BE INCLUDED HERE)

O9010
(#1 = 13578 - NUMBER PASSED TO THIS MACRO TO SELECT HOLES TO BE MACHINED)

#2 = 1 (COMPARISON NUMBER)

(DECODING THE NUMBER STARTS HERE)
WHILE [#2 LE #1] DO1
#2 = [#2 * 10]
END1
#2 = #2 / 10 (THIS WOULD BE THE DIVISOR)

#3 = 1

WHILE [#2 / #3 GE 1] DO1
N1 #4 =FIX[[FIX[#1 / [#2 / #3]]] / 10]
N2 #5 = [FIX[#1 / [#2 / #3]]] - #4 * 10
(DECODING THE NUMBER ENDS HERE)
--------------------------
PCD HOLE POSITIONING AND MACHINING GOES HERE
-------------------------
END1

In the above example, each successive loop of the DO1 Loop would return the following results for Local Variable #5:

1
3
5
7
8

The above individual numbers are used to multiply the incremental angle between the points on the PCD to gain the angle from a specified Start Angle (Zero Degrees is 3 o'clock). Once the angle of the specified numbered point of the PCD is known, COS and SIN functions are used to calculate the X and Y coordinates respectively of the numbered point.

Sequence numbers N1 and N2 in the above code example have only been used to identify these blocks for explanation. The MOD Function is not included in all Machine User Macro Executables. Accordingly, Blocks N1 and N2 have the equivalent function to:

#4 = [FIX[#1 / [#2 / #3]]] MOD 10

This simple, little Macro could have uses in other applications. Some time ago I wrote a Macro for measuring the Tool Length of particular tools. The Macro could be used to measure the Tool Length of one tool per execution of the Macro, or a number of Tools within a range; Tool 6 to Tool 18 for example. In this iteration, the Macro would successively call each of the Tools between 6 and 18 inclusive and go through the the process of measuring and registering the Tool Length Offset. The limitation of this Macro was that the Tools to be measured had to be in a consecutive sequence.

With the inclusion of the above routine, any sequence of Tool Lengths to be measured could be specified by passing the number and order in which they are to be measured, to the Macro, as shown in the following example:

G101 A13578 (NUMBER AND ORDER OF TOOLS TO HAVE TOOL LENGTH OFFSET MEASURED)

O9010
(#1 = 13578 - NUMBER PASSED TO MACRO TO SELECT TOOL NUMBER OF TOOLS TO MEASURE)
#2 = 1 (COMPARISON NUMBER)

(DECODING THE NUMBER STARTS HERE)
WHILE [#2 LE #1] DO1
#2 = [#2 * 10]
END1
#2 = #2 / 10 (THIS WOULD BE THE DIVISOR)

#3 = 1
WHILE [#2 / #3 GE 1] DO1
N1 #4 =FIX[[FIX[#1 / [#2 / #3]]] / 10]
N2 #5 = [FIX[#1 / [#2 / #3]]] - #4 * 10
(DECODING THE NUMBER ENDS HERE)
G65 P9011 T#5 (CALL TOOL LENGTH MEASURE MACRO - PASS NUMBER OF TOOL TO PROCESS)
END1

Regards,

Bill
 
Last edited:








 
Back
Top