# spin.hal # ======== # swap the encoder into siimple counter mode setp hm2_7i95.0.encoder.05.counter-mode true setp hm2_7i95.0.encoder.05.scale -60 # output is 95.0.encoder.05.velocity-rpm # choose the source of the wanted rpm so the mpg can control things # ================================================================= loadrt sspindle count=1 addf sspindle.0 servo-thread net spin-rpm spindle.0.speed-out-abs sspindle.0.req-rpm # requested rpm net spin-mpg sstep.0.rpm-out sspindle.0.mpg-rpm # mpg rpm net spin-subv sstep.0.subvert # mpg mode net spin-subv sspindle.0.use-mpg # to sspindle net spin-subv hm2_7i95.0.ssr.00.out-03 # to mpg lamp # ssprindle.0.out-rpm # output (float) # Simple rpm to PWM # ================= # convert rpm to 0 to 1.0 # 10V is 1500rpm = 1.0 # hence the gain is 1/1500 = 0.0006666666 # loadrt scale count=1 # addf scale.0 servo-thread # setp scale.0.gain 0.0006666666 # multiplier # net spin-0rpm sspindle.0.out-rpm => scale.0.in # input # net spin-speed-to-DAC scale.0.out => hm2_7i95.0.pwmgen.00.value # output # as above but non-linear # ======================= loadrt lincurve personality=16 # number of points addf lincurve.0 servo-thread setp lincurve.0.x-val-00 0 # X is input setp lincurve.0.y-val-00 0 # Y is output setp lincurve.0.x-val-01 100 setp lincurve.0.y-val-01 0.006 setp lincurve.0.x-val-02 200 setp lincurve.0.y-val-02 0.019 setp lincurve.0.x-val-03 300 setp lincurve.0.y-val-03 0.028 setp lincurve.0.x-val-04 400 setp lincurve.0.y-val-04 0.037 setp lincurve.0.x-val-05 500 setp lincurve.0.y-val-05 0.046 setp lincurve.0.x-val-06 600 setp lincurve.0.y-val-06 0.054 setp lincurve.0.x-val-07 700 setp lincurve.0.y-val-07 0.064 setp lincurve.0.x-val-08 800 setp lincurve.0.y-val-08 0.073 setp lincurve.0.x-val-09 900 setp lincurve.0.y-val-09 0.083 setp lincurve.0.x-val-10 1000 setp lincurve.0.y-val-10 0.093 setp lincurve.0.x-val-11 1100 setp lincurve.0.y-val-11 0.104 setp lincurve.0.x-val-12 1200 setp lincurve.0.y-val-12 0.114 setp lincurve.0.x-val-13 1300 setp lincurve.0.y-val-13 0.128 setp lincurve.0.x-val-14 1400 setp lincurve.0.y-val-14 0.157 setp lincurve.0.x-val-15 1500 setp lincurve.0.y-val-15 0.217 net spin-0rpm sspindle.0.out-rpm => lincurve.0.in net spin-speed-to-DAC lincurve.0.out => hm2_7i95.0.pwmgen.00.value # delay things after a spindle on # =============================== loadrt timedelay count=2 addf timedelay.0 servo-thread addf timedelay.1 servo-thread setp timedelay.0.on-delay 0.2 # delay power real 0.2 seconds (protect relays) setp timedelay.0.off-delay 0.0 setp timedelay.1.on-delay 1 # delay spindle.at-speed by 1 sec (protect tool) setp timedelay.1.off-delay 0.0 # I am having a problem with the spindle-on value # it doesn't track spindle0.on and shows a switch in the halshow # but when I try and assignit mydself it say's I can't because it already is net spin-on spindle.0.on => hm2_7i95.0.ssr.00.out-00 timedelay.0.in timedelay.1.in hm2_7i95.0.pwmgen.00.enable # on net spin-power-on timedelay.0.out => hm2_7i95.0.ssr.00.out-02 # scr power net spin-at-speed timedelay.1.out => spindle.0.at-speed