Hi MD. If you're using the homing kit and home the A axis I wouldn't expect the 4th axis to rewind any further than the homing sensor (I don't use the sensor so I can't test this assumption). However if you enter A0 it will continue to rewind until the initial angle has been covered i.e. if the A DRO reads 3600 degrees the axis will rotate 10 times until A0 is reached. The homing switch should play no role in this.
The G-code I provided in post 7 should eliminate the unnecessary whole rotations, leaving no more than a half rotation to zero.
Code:
G10 L20 P[#5220] A[#5423-360*ROUND[#5423/360]]
The #5220 isn't the most important parameter here. It simply represents the current coordinate system i.e. '1' for G54, '2' for G55 etc. If you're working in G54 you could simply use a '1' instead:
Code:
G10 L20 P1 A[#5423-360*ROUND[#5423/360]]
The parameter #5423 represents the current A position. The equation is actually very simple. If the current A position is say 3636 degrees (10 full turns plus 36 degrees) the division on the right would divide this value 3636 by 360 giving 10.1. Then ROUND rounds to the nearest whole number giving 10 exactly. Multiplying this rounded result with 360 gives 3600 degrees which is subtracted from the original value of 3636 to give
36 degrees. G10 L20 sets the A position to the result of this calculation i.e. 36 degrees - just like entering this value in the DRO. The A axis hasn't moved yet. Commanding A0 now only needs to rotate the A axis by 36, instead of 3636 degrees.
If this code is used in a subroutine or a post processor you'll have to ensure that the current coordinate system is used - which is where the parameter #5220 comes in handy.
If you enter a large number in the A DRO and type or copy/paste this line of code in the MDI you should see what happens.
I hope this has clarified something (a little?).
Unfortunately I haven't found a way of automatically adding a line of code like this within a Sprut program without modifying the post. The Auxiliary INSERT almost works, but it doesn't add the line number.
Step