Author Archives: David

Setting the Workshift (Fanuc CNC Lathe)

Category : Beginners Fanuc Turn

Setting the Workshift


This article is about the Workshift on a CNC Lathe with a Fanuc control.

As a beginner one of the first things you will need to learn is how to set the workshift.

The workshift is an adjustable figure that tells the control where the work zero is.

It defines the relationship between the turret and the workpiece.


So we have a programme for our part on a our CNC Lathe. Let’s assume this programme is perfect with no errors.

But at the moment it’s just a part floating around in space.


You have measured the tools using cut and measure or a tool presetting arm. You also need to tell the machine the radius of the cutting tool tip and its virtual nose position.

Tool tip radius and virtual nose

So now all the machine needs to know is where the workpiece stock is. That’s where the workshift comes in.

WorkshiftTool Presetting Arm

The setting of the workshift will vary from one machine to the next but just think about this logically.

1 You have a program.

2 Your machine knows where your tools are in the X and the Z axis.

So now your machine needs to know where the workpiece is in order to complete the jigsaw puzzle.

To do this we need to set the workshift.

With regards to the X axis this never changes because the centreline of the machine is always the same.

Just Worry About Z

Sooooo this is just about Z.

The way we do this is to effectively tell the machine where the tools are in relation to the workpiece.

First you need to call out a tool and its offset.

T0101 (Call tool one and offset one)

You could do this in MDI

Fanuc MDI Screen calling tool one and offset one

Bring the tool to the front face of the component. If you want to machine metal from the front face then you would position the tool slightly behind the front face.

You could even start the spindle and machine the front face. That way you will know you took off the right amount of metal.

Machine the front face when setting workshift

(You can use any tool for this provided it has been measured and you call its offset)

Cursor to the Z underneath (MEASUREMENT) on your workshift screen.


Type in 0 then press INPUT


The Z SHIFT VALUE will change.

If you want to you can input zero into shift value on the left to reset it before you start.

I like to do this when I am setting the workshift because you can clearly see the new figure when it goes in.

My screenshots are from newer Fanuc controls. Even if yours is an old banger it will be much the same.

New CNC Machines

Be very careful not to set anything in the X figures because it will completely mess up your X axis position. This could leave you in deep shit.

It is always good to note the X figure even if it is set to zero.


This X figure can be used to set the centre-line for your drills and centre cutting tools so it may not be zero.

Mine is set to X270. which is the centreline of my machine. So if I am using a drill or any tool that works on centreline then I only need put zero in the X offset.

Be careful before changing this if you have a tool measurement arm as it will alter all your X figures. You will need to re measure all of your tools.

In the table above tool 9 is a drill and because my workshift is set to the centreline (X270.) I would input zero in the X offset geometry.

Otherwise you would have a standard figure that you put into X for all your centreline tools.

On my machine it would be 270. but it usually ends up at something close like X270.106 which is hard to remember.

I often see this figure written on the side of the machine in felt tip pen for operators to remember.

If you do have a figure in the X it is really important not to change it. I would recommend using G10 in all your programmes. That way you can always be sure this figure is correct.

(G10 is a way of entering your offsets and workshift from the CNC Program)

In the program above it is the G10 P0 X270. line. The P0 tells the control to write to the workshift.

This way even if you fuck up the X position the control will just ignore you and keep writing the correct figure in at the beginning of the program.

Please note I am not putting anything in the Z for the G10 as I don’t want this updating. You can do this if you want, but you need to remember that you can now only alter the Z from the G10.

Testing The Workshift

Once your workshift is set you are ready to prove out your part.

You can test the workshift in MDI if you wish.

G0 Z0;

Make sure to override the rapid moves (not 100%) and look at


If when you run your program the front face of your part does not clean up or you feel you are taking too much off then the workshift will need to be altered.


Changing the workshift moves all the tools together. I does not change the relationship between the tools.

How to Alter The Workshift


Always use + INPUT as this will add the value to the present value.

If you use input it will replace the figure and now your in trouble.

How to Adjust workshift

Be Careful Not to Alter X

Thanks for watching and reading

If you have been affected by any of the issues in this post or need CNC Counselling then contact me.

Or call us

If you want to learn to program CNC Milling Machines

Look no further Contact CNC Training Centre

Siemens Sinumerik Training


Using U To Program Taper CNC Lathe

Category : Fanuc Turn Haas Turn

I recently wrote an article on the use of incremental U and W on a CNC Lathe for incremental programming.

I must be honest I didn’t have that many creative uses for it.

Anyway when I posted it on Linkedin I did get some interesting replies and comments. I was surprised to see how many people do use incremental U and W.

incremental U


About a year ago I was working at Gardner Aerospace and we were struggling to get rid of a taper on a shaft we were machining.

Not a particularly difficult job other than this pesky taper we kept getting.

It was something like 30mm diameter by about 140mm long. We were making it on a new Haas ST lathe we struggled to hold the size which was about plus or minus .02mm and were getting a taper too.

I noticed that when we programmed a taper it was easy to make a mistake.

incremental U

The above program would take the size .015 less.

incremental U

When it came to changing the taper again the calculation had to be made. I suddenly had a brainwave and realised we could program it in incremental by using a U figure.

incremental U

The great thing about doing this is that you can see exactly what taper you have and it’s really easy to modify. 

The other thing is that the figure is always going to be small so it’s easy to spot mistakes.

I got so excited I even made a video.

Thanks for watching and reading

If you have been affected by any of the issues in this post or need CNC Counselling then contact me.

Or call us

If you want to learn to program CNC Milling Machines

Look no further Contact CNC Training Centre



G74 Drilling Cycle With G96

Tags :

Category : Fanuc Turn Mazak Turn

G74 Drilling Cycle With G96

G74 Drilling Cycle with G96.

On a CNC lathe G96 is used for most machining. It was amazing in the old days when we suddenly discovered G96.

Because you are using a constant surface speed the metal cutting is consistent so you get a great finish.

The Black Art Of CNC Programming

CNC Programming was a bit of a black art back in the old days and generally speaking we used G96 for everything except for screw cutting and drilling holes on centreline (G74 Drilling Cycle).

When CNC Programming a drilled hole you would always use G97, (this means the speed is in RPM).

If you were to program for example G96 S50 M3 and then rapid to X0 and Z3. ready to drill a hole the machine would just go to its maximum RPM. This would be the speed you set in your G50. (The G code used to restrict the speed.)

Oh by the way that 50 meters per minute is for a B & Q drill.

Don’t get me wrong I love B & Q products but HSS drills are not for grown up engineers they are great for metal work classes at school and making a coffee table for the misses but it’s time to join the big boys and spend some money.

I Digress

Anyway the machine would calculate the speed at its current diameter. So at zero the spindle would always be flat out.

So you could say G96 is pretty useless for a drill.

But you would be wrong!!!!!!

Take a look at this bit of code.

G74 Drilling Cycle

The idea is to send the machine to the drill diameter. Because the machine is in G96 it calculates the correct speed. When you then issue G97 it fixes the speed. Now when you move to X0 it has the correct speed.

Let The Machine Do What It’s Good At

Mmmmmmm… So all you need to do is send the drill to its diameter and the machine does the arithmetic.

Let the machine do what it’s good at and you do what you’re good at.

What are you good at by the way?

Threading is the same if you were machining an M20 thread at 100m/min calculate the surface speed.

(This is the quickest way I have seen)

20/314.2 =.06365

100/.06365 = 1571 RPM

You could do the same thing let the machine do it’s shit.

Rapid to the diameter of the thread then program G96

G0 X20. Z5.;
G96 S100 M3 (Start Spindle at 100 metres per min);
G97 (This will swap to RPM and clamp the speed at the correct RPM);
G76 P010060 Q20 R.02;
G76 X16.93 Z-25. P1534 Q485 F2.5;


So with this bit of code you can get the machine to calculate your speed.

Thanks for watching and reading

If you have been affected by any of the issues in this post or need CNC Counselling then contact me.

Or call us

If you want to learn to program CNC Milling Machines

Look no further Contact CNC Training Centre



Power Up Fanuc Parameter 3402

Category : Fanuc

Messing With Parameters Can Be Fatal!!!!!

Power Up Fanuc Parameter 3402. To change parameters you need to go to the setting screen in MDI. Now put a 1 in the parameter write box.

Today we are going to change the parameter that sets all the modal G codes when you first turn on your machine. This is often known as the wake up state.

Power Up Fanuc Parameter How it works?

When you switch on your machine certain G codes will be active. But what G codes are active?

Well….  they are whatever you set in this parameter.

Imagine you just typed in X50. Y50. in MDI and pressed cycle start. Would it rapid, feed or try and go around in an arc?

In parameter 3402 the different bits set the G codes that are active when you first turn on your machine.

#0 G01 (Set to zero you wake up in G00 set to 1 you wake up in G01)

#1 G18 (Set to zero you wake up in G17 set to 1 you wake up in G18)

Power Up Fanuc Parameter

Isn’t it just great to sort out those annoying problems?

Things like the machine waking up in incremental can be a potential disaster.

Other Parameters Of Interest

3203 Clear MDI Screen

3204 Unlock Program 9000 to 9999 and 8000 to 8999 to Edit

3401 Calculator Type Decimal Point or Integer

6005 Allows the Use of Local Subroutines (Newer Control)

6050-6059  Allows you to Call a 9000 series Program with a G Code

6080-6089 Allows you to Call a 9000 series Program with An M Code

5003 Retain Geometry when you Press Reset

8134 3453 allows you to use ,R and ,C (Rads and Chamfers)

That’s it away you go.

Oh just one other thing before you go off and cripple your machine forever.

Do yourself a favour take a picture of the screen before you change a parameter. If you ain’t got a camera then you must have a piece of paper.

Even better back everything up on a regular basis.


If you have been affected by any of the issues in this post or need CNC Counselling then contact me.

Or call us

If you want to learn to program CNC Milling Machines

Look no further Contact CNC Training Centre

D01 END1 Macro How does it work?

Category : Macro

D01 END1 How does it work?

Someone said to me the other day to “why don’t you just do one”. In fact people often say this to me, even complete strangers. I was forced in the end to google it.

Anyway having researched it at length I can safely say it’s not a term of endearment. It actually means “fuck off”.

Now in macro programming it all takes on a different meaning. If you ever programmed computers back in the 1980’s then you’ll remember BASIC

(Beginner’s All-Purpose Symbolic Instruction Code)

This was a computer language very similar to Macro programming. Mmmmm not come far have we?

Anyway that’s where this language originates. Often known a Spaghetti programming. A pejorative phase to describe this type of programming used mainly because you can be hop skipping and jumping all over the program with GOTO statements and all sorts of confusing shit.

You have to be very disciplined with this type of programming and add loads of explanations. You must space the code out in neat chunks.

Although crude, macro programming has some great uses.

Oh and it adds real functionality to CNC programming.

D01 END1 What is it then?

This is a kind of loop and is best explained in an example. My example is a macro that will drill a grid of holes. The user states the spacing in X and the spacing in Y. Also the number of holes in each direction.

Now I know the smart arses are saying “fuck me, doesn’t he know there are cycles that already do this, yawn yawn”

Well actually I do.

I also know that the wheel was invented 3500 B.C. but the wheel can be used for demonstration which is what I’m about to do.

Demonstrate grids that is not wheels.

First of all this is just drilling one line of holes I’ll then go on to complicate the shit out of it by doing a grid.

First of all I drill one hole at X0 Y0, or whatever I want as my first  position. The G202 has two parameters W and X.

W is the number of holes along the X axis.

X is the width between holes.

So this will give me 6 holes 10mm apart along the X axis.

I have aliased G202 to program O09011 which is my macro. Here’s how you do it in case you forgot.

This is program O9011

D01 END1

The line WHILE [#23 GT 1] DO1

Tells the control that as long as #23 is greater than 1 to go around the loop.

It’s now looking for END1 which corresponds to D01 and it whizzes around the loop.

You can have loads of these.

The END must match the D0.

It could be D02 & End2 the choice is yours. The D02 is just the name it’s nothing to do with how many times you go around the loop.

Just make sure you don’t get mixed up else you will have a nightmare trying to sort them out.

Each time it goes around the loop it checks the condition in the statement.

The line #23 = #23 -1 will reduce #23 by one each time it goes around the loop. (Eventually #23 will not be greater than 1 and the control will escape the loop and carry on)

The next line moves X incrementally (G91) by the amount stored in #24 (this was the X value you put in the G202). It drills a hole because the G81, stated in the main program, is still active.

The control is then put back into G90 (Absolute) as a safety measure.

Read this article for more on G and M code aliasing.

Now Lets Complicate Things

OK so you understood that?

Good now lets completely fuck it up.

D01 END1, This is the complete program.

First of all I drill one hole at X0 Y0, my first position same as above.

The G202 now has four parameters D,W and X, Y

D is the number of rows in Y.

W is the number of holes in X.

X is the width between holes along the X axis.

Y is the depth between holes along the Y axis.

So this should give me 6 holes 10mm apart in the X axis and 6 rows of holes 10mm apart in Y.

(A grid of holes)


More D0’s and Ends

Now we have D01 END1 inside D02 END2.

D01 END1

So……… the D01 END1 is the rows of holes across (X Axis).

The D02 END2 s the number of rows (Y Axis).

Now lets break it all down.

O09012 (Drill Grid of Holes)

#100= #23 (Store W Value)

The line above puts #23 which was the W value into #100. This is because we are going to need it again when we go round the D01 END1 again. This loop reduces it down each time it goes around, so it needs to be restored.

WHILE [ #7 GT 0 ] DO2 (DO LOOP)

The line above is the condition that allows it to keep going around the loop as long as #7 is greater than zero.

WHILE [ #23 GT 1 ] DO1 (DO LOOP)
G91 X#24 (Drill a Hole)

The D01 END 1 above is one row of holes once the condition is satisfied it escapes the loop.

#23= #100 (Restore W Value)

Remember we saved #24 in #100. you need to set this back to it’s original value because the loop above reduced it down to zero.

#24= – #24 (Reverse X)

This is to make the X move in the opposite way to make the path zig-zag. This will make it toggle between plus and minus.


The above is the counter for the rows. Number of rows was in D (#7) so wee need to reduce this number as we go.

IF [ #7 EQ 0 ] GOTO1
G91 Y#25

This little bit of code above is for when we get to the last row of holes we don’t want the Y move as we have completed the grid.



It looks like this.

So there you have it. I hope you now have an understanding of how these loops work.

This kind of programming is notoriously difficult to get your head around. Once the penny drops it gets easier.

The problem is our brains are not too good at thinking about two things at the same time.

It’s called spaghetti programming for a reason.

My advice with all programming is to break the program down into small manageable chunks. Make simple little programs of each part and prove them till they work. You can the piece your program back together.

I hope you have enjoyed reading this article.

Thanks for watching and reading

If you have been affected by any of the issues in this post or need CNC Counselling then contact me.

Siemens 828 840 Sinumerik Training

Or call us 

If you want to learn to program CNC Milling Machines

Look no further Contact CNC Training Centre



WP to LinkedIn Auto Publish Powered By :