How to make a 3 axis post processor from the HSM post processor library support 4 or 5 axis motion x

in #axis7 years ago

large.png

Issue:
You have a post processor that works on your machine but need a multi axis version.
Solution:
Most of the post processors available in the HSM post processor library are set up for 5 axis code. The 4th and 5th axis are disabled by default. To enable the 4th and 5th axis code, you need to set the right machine configuration for the ABC axis for the specific machine you want to use. The machine configuration can be found in the onOpen() function:

machine config.PNG

To activate the machine configuration, the first step is to change "if (false)" to "if (true)". Now you can go ahead and start to customize the ABC axes to your needs. Here's a more detailed explanation of the parameters.

actuator: Specifies the actuator type (ie. either "linear" or "rotational").
The default is "rotational".
table: Specifies whether the axis is located in the table or the head. The default is true for table.
axis: Specifies the axis vector as a 3-element array (e.g. "[0, 0, 1]").
[Axis rotates around X, Axis rotates around Y, Axis rotates around Z]
ex: A-axis rotating around the X-axis would be: [1, 0, 0]
offset: Specifies the axis offset as a 3-element array (e.g. "[0, 0, 25]").
The default is [0, 0, 0].
coordinate: Specifies the coordinate used in the ABC vectors (ie. "X", "Y", or "Z"). The given number will define the letter for the axis:
0 = “A”
1 = “B”
2 = “C”
Note: This is the only way to influence the axis letter for the output.
cyclic: Specifies that the axis is cyclic. Only supported for rotational axes.
Only used when a range is specified. The default is false.
range: Specifies the angular range for the axis in degrees as a 2-element array (e.g. "[-120, 120]"). You can also specify a single number to create an axis for an aggregate.
The default is unbound.
preference: Specifies the preferred angles (-1:negative angles, 0:don't care, and 1:positive angles). The default is don't care.
resolution: Specifies the resolution. In degrees for rotational actuator. The default is 0.
Note - If you only need a 4 axis setup, you can either delete the other axis beginning with "var bAxis” and “var cAxis” or you can just disable them by typing two slashes “//” in front of the line which you want to disable.

Next adjust the machine configuration assignment. Look at this line:

machineConfiguration = new MachineConfiguration(aAxis, cAxis);

This line creates a new machine configuration as defined above by using the given variables for each axis (in that case: aAxis, cAxis). You can only use the variables inside the parenthesis which are defined above. If you had removed or disabled an axis earlier for a 4 axis machine setup, remember to remove the disabled axis variable here as well.

Here are some examples of what this would look like for different machines:

4 axis setup, A rotates around X, direction is positive:
var aAxis = createAxis({coordinate:0, table:true, axis:[1, 0, 0], range:[-360,360], preference:1});
machineConfiguration = new MachineConfiguration(aAxis);

4 axis setup, A rotates around X, direction is negative:
var aAxis = createAxis({coordinate:0, table:true, axis:[-1, 0, 0], range:[-360,360], preference:1});
machineConfiguration = new MachineConfiguration(aAxis);

5 axis, B rotates around Y, C rotates around Z, directions both positive:
var bAxis = createAxis({coordinate:0, table:true, axis:[0, 1, 0], range:[-360,360], preference:1});
var cAxis = createAxis({coordinate:0, table:true, axis:[0, 0, 1], range:[-360,360], preference:1});
machineConfiguration = new MachineConfiguration(bAxis, cAxis);

Lastly, adjust optimizeMachineAngles2() depending on whether or not your machine has TCP capabilities for 5 axis simultaneous machining.

optimizeMachineAngles2(0); // TCP enabled (eg. M128, TRAORI, G43.4, G243)
optimizeMachineAngles2(1); // TCP disabled (eg. M128, TRAORI, G43.4, G243)