I just found this really helpful hal tutorial:http://linuxcnc.org/docs/2.5/html/hal/basic_hal.html
In my my_LinuxCNC_machine.hal I already have this section
Code:
#*******************
# AXIS Z JOINT 2
#*******************
setp pid.z.Pgain [JOINT_2]P
setp pid.z.Igain [JOINT_2]I
setp pid.z.Dgain [JOINT_2]D
setp pid.z.bias [JOINT_2]BIAS
setp pid.z.FF0 [JOINT_2]FF0
setp pid.z.FF1 [JOINT_2]FF1
setp pid.z.FF2 [JOINT_2]FF2
setp pid.z.deadband [JOINT_2]DEADBAND
setp pid.z.maxoutput [JOINT_2]MAX_OUTPUT
setp pid.z.error-previous-target true
net z-index-enable <=> pid.z.index-enable
net z-enable => pid.z.enable
net z-pos-cmd => pid.z.command
net z-pos-fb => pid.z.feedback
net z-output <= pid.z.output
# ---PWM Generator signals/setup---
setp hm2_5i25.0.7i77.0.1.analogout2-scalemax [JOINT_2]OUTPUT_SCALE
setp hm2_5i25.0.7i77.0.1.analogout2-minlim [JOINT_2]OUTPUT_MIN_LIMIT
setp hm2_5i25.0.7i77.0.1.analogout2-maxlim [JOINT_2]OUTPUT_MAX_LIMIT
net z-output => hm2_5i25.0.7i77.0.1.analogout2
net z-pos-cmd <= joint.2.motor-pos-cmd
net z-enable <= joint.2.amp-enable-out
So I will need to unlink the joint.2.amp-enable-out and the pid.z.enable pin from the z-enable net before I connect my and2 gate.
so
Code:
loadrt and2
addf and2.0 servo-thread
unlinkp joint.2.amp-enable-out
unlinkp pid.z.enable
net z-enable-joint and2.0.in0 <= joint.2.amp-enable-out
net z-enable-ladder and2.0.in1 <= classicladder.0.out-03
net z-enable <= and2.0.out0
net z-enable => pid.z.enable
-Hunter