hello, thanks for all the help, this is the current hal excerpt. i can now turn the spindle on with m3 and m4 and off again with m5. However, my spindle is now running too fast because the config for the translation ratio is now missing.
However, when I do m19 nothing happens. when i make m19 with spindle off, the spindle turns on and turns and turns. nothing happens here anymore.
I noticed now that I'm at home that there is another # at the bottom of the sync could it be because of that?
#*******************
# SPINDLE
#*******************
# ---Encoder feedback signals/setup---
setp [HMOT](CARD0).encoder.04.counter-mode 0
setp [HMOT](CARD0).encoder.04.filter 1
setp [HMOT](CARD0).encoder.04.index-invert 0
setp [HMOT](CARD0).encoder.04.index-mask 0
setp [HMOT](CARD0).encoder.04.index-mask-invert 0
setp [HMOT](CARD0).encoder.04.scale [SPINDLE_0]ENCODER_SCALE
# Step Gen signals/setup
setp [HMOT](CARD0).stepgen.04.dirsetup [SPINDLE_0]DIRSETUP
setp [HMOT](CARD0).stepgen.04.dirhold [SPINDLE_0]DIRHOLD
setp [HMOT](CARD0).stepgen.04.steplen [SPINDLE_0]STEPLEN
setp [HMOT](CARD0).stepgen.04.stepspace [SPINDLE_0]STEPSPACE
setp [HMOT](CARD0).stepgen.04.position-scale [SPINDLE_0]OUTPUT_SCALE
setp [HMOT](CARD0).stepgen.04.step_type 0
setp [HMOT](CARD0).stepgen.04.control-type 1
setp [HMOT](CARD0).stepgen.04.maxaccel [SPINDLE_0]STEPGEN_MAXACCEL
setp [HMOT](CARD0).stepgen.04.maxvel [SPINDLE_0]STEPGEN_MAXVEL
# ---setup spindle control signals---
loadrt limit2 names=spindle-ramp
loadrt near names=spindle-at-speed,spindle-at-pos
loadrt timedelay names=spindle-active-delay
loadrt orient names=spindle-orient
#loadrt pid names=spindle-pid
loadrt mux2 names=spindle-pwm-switch
loadrt or2 count=0
loadrt not count=0
loadrt and2 count=0
loadrt offset count=0
addf spindle-ramp servo-thread
addf spindle-at-speed servo-thread
addf spindle-at-pos servo-thread
addf spindle-active-delay servo-thread
addf spindle-orient servo-thread
addf spindle-pid.do-pid-calcs servo-thread
addf spindle-pwm-switch servo-thread
addf or2.0 servo-thread
addf not.0 servo-thread
addf and2.0 servo-thread
addf offset.0.update-output servo-thread
#addf orient.0 servo-thread
setp spindle-pid.Pgain [SPINDLE_0]P
setp spindle-pid.Igain [SPINDLE_0]I
setp spindle-pid.Dgain [SPINDLE_0]D
setp spindle-pid.bias [SPINDLE_0]BIAS
setp spindle-pid.FF0 [SPINDLE_0]FF0
setp spindle-pid.FF1 [SPINDLE_0]FF1
setp spindle-pid.FF2 [SPINDLE_0]FF2
setp spindle-pid.deadband [SPINDLE_0]DEADBAND
setp spindle-pid.maxoutput [SPINDLE_0]MAX_OUTPUT
setp spindle-pid.error-previous-target true
setp spindle-ramp.maxv [SPINDLE_0]ACCELERATION
setp spindle-at-speed.difference [SPINDLE_0]MAX_ERROR
setp spindle-at-pos.difference 0.01
setp spindle-at-pos.in1 0
setp spindle-active-delay.on-delay 0
setp spindle-active-delay.off-delay [SPINDLE_0]OFF_DELAY
# ---Setup spindle at speed signals---
# orient mit motion verknuepfen
net orient-angle spindle-orient.angle => spindle.0.orient-angle
net orient-mode spindle-orient.mode => spindle.0.orient-mode
net orient-enable spindle.0.orient => => and2.0.in1
# Position vom Encoder in den pid / orient und motion schieben
net spindle-pos => spindle-pid.feedback => spindle-orient.position
net spindle-pos <= spindle.0.revs <= [HMOT](CARD0).encoder.04.position
# Encodergeschwindigkeit U/sek in den near und motion schieben
net spindle-fb-rps spindle.0.speed-in <= [HMOT](CARD0).encoder.04.velocity => spindle-at-speed.in2
# Positionsvorgabe vom orient in den pid schieben
setp offset.0.offset 1
net spindle.orient-cmd spindle-orient.command => offset.0.in
net spindle-orient-cmd1 offset.0.out => spindle-pid.command
# Drehzahlvorgabe U/min aus motion in das limit2 schieben
net spindle-speed-rpm spindle.0.speed-out => spindle-ramp.in
# Drehzahlvorgabe U/sek aus motion in das near schieben
net spindle-speed-rps spindle.0.speed-out-rps => spindle-at-speed.in1
# Wenn Solldrehzahl gleich Istdrehzahl dann aus near das bit in motion schieben
net spindle-at-speed spindle-at-speed.out => spindle.0.at-speed
# Wenn Sollpositon gleich Istpositon dann aus near das bit in motion schieben
net spindle-pos-err spindle-at-pos.in2 <= spindle-pid.error
net spindle-at-pos spindle-at-pos.out =>
net spindle-on0 spindle.0.on => spindle-active-delay.in
net spindel-on1 spindle-active-delay.out => or2.0.in0 => not.0.in
net spindel-on2 and2.0.in0 <= not.0.out
# orient und pid aktivieren
net orient-active and2.0.out => or2.0.in1 => spindle-pwm-switch.sel
net orient-active => spindle-pid.enable => spindle-orient.enable
net spindle-enable or2.0.out => [HMOT](CARD0).stepgen.04.enable
# motion gibt Signal an Encoder das beim naechsten Z Signal auf 0 gestellt werden soll
net spindle-sync spindle.0.index-enable => [HMOT](CARD0).encoder.04.index-enable #
sets spindle-sync 1
# pwm Signal entweder vom motion oder orient
net pwm-switch-in0 spindle-pwm-switch.in0 <= spindle-ramp.out
net pwm-switch-in1 spindle-pwm-switch.in1 <= spindle-pid.output
net pwm-switch-out spindle-pwm-switch.out => [HMOT](CARD0).stepgen.04.velocity-cmd