There are 2 approaches you could take. One is true 5-axis where you need to know the kinematics, and calculate the necessary values for your post. The other method is to use "plane spatial" which basically means that the tool is not tied into the kinematics of the machine, but is linked to the pick-up. This is referred to as "Cycle 19" on some controllers.
The easiest way to take advantage of the "plane spatial" is to use M128 in your code. For example:
% ISO G71
N2G00G90C0A0M126
N4T6G17S5600
N6M3
N8M23
N10G00Z1.M92
N12G00X399.Y0.M92
N14G00Y-600.M92
N16G01C-147.6589A-61.4361M126F5000.
N18M128
N20G01X441.7388Y54.1415Z-39.4795F5200.
N22G01X441.7388Y54.1416Z-93.4119F20000.
N24X439.8595Y57.1097Z-95.3244
M129 shuts off the "plane spatial" feature.
Does this make sense?
Dan
(Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)