EMC2 is incredibly flexible. The HAL files let you wire together all the modules in any way you want. I will give you a condensed answer but if you need more detail feel free to ask.
To make a fake axis in EMC you will be removing the "motor" component for that axis (which normally would be a stepper or servo+encoder). The desired position (driven ultimately by gcode) is axis.2.motor-pos-cmd (0 is X, 1 is Y, etc). To make it appear as if some perfect motor drive is connected to Z you tie that directly to the position feedback axis.2.motor-pos-fb:
- Code: Select all
net zpos-cmd-fb <= axis.2.motor-pos-cmd => axis.2.motor-pos-fb
With that line in your HAL you can "G1 Z..." and Z will update instantly but nothing outside the machine will happen. That position is available to HAL modules as axis.2.joint-pos-fb. You need to tie that to a comparator:
- Code: Select all
loadrt comp names=laser-magic-z-comp
addf laser-magic-z-comp servo-thread
net zpos-fb <= axis.2.joint-pos-fb => laser-magic-z-comp.in0
setp laser-magic-z-comp.in1 0.0
net laser-magic-z <= laser-magic-z-comp.out
Now the net laser-magic-z is true whenever Z<0.0. This has the same effect as if you were able to edit the code for servo-thread and add a statement like "if axis.2.joint-pos-fb < 0 then laser-magic-z = true else false".
At that point you can tie laser-magic-z directly to your laser firing pin if you like. Or you can drive additional logic to do something more complex (eg OR in some other signal, or like I do, AND in the spindle control so the laser can't fire if the "spindle" is off).