There are situations in which we want to repeat a program sequence several times. In the photo above, you can see a series of holes whose positions are to be checked and the positions of the centers and their diameters are to be recorded in a measurement sheet.
This can be done automatically and very easily using the Renishaw Probe control device and by calling a program that uses subroutines (subprograms).
Here is an example of a complex program that helps us to automatically record the measured values during the automatic cycle in a text file (* .CSV).
We present the working method for OKUMA CNC milling centers. Other parameters and other measurement subprograms will be used for the lathe.
First of all, let’s remember the five types of ISO program files on the OSP numeric control:
- Main programs .MIN
- Subprogram files .SUB
- Subprogram files of the system .SSB
- Organization program files .SDF
- Library program files .LIB
- Program files constructor .MSB
We do not go into details, we are interested in the main programs and subprograms in this case application.
The main programs always start with the program number, the name starts with O and is followed by four digits, and ends with
M30. Subprogram files have the extension SUB.
They start with the name of the program and end with
RTS. To call a subprogram, during the execution of a main program, we write the command
CALL followed by the name / number of the desired subprogram.
How does it work? NC code analysis
We consider that the measurement program starts from the coordinates
Z20 X0 Y0. For work safety we will approach this position manually. We have to measure by points a circle with a radius of 50mm at a measuring depth of -15 mm on the Z axis.
Note that the probe reading subroutine automatically creates a file where all the measured data is saved, in our case the
Subroutine writing table header and file name
From the main program, a subprogram
O1000 (HEADER) is called with
CALL, which writes the header X, Y (table head), and the file in which the data is written is on the
MD1, respectively the file
VPRT=15 (Writing results in D:\MD1\A.MDF)
CALL O1000 (HEADER)
GET/PUT functions are read and write functions in an external variable file.
Probe loading and initialisation
Then the main program selects the test tool
M6 rotates the main shaft counterclockwise when looking from the part,
G15 H1 selects the coordinate system (modal in this case) and code
G56 HA Z20 compensates the length of the measuring tool on the axis Z.
G56 HA Z20
The main measurement program follows, which starts the Renishaw probe (
if VNCOM  = 0) with a half-second pause in the program
G4 F0.5. to have a guaranteed time to activate the probe.
M19 control is used on machines equipped with a main shaft orientation mechanism. The orientation function stops the main shaft at a specified angular position.
IF [VNCOM EQ 0] GOTO N11
M127 (Pornire RENISHAW)
Travel to the points on the innercircle
The next 2 groups of commands
(- + - Y PLUS) respectively
(- + - X MINUS) move the probe on the Y axis minus respectively on the X axis in addition, starting from the initial values declared in the global variables
XXI = -3 and
YYI = -3 values then transported in common variables
VC11 = XXI and
VC12 = YYI. The main program calls the measuring subprograms with
CALL OY and
CALL OX, 7 times each (
Q7) which has the effect of palpating the surfaces on the circle with the probe and then recording the values in the file point by point.
As can be seen in the graph below, we move the probe in a circle inside the measuring part with an offset of +/- 3 mm from the position X = 0 and Y = 0 (
XXI = -3,
YYI = -3) and we measure in 7 consecutive points at a distance of 1 mm between them (the explanatory drawing does not represent the proportional distances between points).
The orange dots represent the travel coordinates given by the main program, and dialing the internal measurement subroutine automatically takes the sensor to the landmark until it is reached and the coordinate data is recorded.
(-+- Y MINUS)
CALL OY Q7 PP=-PDE
(-+- X PLUS)
CALL OX Q7 PP=PDE
Point measurement subroutine
CALL OO10 is the call to an internal measuring subroutine and
PMOD = 2 PEI = PP are the parameters that are transmitted to the measuring subprogram for the different working modes with probe (Point Face, see details in the OKUMA / Gauging function manual).
OX (-+- SUB Masurare X)
CALL OO10 PMOD=1 PEI=PP (POINT FACE)
CALL O1001 PSX=VC13 PSY=VC12
PMOD=1 for Point Face measurement on the X axis
PMOD=2 for Point Face measurement on the Y axis
PEI=PP measurement quota.
Subroutine for writing values to the table
CALL O1001 is the subroutine that writes the values read in the coordinate point. X, Y transmitted by the parameters
PSY. After returning from the write subroutine, the variable VC12 (
VC12 = VC12 + 1) is incremented and the next point is measured, an action repeated 7 times with Q7 (
CALL OX Q7 PP = PDE).
After performing the measurement cycles, the main program calls
M127 which stops the Renishaw probe and the final program