nambass wrote:Thanks for the feedback
What do you recommend for the safe z height - will 20 be enough?
You need enough height to clear whatever may be in the path of the rapid move. Since I don't know that, I can't tell you "how much is enough".
nambass wrote:
Also do you recommend I remove the G71 and define G45?
I would remove the G71.
Re the G54 I prefer to set it explicitly - but many like to use whatever the current WC system is set to - in which case you leave out any explicit choice of WC system. G54 is the default WC system is one is not set explicitly.
BTW - I think you meant to type G54 instead of G45.
[/quote]
nambass wrote:
What is strange is that the test code was compared with code I generated using Aspire and the Asire code worked fine. And most of the initializing lines was copied line by line to make sure it is identical. Yest on my sample code I got the limit switch error.
Any machine has a fixed amount of total Z travel. Generally, Z0 is at the top of the Machine Coordinates (Note that I said machine coordinates) and the travel downward in Z is in the minus direction. So let's say you had a total travel of 1m or 1000mm in Z. The Machine coords would then be from Z=0 to Z=-1000.
Now then, the Work coordinate system is NOT the same as the machine coordinate system. They are shifted from each other. The amount of that shift is call the work coordinate offset - which is what you are setting when you set the work coordinate Z0 level.
Let's say that the WCZ0 is set to a physical level that corresponds to MCZ = -500 (i.e. in the middle of the physical Z travel limits). Now you have a total of 500mm travel between WCZ0 and the top of physical travel.
OK, now you decide that 200mm is enough clearance space to do your rapid movements.... you had better now be using a tool that is not longer than 500-200 = 300mm in length. If the tool is longer, when you ask the machine to put the tool tip at WCZ=200, you will be asking the physical spindle Z height to be above the top of MCZ0.
Look through chapter 4 and 5.2 of the MSM user manual to see pictures of how a CNC control (mach in this case) calculates conversions from MC to WC and back and how Tool length offsets impact this.
Another good source for this topic is Peter Smid's book "CNC Programming Handbook".
Dave