On Tuesday 07 November 2017 21:17:17 Peter C. Wallace wrote:

> Hmm... something is really broken either in your encoder or hal/ini
> setup
>
> Can you post your hal/ini files plus a screen shot of the quadrature
> A,B signals?
>
> ( at a slow enoigh speed that the servo thread can sample it
> adequately )
>
> Peter Wallace
> Mesa Electronics
>
I think thats enough to run it. Some of the gui's extra buttons will not 
run however as I am in the process of bringing that stuff online.  And 
to actually drive the spindle, one, only one of the mist/flood buttons 
must be checked. That steers the input to the pwm servo to either the 
high gear or low gear pid's output, pid.sl, and pid.sh in the files.

Until I get the switches made and installed on the high/low gearshift 
dial at which point wiring that up will make it automatic. I carved a 
hollow spot in the edge of the knob today, for the rollers on the switch 
levers to drop into, but also finished up the locking clamp ring for the 
8" chuck's retention on the 11x36 Sheldon, its a threaded spindle nose.  
So now I can grab square stock to make armstrong bolts etc.  And I can 
rigid tap on it. That was one of the first things I did even before 
adding the hand dials to move it by hand with.

The picture was taken at about 25, maybe 30 rpms. It won't run reliably 
any slower than that. The tach dial just moves off zero.

Thank you Peter.

Cheers, Gene Heskett
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
Genes Web page <http://geneslinuxbox.net:6309/gene>
# This config file was created 2016-06-29 13:56:14.520980 by the update_ini 
script
# The original config files may be found in the 
/home/gene/linuxcnc/configs/GO704fast/GO704fast.old directory

# Generated by PNCconf at Tue Jun 30 22:44:28 2015
# If you make changes to this file, they will be
# overwritten when you run PNCconf again

[EMC]
# The version string for this INI file.
VERSION = 1.0

MACHINE = GO704fast
DEBUG = 00000000

[DISPLAY]
DISPLAY                                 = axis
PYVCP                                   = pyvcp-panel.xml
#EMBED_TAB_NAME                 = Camera
#EMBED_TAB_COMMAND              = gladevcp -x {XID} camview.glade
POSITION_OFFSET                 = RELATIVE
POSITION_FEEDBACK               = ACTUAL
MAX_FEED_OVERRIDE               = 2.000000
MAX_SPINDLE_OVERRIDE    = 2.0000
MIN_SPINDLE_OVERRIDE    = 0.25000
DEFAULT_SPINDLE_SPEED   = 100
INTRO_GRAPHIC                   = linuxcnc.gif
INTRO_TIME                              = 4
PROGRAM_PREFIX                  = /home/gene/linuxcnc/nc_files
INCREMENTS                              = 1.000  0.500 0.200 0.100 0.050 0.02 
0.01 0.005 0.002 0.001
DEFAULT_LINEAR_VELOCITY = .90
MAX_LINEAR_VELOCITY             = 1.5
MIN_LINEAR_VELOCITY             = 0.001
DEFAULT_ANGULAR_VELOCITY = 5.0000
MAX_ANGULAR_VELOCITY    = 7.5000
MIN_ANGULAR_VELOCITY    = 0.0100000
EDITOR = geany
GEOMETRY = xyz

[FILTER]
PROGRAM_EXTENSION       = .png,.gif,.jpg Greyscale Depth Image
PROGRAM_EXTENSION       = .py Python Script
png                                     = image-to-gcode
gif                                     = image-to-gcode
jpg                                     = image-to-gcode
py                                      = python

[RS274NGC]
PARAMETER_FILE          = linuxcnc.var
#RS274NGC_STARTUP_CODE  =  #4990=0.0000 #4991=0.0000 #4992=0.0000 #4993=0.0000 
#4994=0.0000 #4995=0.000000
SUBROUTINE_PATH         = /home/gene/linuxcnc/cam.stf

[EMCMOT]
EMCMOT                          = motmod
COMM_TIMEOUT            = 1.0
COMM_WAIT                       = 0.010
SERVO_PERIOD            = 1000000

[TASK]
TASK                            = milltask
CYCLE_TIME                      = 0.010

[HAL]
HALUI                           = halui
HALFILE                         = GO704fast.hal
# pins missing, need to strip from a file and make a separate HALFILE = for here
#HALFILE = custom.hal
#HALFILE = campins.hal
#HALFILE = Caa3Axis.hal
POSTGUI_HALFILE         = postgui_call_list.hal
SHUTDOWN                        = shutdown.hal

[HALUI]
# camon, camoff one call now
MDI_COMMAND=o<_newcamsw> call
#MDI_COMMAND=o<_camstore> call
#MDI_COMMAND=o<_camcenter3> call
#MDI_COMMAND=o<_camcenter4> call
#MDI_COMMAND=o<align_start> call
#MDI_COMMAND=o<align_y> call
#MDI_COMMAND=o<align_x> call
#MDI_COMMAND=o<clear_offset> call

[TRAJ]
AXES                            = 4
COORDINATES                     = X Y Z A
LINEAR_UNITS            = inch
ANGULAR_UNITS           = degree
CYCLE_TIME                      = 0.010
DEFAULT_LINEAR_VELOCITY = 0.65
MAX_LINEAR_VELOCITY = .90
POSITION_FILE           = position.txt

[EMCIO]
EMCIO                           = io
CYCLE_TIME                      = 0.100
TOOL_TABLE                      = tool.tbl

#********************
# Axis X
#********************

[KINS]
KINEMATICS                      = trivkins
#This is a best-guess at the number of joints, it should be checked
JOINTS                          = 4

#***********
# Axis X   *
#***********

[AXIS_X]
MIN_LIMIT                       =-9.6456
MAX_LIMIT                       = 9.6556

[JOINT_0]
MIN_LIMIT                       = -9.6456
MAX_LIMIT                       = 9.6556
MAX_VELOCITY            = 1.05
MAX_ACCELERATION        = 20.00
TYPE                            = LINEAR
HOME_SEQUENCE           = 2
HOME_IS_SHARED          = 1
HOME_SEARCH_VEL         = 0.60
HOME_LATCH_VEL          = -0.05
HOME_FINAL_VEL          = .80
HOME_OFFSET                     = 9.7580
HOME                            = 0.0
FERROR                          = 0.001
MIN_FERROR                      = 0.0005

# The values below should be 25% larger than MAX_VELOCITY and MAX_ACCELERATION
# If using BACKLASH compensation STEPGEN_MAXACCEL should be 100% larger.
STEPGEN_MAXVEL          = 2.0
STEPGEN_MAXACCEL        = 40.00
P                                       = 4.00
I                                       = 0.0
D                                       = 0.0
FF0                                     = 0.0
FF1                                     = 1.0
FF2                                     = 0.000025
BIAS                            = 0.0
DEADBAND                        = 0.0001
MAX_OUTPUT                      = 0
# these are in nanoseconds
DIRSETUP                        = 6000
DIRHOLD                         = 6000
STEPLEN                         = 3000
STEPSPACE                       = 3000
STEP_SCALE                      = 16271.00379
BACKLASH                        = 0.00190

#*********
# Axis Y *
#*********
[AXIS_Y]
MIN_LIMIT                       = -2.716
MAX_LIMIT                       = 2.7559

[JOINT_1]
MIN_LIMIT                       = -2.716
MAX_LIMIT                       = 2.7559
MAX_VELOCITY            = 1.35
MAX_ACCELERATION        = 20
TYPE                            = LINEAR
HOME_SEQUENCE           = 1
HOME_IS_SHARED          = 1
HOME_SEARCH_VEL         = 0.65
HOME_LATCH_VEL          = -0.05
HOME_FINAL_VEL          = 0.800
HOME_OFFSET                     = 2.7
HOME                            = 0.0
FERROR                          = 0.002
MIN_FERROR                      = 0.0005
# The values below should be 25% larger than MAX_VELOCITY and MAX_ACCELERATION
# If using BACKLASH compensation STEPGEN_MAXACCEL should be 100% larger.
STEPGEN_MAXVEL          = 2.70
STEPGEN_MAXACCEL        = 60
P                                       = 4.000
I                                       = 0.0
D                                       = 0.0
FF0                                     = 0.0
FF1                                     = 1.0
FF2                                     = 0.000025
BIAS                            = 0.0
DEADBAND                        = 0.00001
MAX_OUTPUT                      = 0
# these are in nanoseconds
DIRSETUP                        = 6000
DIRHOLD                         = 6000
STEPLEN                         = 3000
STEPSPACE                       = 3000
STEP_SCALE                      = -16298.63031
BACKLASH                        = .000950

#*********
# Axis Z *
#*********
[AXIS_Z]
MIN_LIMIT                       = -5.4700
MAX_LIMIT                       = 5.47

[JOINT_2]
MIN_LIMIT                       = -5.4700
MAX_LIMIT                       = 5.47
MAX_VELOCITY            = 1.250
MAX_ACCELERATION        = 20
TYPE                            =       LINEAR
HOME_SEQUENCE           =       0
HOME_IS_SHARED          =       1
HOME_SEARCH_VEL         =       0.800
HOME_LATCH_VEL          =       -0.030
HOME_FINAL_VEL          =       0.650
HOME                            =       5.45000000
HOME_OFFSET                     =       5.4500000
FERROR                          =       0.01
MIN_FERROR                      =       0.01
# The values below should be 35% larger than MAX_VELOCITY and MAX_ACCELERATION
# If using BACKLASH compensation STEPGEN_MAXACCEL should be at least 100% 
larger.
# 3x MAX_ACCELERATION if using g33.1 in peck mode
STEPGEN_MAXVEL          =       2.5
STEPGEN_MAXACCEL        =       50
P                                       =       4.000
I                                       =       0.0
D                                       =       0.0
FF0                                     =       0.0
FF1                                     =       1.0
FF2                                     =       0.000025
BIAS                            =       0.0
DEADBAND                        =       0.0001
MAX_OUTPUT                      =       0.0
# these are in nanoseconds
DIRSETUP                        =       6500
DIRHOLD                         =       6500
STEPLEN                         =       3500
STEPSPACE                       =       3500
STEP_SCALE                      =  -8128.0000000
BACKLASH                        =       .00320

#********************
# Axis A
#********************
[JOINT_3]
TYPE = ANGULAR
HOME = 0.0
HOME_SEQUENCE = 0
HOME_SEARCH_VEL = 0
HOME_LATCH_VEL = 0
HOME_FINAL_VEL = 0
FERROR = 0.05
MIN_FERROR = 0.005
MAX_VELOCITY = 12.0
MAX_ACCELERATION = 180.0
## The values below should be 25% larger than MAX_VELOCITY and MAX_ACCELERATION
## If using BACKLASH compensation STEPGEN_MAXACCEL should be 100% larger.
STEPGEN_MAXVEL = 15.00
STEPGEN_MAXACCEL = 225.00
P = 1000.0
I = 0.0
D = 0.0
FF0 = 0.00
FF1 = 1.00
FF2 = 0.0005
BIAS = 0.0
DEADBAND = 0.0
MAX_OUTPUT = 0
## these are in nanoseconds
DIRSETUP   = 6000
DIRHOLD    = 6000
STEPLEN    = 3000
STEPSPACE  = 3000
STEP_SCALE = 800.0
#MIN_LIMIT = -9999.0
#MAX_LIMIT = 9999.0
HOME_OFFSET = 0.0

#**************************
# Spindle H for high gear *
#**************************
[SPINDLE_H]
P                               =       0.000
I                               =       1.5
D                               =       0.0000
FF0                     =       .900
FF1                     =       0.000
FF2                     =       0.000
BIAS                    = 0.00
FBIAS                   =       0.60
RBIAS                   =       -0.90
ACCELL                  =       6.8
DEADBAND                =       0.004
ENCODER_SCALE   =       268.0
PWMGEN_S_SCALE  =       46.00
# this controls the speed of spindle accel, mainly for G33.1 turnaround shaping
# middle of output ramp rate
SP_MAXACCEL             = 350
# 700 = 3.75 turns of overshoot at 1k revs in backgear low
SP_MAXVEL               = 8000
# sp_maxvel should control roundness of ends of ramp
PWMGEN_S_FREQ   = 20000
NEAR_TOL                = 2
NEAR_SCALE              = 1.05
ENCODER_SAMPLE  = 500000

#*************************
# spindle L for low gear *
#*************************
[SPINDLE_L]
# is a velocity servo, treat it as such
P                               =       0.00
I                               =       1.5
D                               =       0.000
FF0                     =       1.9
FF1                     =       0.00
FF2                     =       0.00
FBIAS                   =       0.60
RBIAS                   =       -0.90
ACCELL                  =       6.8
DEADBAND                =       0.004
ENCODER_SCALE   =       268.0
PWMGEN_S_SCALE  =       46.00
# this controls the speed of spindle accel, mainly for G33.1 turnaround shaping
# middle of output ramp rate
SP_MAXACCEL             = 350
# 700 = 3.75 turns of overshoot at 1k revs in backgear low
SP_MAXVEL               = 8000
# sp_maxvel should control roundness of ends of ramp
PWMGEN_S_FREQ   = 20000
NEAR_TOL                = 2
NEAR_SCALE              = 1.05
ENCODER_SAMPLE  = 500000

[HOSTMOT2]
# **** This is for info only ****
# DRIVER0=hm2_pci
# BOARD0=5i25
# Generated by PNCconf at Tue Jun 30 22:44:28 2015
# If you make changes to this file, they will be
# overwritten when you run PNCconf again, so it never gets run again

loadrt [KINS]KINEMATICS
#autoconverted  trivkins
loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD 
num_joints=[KINS]JOINTS
loadrt hostmot2
loadrt hm2_pci config="num_encoders=1 num_pwmgens=1 num_stepgens=4"
loadrt  boot                    names=boot.spindle
loadrt  sample_hold     names=sample.dirchg,sample.spndlchg
loadrt  conv_bit_u32    names=conv-DirF,conv-DirR
loadrt  conv_u32_float  names=float-boot,conv-float.DirF,conv-float.DirR
loadrt  conv_s32_float  names=S32_float_cmd,S32_float_spndl
loadrt  pid                             
names=pid.x,pid.y,pid.z,pid.sl,pid.sh,pid.a
loadrt  abs                             
names=abs.spindle,abs.vel,abs.tachplus,abs.encdir,abs.piddir,abs.delay
loadrt  comp                    names=comp.drvbooted,comp.filter
loadrt  limit2                  count=3
loadrt  limit3                  names=rvsaccel
loadrt  not                             names=not.load,not.spndl
#loadrt not                             names=not.spndl
loadrt  or2                             names=or2.0,or2.1,or2.Z,or2.A,or2.B
# preparatory to making the charge-pump multi-use
loadrt  and2                    
names=and.vac,and.lube,and.spndl-hard,and.spndl-soft,steeron,steeroff
loadrt  mux2                    
names=enc0,enc1,enc2,enc3,mux2.fwd-rev,mux2.spndl
loadrt  mux4                    names=mux4spsel
loadrt  scale                   
names=scale.s_limit,scale.s_scale,scale.pidmaxerr,scale.tach,scale.motion,scaleX60
loadrt  near                    names=near.speed
loadrt  debounce                cfg=1,1
loadrt  lut5                    names=lut5-fwd,lut5-rvs,lut5-protect
loadrt  lowpass                 names=lowpass.tach
loadrt  sum2                    
names=sum01,sum23,sumenc,sum2.ovrtrvl,sum2.gearchg,sum2.bias
loadrt  conv_float_s32  count=1
loadrt  timedelay               names=pwr-delay-soft,pwr-delay-hard
loadrt  charge_pump
loadrt  oneshot                 names=forOn,forOff
loadrt  flipflop                names=camonoff

# addf stuff, mostly order sensitive
#addf hm2_5i25.0.read_gpio servo-thread
addf hm2_5i25.0.read    servo-thread #trigger scope on this
addf debounce.0                 servo-thread
addf debounce.1                 servo-thread
#************************************
# encoder-velocity noise filter
# arrange these in reverse order addf's to save the previous modules state, 
# otherwise it cascades thru in one cycle
# use comp.filter to detect a state change for enc#.hold control
addf  comp.filter               servo-thread # make hold signal for this servo 
cycle by comparing encoder-velocity and enc0.out
addf  conv-DirF                 servo-thread # is bit-u32
addf  conv-DirR                 servo-thread # is bit-u32
addf  conv-float.DirF   servo-thread #
addf  conv-float.DirR   servo-thread
addf  S32_float_spndl   servo-thread # is conv-s32-float
addf  S32_float_cmd             servo-thread
addf  float-boot                servo-thread # is conv-s32-float
# all this ordered so it all falls thru on the same servo-loop
addf  enc3                              servo-thread    # so it saves enc2's 
output in this cycle
addf  enc2                              servo-thread    # so it saves enc1's 
output in this cycle
addf  enc1                              servo-thread    # so it saves enc0's 
output in this cycle
addf  enc0                              servo-thread    # so it saves encoder 
velocity
addf  sum01                             servo-thread    # now total it up
addf  sum23                             servo-thread    # ditto
addf  sumenc                    servo-thread    # ditto, and incomplete, where 
the hell does sumenc go?  s/b pid.s.feedback
addf  abs.encdir                servo-thread
# end of encoder filter

addf motion-command-handler     servo-thread
addf motion-controller          servo-thread
addf rvsaccel                           servo-thread
addf abs.piddir                         servo-thread
addf sum2.bias                          servo-thread
addf not.load                           servo-thread

addf limit2.2                           servo-thread
addf comp.drvbooted                     servo-thread
addf boot.spindle                       servo-thread

#***********************************
addf lut5-fwd                   servo-thread
addf lut5-rvs                   servo-thread
addf lut5-protect               servo-thread
addf scale.s_limit              servo-thread
addf scale.s_scale              servo-thread
addf scale.pidmaxerr    servo-thread
addf mux2.spndl                 servo-thread
addf mux4spsel                  servo-thread
addf mux2.fwd-rev               servo-thread
addf scale.tach                 servo-thread
addf pid.x.do-pid-calcs servo-thread
addf pid.y.do-pid-calcs servo-thread
addf pid.z.do-pid-calcs servo-thread
addf pid.a.do-pid-calcs servo-thread
addf pid.sl.do-pid-calcs servo-thread
addf pid.sh.do-pid-calcs servo-thread
addf abs.spindle                servo-thread
addf abs.vel                    servo-thread
addf abs.tachplus               servo-thread
addf not.spndl                  servo-thread
addf limit2.1                   servo-thread
addf or2.0                              servo-thread
addf or2.1                              servo-thread
addf or2.Z                              servo-thread
addf or2.A                              servo-thread
addf or2.B                              servo-thread
addf lowpass.tach               servo-thread
addf near.speed                 servo-thread
addf charge-pump        servo-thread
addf and.vac                    servo-thread
addf and.spndl-soft             servo-thread
addf and.spndl-hard             servo-thread
addf and.lube                   servo-thread
addf pwr-delay-soft             servo-thread
addf pwr-delay-hard             servo-thread
addf forOn                              servo-thread
addf forOff                             servo-thread
addf steeron                    servo-thread
addf steeroff                   servo-thread
addf camonoff                   servo-thread

# for G33.1 overtravel display
addf    sample.dirchg   servo-thread
addf    sample.spndlchg servo-thread
addf    sum2.ovrtrvl    servo-thread
addf hm2_5i25.0.write   servo-thread
#addf hm2_5i25.0.write-gpio servo-thread
# external input signals
setp    hm2_5i25.0.watchdog.timeout_ns 6000000

#*******************
# HOME switches
#*******************

setp debounce.0.delay  1
net home-switch         <=      hm2_5i25.0.gpio.013.in  =>      debounce.0.0.in 
# signal source is p3-10
net debncd-home         <=      debounce.0.0.out        =>      
joint.2.home-sw-in joint.1.home-sw-in joint.0.home-sw-in
# as more switches get added to the series chain, add them to the net above

# hook up probe signal
net probe.sense         <=      hm2_5i25.0.gpio.003.in_not      =>      
motion.probe-input # signal source is p3-15

#******************************************
# align, calibrate stuff, still being tuned
#******************************************

setp    forOn.width .1
setp    forOn.falling 0
setp    forOn.rising 1
setp    forOff.width .1
setp    forOff.falling 1
setp    forOff.rising 0

#********************
#  AXIS X = joint_0 *
#********************
# setup pid
setp   pid.x.Pgain     [JOINT_0]P
setp   pid.x.Igain     [JOINT_0]I
setp   pid.x.Dgain     [JOINT_0]D
setp   pid.x.bias      [JOINT_0]BIAS
setp   pid.x.FF0       [JOINT_0]FF0
setp   pid.x.FF1       [JOINT_0]FF1
setp   pid.x.FF2       [JOINT_0]FF2
setp   pid.x.deadband  [JOINT_0]DEADBAND
setp   pid.x.maxoutput [JOINT_0]MAX_OUTPUT
setp   pid.x.error-previous-target true
setp   pid.x.maxerror .0005

#*****************************
# Step Gen signals/setup for X
#*****************************
setp   hm2_5i25.0.stepgen.00.dirsetup        [JOINT_0]DIRSETUP
setp   hm2_5i25.0.stepgen.00.dirhold         [JOINT_0]DIRHOLD
setp   hm2_5i25.0.stepgen.00.steplen         [JOINT_0]STEPLEN
setp   hm2_5i25.0.stepgen.00.stepspace       [JOINT_0]STEPSPACE
setp   hm2_5i25.0.stepgen.00.position-scale  [JOINT_0]STEP_SCALE
setp   hm2_5i25.0.stepgen.00.step_type        0
setp   hm2_5i25.0.stepgen.00.control-type     1
setp   hm2_5i25.0.stepgen.00.maxaccel         [JOINT_0]STEPGEN_MAXACCEL
setp   hm2_5i25.0.stepgen.00.maxvel           [JOINT_0]STEPGEN_MAXVEL
setp   hm2_5i25.0.gpio.002.invert_output true
setp   hm2_5i25.0.gpio.004.invert_output true

#*********************************
# ---closedloop stepper signals for X---
#*********************************
net x-pos-cmd           <=      joint.0.motor-pos-cmd   =>      pid.x.command
net x-vel-cmd           <=      joint.0.vel-cmd =>      pid.x.command-deriv
net x-pos-fb            <=      hm2_5i25.0.stepgen.00.position-fb       =>      
pid.x.feedback  joint.0.motor-pos-fb
net x-output            <=      hm2_5i25.0.stepgen.00.velocity-cmd      =>      
pid.x.output
net x-index-enable      <=>     pid.x.index-enable
net x-enable            <=      joint.0.amp-enable-out  =>      
hm2_5i25.0.stepgen.00.enable    pid.x.enable

#********************
#  AXIS Y = joint_1 *
#********************
setp   pid.y.Pgain     [JOINT_1]P
setp   pid.y.Igain     [JOINT_1]I
setp   pid.y.Dgain     [JOINT_1]D
setp   pid.y.bias      [JOINT_1]BIAS
setp   pid.y.FF0       [JOINT_1]FF0
setp   pid.y.FF1       [JOINT_1]FF1
setp   pid.y.FF2       [JOINT_1]FF2
setp   pid.y.deadband  [JOINT_1]DEADBAND
setp   pid.y.maxoutput [JOINT_1]MAX_OUTPUT
setp   pid.y.error-previous-target true
setp   pid.y.maxerror .0005


#**********************************
# Step Gen signals/setup for Y axis
#**********************************
setp   hm2_5i25.0.stepgen.01.dirsetup        [JOINT_1]DIRSETUP
setp   hm2_5i25.0.stepgen.01.dirhold         [JOINT_1]DIRHOLD
setp   hm2_5i25.0.stepgen.01.steplen         [JOINT_1]STEPLEN
setp   hm2_5i25.0.stepgen.01.stepspace       [JOINT_1]STEPSPACE
setp   hm2_5i25.0.stepgen.01.position-scale  [JOINT_1]STEP_SCALE
setp   hm2_5i25.0.stepgen.01.step_type        0
setp   hm2_5i25.0.stepgen.01.control-type     1
setp   hm2_5i25.0.stepgen.01.maxaccel         [JOINT_1]STEPGEN_MAXACCEL
setp   hm2_5i25.0.stepgen.01.maxvel           [JOINT_1]STEPGEN_MAXVEL
setp   hm2_5i25.0.gpio.006.invert_output true
setp   hm2_5i25.0.gpio.008.invert_output true

#*********************************
# ---closedloop stepper signals---
#*********************************
net y-pos-cmd    <= joint.1.motor-pos-cmd
net y-vel-cmd    <= joint.1.vel-cmd
net y-output     <= hm2_5i25.0.stepgen.01.velocity-cmd
net y-pos-fb     <= hm2_5i25.0.stepgen.01.position-fb
net y-pos-fb     => joint.1.motor-pos-fb
net y-enable     <= joint.1.amp-enable-out
net y-enable     => hm2_5i25.0.stepgen.01.enable
net y-index-enable  <=> pid.y.index-enable
net y-enable        =>  pid.y.enable
net y-pos-cmd       =>  pid.y.command
net y-vel-cmd       =>  pid.y.command-deriv
net y-pos-fb        =>  pid.y.feedback
net y-output        =>  pid.y.output

#********************
#  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
setp   pid.z.maxerror .0005

#*****************************
# Step Gen signals/setup for Z
#*****************************
setp   hm2_5i25.0.stepgen.02.dirsetup        [JOINT_2]DIRSETUP
setp   hm2_5i25.0.stepgen.02.dirhold         [JOINT_2]DIRHOLD
setp   hm2_5i25.0.stepgen.02.steplen         [JOINT_2]STEPLEN
setp   hm2_5i25.0.stepgen.02.stepspace       [JOINT_2]STEPSPACE
setp   hm2_5i25.0.stepgen.02.position-scale  [JOINT_2]STEP_SCALE
setp   hm2_5i25.0.stepgen.02.step_type        0
setp   hm2_5i25.0.stepgen.02.control-type     1
setp   hm2_5i25.0.stepgen.02.maxaccel         [JOINT_2]STEPGEN_MAXACCEL
setp   hm2_5i25.0.stepgen.02.maxvel           [JOINT_2]STEPGEN_MAXVEL
setp   hm2_5i25.0.gpio.009.invert_output true
setp   hm2_5i25.0.gpio.010.invert_output true

#*************************************
# ---closedloop stepper signals for Z
#*************************************
net z-pos-cmd    <= joint.2.motor-pos-cmd
net z-vel-cmd    <= joint.2.vel-cmd
net z-output     <= hm2_5i25.0.stepgen.02.velocity-cmd
net z-pos-fb     <= hm2_5i25.0.stepgen.02.position-fb
net z-pos-fb     => joint.2.motor-pos-fb
net z-enable     <= joint.2.amp-enable-out
net z-enable     => hm2_5i25.0.stepgen.02.enable
net z-index-enable  <=> pid.z.index-enable
net z-enable        =>  pid.z.enable
net z-pos-cmd       =>  pid.z.command
net z-vel-cmd       =>  pid.z.command-deriv
net z-pos-fb        =>  pid.z.feedback
net z-output        =>  pid.z.output


#*********************************************************
#  AXIS A, joint_3 removed for spwr control use but now  *
#  moved spwr control to other p2 connector, same pins   *
#*********************************************************

setp   pid.a.Pgain     [JOINT_3]P
setp   pid.a.Igain     [JOINT_3]I
setp   pid.a.Dgain     [JOINT_3]D
setp   pid.a.bias      [JOINT_3]BIAS
setp   pid.a.FF0       [JOINT_3]FF0
setp   pid.a.FF1       [JOINT_3]FF1
setp   pid.a.FF2       [JOINT_3]FF2
setp   pid.a.deadband  [JOINT_3]DEADBAND
setp   pid.a.maxoutput [JOINT_3]MAX_OUTPUT
setp   pid.a.error-previous-target true
setp   pid.a.maxerror .0005

net a-index-enable  <=> pid.a.index-enable
net a-enable        =>  pid.a.enable
net a-pos-cmd       =>  pid.a.command
net a-vel-cmd       =>  pid.a.command-deriv
net a-pos-fb        =>  pid.a.feedback
net a-output        =>  pid.a.output

# Step Gen signals/setup

setp   hm2_5i25.0.stepgen.03.dirsetup        [JOINT_3]DIRSETUP
setp   hm2_5i25.0.stepgen.03.dirhold         [JOINT_3]DIRHOLD
setp   hm2_5i25.0.stepgen.03.steplen         [JOINT_3]STEPLEN
setp   hm2_5i25.0.stepgen.03.stepspace       [JOINT_3]STEPSPACE
setp   hm2_5i25.0.stepgen.03.position-scale  [JOINT_3]STEP_SCALE
setp   hm2_5i25.0.stepgen.03.step_type        0
setp   hm2_5i25.0.stepgen.03.control-type     1
setp   hm2_5i25.0.stepgen.03.maxaccel         [JOINT_3]STEPGEN_MAXACCEL
setp   hm2_5i25.0.stepgen.03.maxvel           [JOINT_3]STEPGEN_MAXVEL
setp   hm2_5i25.0.gpio.011.invert_output true

# ---closedloop stepper signals---

net a-pos-cmd    <= joint.3.motor-pos-cmd
net a-vel-cmd    <= joint.3.vel-cmd
net a-output     <= hm2_5i25.0.stepgen.03.velocity-cmd
net a-pos-fb     <= hm2_5i25.0.stepgen.03.position-fb
net a-pos-fb     => joint.3.motor-pos-fb
net a-enable     <= joint.3.amp-enable-out
net a-enable     => hm2_5i25.0.stepgen.03.enable

# ---setup home / limit switch signals---

#net a-home-sw     =>  joint.3.home-sw-in
#net a-neg-limit     =>  joint.3.neg-lim-sw-in
#net a-pos-limit     =>  joint.3.pos-lim-sw-in

#*****************************************
# setup feeds TO the pid.s(h|l)'s etc    *
# but profile the switch for accell ctrl *
#*****************************************
net     spindle-vel-cmd-rps             =>      rvsaccel.in

# The following is based on the Z axis haveing maximum power at zero speed,
# so the controling ramp output from rvsaccel can go thru zero speed at a
# good rate, probably limited by the backlash takeup as it reverses, but is
# more torque limited at the higher speeds, so round off the corners of the
# ramp which correspond to the higher speeds.  This is not an ideal, all speeds
# and tpi variation solution.  The Z cannot reliably move at more than 42 ipm,
# so we need an error stopper to kick in at any time the Z speed exceeds say
# 25 ipm, which should leave some headroom for the backlash takeup.
# it needs to show the error as please try a lower spindle speed so Z can keep 
up.

setp rvsaccel.maxa                                      [SPINDLE_H]SP_MAXACCEL  
# turns ramp into
# the PID into a sine squared waveform
setp rvsaccel.maxv                                      [SPINDLE_H]SP_MAXVEL  # 
sets speed of ramp
net spindle-accel-limit    <=      rvsaccel.out   =>    pid.sh.command 
pid.sl.command abs.piddir.in # all good here

#**************************************************************
#  SPINDLE PID's setup, pid.sh is low gear, runs motor faster *
# whereas pid.sl is high gear, runs motor slower              *
#**************************************************************
setp   pid.sh.Pgain     [SPINDLE_H]P
setp   pid.sh.Igain     [SPINDLE_H]I
setp   pid.sh.Dgain     [SPINDLE_H]D
setp   pid.sh.FF0       [SPINDLE_H]FF0
setp   pid.sh.FF1       [SPINDLE_H]FF1
setp   pid.sh.FF2       [SPINDLE_H]FF2
setp   pid.sh.deadband  [SPINDLE_H]DEADBAND
setp   pid.sh.error-previous-target true
# send this pid's output on to switching according to knob
net    slow-spindle     <=      pid.sh.output   => mux4spsel.in1
setp    mux4spsel.in0   0.0000000
setp   pid.sl.Pgain     [SPINDLE_L]P
setp   pid.sl.Igain     [SPINDLE_L]I
setp   pid.sl.Dgain     [SPINDLE_L]D
setp   pid.sl.FF0       [SPINDLE_L]FF0
setp   pid.sl.FF1       [SPINDLE_L]FF1
setp   pid.sl.FF2       [SPINDLE_L]FF2
setp   pid.sl.deadband  [SPINDLE_L]DEADBAND
setp   pid.sl.error-previous-target true

# send this pid's output on to switching according to knob
net    fast-spindle     <=      pid.sl.output =>        mux4spsel.in2
setp    mux4spsel.in3   0.00000000

#*****************************************
# setup feeds TO the pid.s(h|l)'s etc    *
# but profile the switch for accell ctrl *
#*****************************************
net     spindle-vel-cmd-rps             =>      rvsaccel.in

# The following is based on the Z axis haveing maximum power at zero speed,
# so the controling ramp output from rvsaccel can go thru zero speed at a
# good rate, probably limited by the backlash takeup as it reverses, but is
# more torque limited at the higher speeds, so round off the corners of the
# ramp which correspond to the higher speeds.  This is not an ideal, all speeds
# and tpi variation solution.  The Z cannot reliably move at more than 42 ipm,
# so we need an error stopper to kick in at any time the Z speed exceeds say
# 25 ipm, which should leave some headroom for the backlash takeup.
# it needs to show the error as please try a lower spindle speed so Z can keep 
up.

setp rvsaccel.maxa                                      [SPINDLE_H]SP_MAXACCEL  
# turns ramp into
# the PID into a sine squared waveform
setp rvsaccel.maxv                                      [SPINDLE_H]SP_MAXVEL  # 
sets speed of ramp
net spindle-accel-limit    <=      rvsaccel.out   =>    pid.sh.command 
pid.sl.command abs.piddir.in # all good here


# SPINDLE REVERSE and friction control helpers
#************************
setp   sum2.bias.gain0       [SPINDLE_H]FBIAS
setp   sum2.bias.gain1       [SPINDLE_H]RBIAS
net    is-plus0         <=      abs.piddir.is-positive  =>      conv-DirF.in # 
TRUE converted to 1
net    is-plus1         <=      conv-DirF.out                   =>      
conv-float.DirF.in  # still a 1 when m3
net    is-neg0          <=      abs.piddir.is-negative  =>      conv-DirR.in # 
this works in m4 too
net    is-neg1          <=      conv-DirR.out                   =>      
conv-float.DirR.in # ditto for m4
net    bias-dirF        <=      conv-float.DirF.out             =>      
sum2.bias.in0
net    bias.DirR        <=      conv-float.DirR.out             =>      
sum2.bias.in1
net    pid.bias         <=      sum2.bias.out                   =>      
pid.sl.bias pid.sh.bias
# this might have to be separated too.

#**********************************
# ENCODER feedback signals setup
#**********************************
setp    hm2_5i25.0.encoder.00.counter-mode              false
setp    hm2_5i25.0.encoder.00.filter                    true
setp    hm2_5i25.0.encoder.00.index-enable              true
setp    hm2_5i25.0.encoder.00.index-invert              false
setp    hm2_5i25.0.encoder.00.index-mask                false
setp    hm2_5i25.0.encoder.00.scale                             
[SPINDLE_H]ENCODER_SCALE
setp    hm2_5i25.0.encoder.sample-frequency             
[SPINDLE_H]ENCODER_SAMPLE
#*************************
# ENCODER FILTER SCALING *
#*************************
setp    sumenc.gain0 0.2500             # scale it back to unity
setp    sumenc.gain1 0.2500             # scale it back to unity

#***********************************************
# now continue path from mux4spsel to pwm input*
#***********************************************
net pid-select  <=      mux4spsel.out   =>      boot.spindle.pid0
# now scale pid.s.maxoutput to 0.98 times pwmgen scale
setp scale.s_limit.in                           [SPINDLE_H]PWMGEN_S_SCALE

setp  scale.s_limit.gain           0.98

net   maxdrive          <=      scale.s_limit.out       =>      
pid.sh.maxoutput pid.sl.maxoutput

# ---PWM Generator signals/setup---
# default output type is 1, don't muck with it
setp   hm2_5i25.0.pwmgen.00.scale               [SPINDLE_H]PWMGEN_S_SCALE
setp   scale.s_scale.gain                               
[SPINDLE_H]PWMGEN_S_SCALE
setp   hm2_5i25.0.pwmgen.pwm_frequency  [SPINDLE_H]PWMGEN_S_FREQ
setp   hm2_5i25.0.gpio.001.invert_output false
setp   hm2_5i25.0.gpio.005.invert_output true

net             spindle-output1 <= boot.spindle.pout0 => 
hm2_5i25.0.pwmgen.00.value
net             machine-is-on   => hm2_5i25.0.pwmgen.00.enable

#***********************************
# stuff for encoder noise filter
setp    scaleX60.gain 60.000
setp    comp.filter.hyst .0001 # if no diff skip clocking data thru

# feed enc0.in, or mul2 as case may be
net spindle-vel-fb-rps          <=  hm2_5i25.0.encoder.00.velocity
net spindle-vel-fb-rps          =>  scaleX60.in abs.encdir.in  enc0.in0 
comp.filter.in0
# for spindle syched moves
net spindle-revs                        <=      hm2_5i25.0.encoder.00.position  
=>      motion.spindle-revs
net encoderhold.0                       <=      enc0.out enc0.in1 enc1.in0 
comp.filter.in1 sum01.in0
net encoder-sel                         <=      comp.filter.equal enc0.sel 
enc1.sel enc2.sel enc3.sel

# now we have a diff sig
net             encoder-sel                     <=      comp.filter.equal       
enc0.sel        enc1.sel        enc2.sel        enc3.sel # now go watch 
enc0.out etc for S&G
net             encoderhold-1           <=      enc1.out        =>      
enc1.in1        enc2.in0        sum01.in1
net             encoderhold-2           <=      enc2.out        =>      
enc2.in1        enc3.in0        sum23.in0
net             encoderhold-3           <=      enc3.out        =>      
enc3.in1        sum23.in1
# now combine it
net             encoderfilter-sum4      <=      sum01.out       =>      
sumenc.in0
net             encoderfilter-sum       <=      sum23.out       =>      
sumenc.in1
net             spindle-velocity                <=      sumenc.out      =>      
pid.sh.feedback  pid.sl.feedback near.speed.in2 # to where ever needed, watch 
with halscope

# ---setup spindle control signals---
# We have 4 signal names here, which goes to pwmgen?
net spindle-vel-cmd-rps        <=  motion.spindle-speed-out-rps  near.speed.in1 
#this one!
net spindle-vel-cmd-rps        =>   rvsaccel.in # control accel rates

#***************************************************
# First - setup 5i25's p3-p17 for servo enable use *
#***************************************************
setp    hm2_5i25.0.gpio.007.is_output           true
setp    hm2_5i25.0.gpio.007.invert_output       false

# now hook spindle up, rebooting the servo amp at spindle start
net spindle-enable      <=  motion.spindle-on   boot.spindle.enable
net spindle-enable      =>      hm2_5i25.0.gpio.007.out # is pwmgen-enable-out 
at P3-17
#net spindle-enable     <=      not.load.in # not used? get rid of the not too
#net load-inverted      <=      not.load.out  # limit2.0.load
setp comp.drvbooted.in1         4.500000
net spindle-boot0               <=              boot.spindle.state      =>      
float-boot.in
net spindle-boot1               <=              float-boot.out          =>      
comp.drvbooted.in0
net spindle-booted              <=              comp.drvbooted.out      =>      
not.spndl.in
net spindle-booted-inv  <=              not.spndl.out           =>      
pid.sl.enable pid.sh.enable
net spindle-cw                  <=              motion.spindle-forward
net spindle-ccw                 <=              motion.spindle-reverse
net spindle-brake               <=              motion.spindle-brake
net spindle-vel-fb-rps  =>              motion.spindle-speed-in # near.speed.in2

net spindle-index-enable        <=>     motion.spindle-index-enable <=> 
hm2_5i25.0.encoder.00.index-enable
# ---Setup spindle at speed signals---
net spindle-index       <=>     hm2_5i25.0.encoder.00.input-index 
pid.sl.index-enable pid.sh.index-enable

setp near.speed.difference 2

net spindle-at-speed <= near.speed.out => motion.spindle-at-speed

#  Use ACTUAL spindle velocity from spindle encoder
#  spindle-velocity bounces around so we filter it with lowpass
#  spindle-velocity is signed so we use absolute component to remove sign
#  ACTUAL velocity is in RPS not RPM so we scale it.

setp     scale.tach.gain 60
setp     lowpass.tach.gain 0.1
net spindle-vel-fb-rps  =>      scale.tach.in
net spindle-fb-rpm              <=      scale.tach.out  =>   abs.spindle.in
net spindle-fb-rpm-abs  <=      abs.spindle.out =>   lowpass.tach.in
net spindle-rpm         lowpass.tach.out

# Now, lets see if we can track the G33.1 turnaround overtravel
# first, make a sum2 a sub2
setp    sum2.ovrtrvl.gain0      -1.0000

# then net the sample holds but sample needs s32, not float so use count
net     ovrtrvl1                <=      hm2_5i25.0.encoder.00.count     
sample.dirchg.in sample.spndlchg.in
net     spindle-ccw             =>      sample.dirchg.hold
net     spindle-reverse <=      abs.encdir.is-negative  =>      
sample.spndlchg.hold

# and calc the overtravel from S32's
net     ovrtrvl2        <=      sample.dirchg.out       =>      S32_float_cmd.in
net     ovrtrvl3        <=      S32_float_cmd.out       =>      sum2.ovrtrvl.in0
net     ovrtrvl4        <=      sample.spndlchg.out     =>      
S32_float_spndl.in
net     ovrtrvl5        <=      S32_float_spndl.out     =>      sum2.ovrtrvl.in1
net     overtravel      <=      sum2.ovrtrvl.out
#**************************************************************
# the hal signal overtravel should be shown with a hal__meter *
#**************************************************************
#********************************
# connect miscellaneous signals *
#********************************

#  ---HALUI signals---

net joint-select-a              <=      halui.axis.x.select
net x-is-homed                  <=      halui.joint.0.is-homed
net jog-x-pos                   <=      halui.axis.x.plus
net jog-x-neg                   <=      halui.axis.x.minus
net jog-x-analog                <=      halui.axis.x.analog
net joint-select-b              <=      halui.axis.y.select
net y-is-homed                  <=      halui.joint.1.is-homed
net jog-y-pos                   <=      halui.axis.y.plus
net jog-y-neg                   <=      halui.axis.y.minus
net jog-y-analog                <=      halui.axis.y.analog
net joint-select-c              <=      halui.axis.z.select
net z-is-homed                  <=      halui.joint.2.is-homed
net jog-z-pos                   <=      halui.axis.z.plus
net jog-z-neg                   <=      halui.axis.z.minus
net jog-z-analog                <=      halui.axis.z.analog
# Axis A stuff
net joint-select-d              <=      halui.axis.a.select
net a-is-homed                  <=      halui.joint.3.is-homed
net jog-a-pos                   <=      halui.axis.a.plus
net jog-a-neg                   <=      halui.axis.a.minus
net jog-a-analog                <=      halui.axis.a.analog
net jog-selected-pos    <=      halui.axis.selected.plus
net jog-selected-neg    <=      halui.axis.selected.minus
net spindle-manual-cw   <=      halui.spindle.forward
net spindle-manual-ccw  <=      halui.spindle.reverse
net spindle-manual-stop <=      halui.spindle.stop
net machine-is-on               <=      halui.machine.is-on
net jog-speed                   <=      halui.axis.jog-speed 
net MDI-mode                    <=      halui.mode.is-mdi

#  ---coolant signals---
# setup P2-17 to control the jigs locator bar, is cable hanging out of pcb box
setp hm2_5i25.0.gpio.024.is_output true
setp hm2_5i25.0.gpio.024.invert_output true
net coolant-mist        <=      iocontrol.0.coolant-mist        =>      
hm2_5i25.0.gpio.024.out mux2.spndl.sel

net coolant-mist        =>      mux4spsel.sel0
# disable the line above when switches have been installed.
#*****************************************************************************
# hook up back gear switches. There will be a notch, or a bump on the rim of *
# the knob that will contact one of 2 switches, only one when it is fully    *
# engaged in _that_ gear. But nust find pins that are inputs on the b.o.b.   *
# According to dmesg, gpio.032, pin p2-12 and gpio.033, p2-13 are available  *
# assume switch is closure to ground. gpio's are input  unless set otherwise *
#*****************************************************************************
#net    gear-sw-high    <=      hm2_5i25.0.gpio.032.in_not      =>      
mux4spsel.sel0
#net    gear-sw-low             <=      hm2_5i25.0.gpio.033.in_not      =>      
mux4spsel.sel1
# enable the above 2 lines when switches have been installed.

# this should be true=low at P2-17 when mist is on,
# or when an M7 has been encountered in the g-code.
# M9 turns it all off
# need to assign another output pin to flood, to be used to control
# a vacuum cleaner to suck up the sawdust.

# and here, we open a 10 lb can of worms, because charge-pump is a single 
# instance module.  So to be able to use it for other controls, we will
# have to enable it permanently, and drive any number of and2's so we get
# an output to send to a pin of the BoB, or not, by setting the other
# input to the and2, effectively using that for the enable  signal on a 
# per output basis.  or2's could also be used, seting the 2nd input true
# to disable the output toggling.  And2's make more sense to me however.
 
## this will do till I have a better idea. 022 is usually axis B's pulse
setp hm2_5i25.0.gpio.022.is_output true
setp hm2_5i25.0.gpio.022.invert_output false #shouldn't effect result
# but does, the vacuum starts for 1/4 second at power up.

# setup charge-pump full time
setp charge-pump.enable true  # just leave it running.
net             pwr-pump                <=      charge-pump.out => and.vac.in0 
and.spndl-hard.in0 and.spndl-soft.in0

# remove the mux4spsel.sel1 feed when switches hace been installed
net             coolant-flood   <=      iocontrol.0.coolant-flood => 
and.vac.in1        mux4spsel.sel1

net             vac-control1    <=      and.vac.out => hm2_5i25.0.gpio.022.out
# an M8 turns it on, M9 shuts both off
# and it seems to work as written but I just inverted the mist output
# hopefully the bar will stay out when lcnc shuts down. It did.

#*************************************************
# Now setup the spindles psu on/off sequencing
#*************************************************
# first, set the time delays, on in order of execution
setp    pwr-delay-soft.on-delay 0.1 # initial on, but thru the resistor
setp    pwr-delay-hard.on-delay 5.0 # seconds, to full on, bypassing the 
resistor

# now its on, shut it off in order of execution 
setp    pwr-delay-hard.off-delay        0.1 # seconds, go back to resistor 
limited power
setp    pwr-delay-soft.off-delay        1.0 # to full off in seconds

# setup the gpio's used for spindle power control
setp    hm2_5i25.0.gpio.028.is_output true # is J2-8, 2nd bob, in pcb box, pin 
8 controls resistor's feed
setp    hm2_5i25.0.gpio.029.is_output true # is J2-9, 2nd bob, in pcb box, pin 
9 controls resistor bypass
# that sets 5i25's gpio's 028 and 029 to output, and this crowbars the soft 
start resistor

# now tie it all together
# turn on spindle power softly, by pumping pin 8 of the BoB, and start both 
timers
# start the control chain
net     spndl-power             <=      motion.motion-enabled   =>      
pwr-delay-hard.in       pwr-delay-soft.in
# both time-delays now started

# hook soft start to and2.spindle.in1
net             spndl-soft              <= pwr-delay-soft.out   => 
and.spndl-soft.in1

# and hook it to the 5i25, J2-8
net     soft-spdnl-pwr  <= and.spndl-soft.out => hm2_5i25.0.gpio.028.out # pin 
p2-8
# which turns on toroids thru a 51 ohm 200 watt resistor to start charging 
supply caps

# 5 secs later, bypass the resistor by linking hard delay out to
# and.spndl.hard input 1, enabling it to pass the pump signal
net             hard-spndl-pwr  <=      pwr-delay-hard.out      =>      
and.spndl-hard.in1      # sets up to feed full power

# now feed that delayed full power pump to J2-9 after 5 seconds, and turn it 
off in .1 seconds
net             spndl-power-hard        <=      and.spndl-hard.out => 
hm2_5i25.0.gpio.029.out #P2 bob pin 9 feeds tordoids direct
# all done and understandable spindle psu controls.

# I wonder if I could also feed the rest of the system control box (after the 
BoB) with
# the first SSR, making it 95% automatic. The thought keeps nagging at me.  But 
then
# would lose the protection that making me switch it by hand gives, so I don't 
do it...

# connect max velocity overide increments - switches

setp halui.max-velocity.count-enable true
setp halui.max-velocity.direct-value true
setp halui.max-velocity.scale 20.000000
#net max-vel-override-incr   =>  halui.max-velocity.counts # no src!!

# connect spindle overide increments 

setp halui.spindle-override.count-enable true
setp halui.spindle-override.direct-value true
setp halui.spindle-override.scale .01
#net spindleoverride-incr  =>  halui.spindle-override.counts

#  ---motion control signals---

net in-position         <=  motion.in-position

#  ---digital in / out signals---

#  ---estop signals---
# P2-pin 10 is usually the estop input, but haven't sussed how to
# net that yet.
net estop-out           <=      iocontrol.0.user-enable-out
net estop-out           =>      iocontrol.0.emc-enable-in

#  ---manual tool change signals---

loadusr -W hal_manualtoolchange
net tool-change-request         <=      iocontrol.0.tool-change       =>  
hal_manualtoolchange.change
net tool-change-confirmed       <=      iocontrol.0.tool-changed      =>  
hal_manualtoolchange.changed
net tool-number                         <=      iocontrol.0.tool-prep-number  
=>  hal_manualtoolchange.number
net tool-prepare-loopback       <=      iocontrol.0.tool-prepare      =>  
iocontrol.0.tool-prepared
<?xml version='1.0' encoding='UTF-8'?>

<pyvcp>
<!-- 
Include your PyVCP panel here.
The contents of this file will not be overwritten when you run stepconf again.
-->
<!-- the RPM meter -->
  <hbox>
    <relief>RAISED</relief>
    <bd>2</bd>
    <meter>
      <halpin>"spindle_rpm"</halpin>
      <text>"Spindle"</text>
      <subtext>"RPM"</subtext>
      <size>240</size>
      <min_>0</min_>
      <max_>2750</max_>
      <majorscale>500</majorscale>
      <minorscale>100</minorscale>
      <region1>0,2250,"green"</region1>
      <region2>2250,2600,"yellow"</region2>
      <region3>2600,2750,"red"</region3>
    </meter>
  </hbox>

  <hbox>
    <vbox>
      <relief>RAISED</relief>
      <bd>2</bd>
      <label>
        <text>"SPWR"</text>
        <font>("Helvetica",8)</font>
      </label>
      <rectled>
        <halpin>"on-led"</halpin>
        <height>"6"</height>
        <width>"72"</width>
        <on_color>"green"</on_color>
        <off_color>"red"</off_color>
      </rectled>
    </vbox>

    <vbox>
      <relief>RAISED</relief>
      <bd>2</bd>
      <label>
        <text>"FWD"</text>
        <font>("Helvetica",8)</font>
      </label>
      <rectled>
        <halpin>"fwd-led"</halpin>
        <height>"6"</height>
        <width>"72"</width>
        <on_color>"green"</on_color>
        <off_color>"red"</off_color>
      </rectled>
    </vbox>

    <vbox>
      <relief>RAISED</relief>
      <bd>2</bd>
      <label>
        <text>"REV"</text>
        <font>("Helvetica",8)</font>
      </label>
      <rectled>
        <halpin>"rev-led"</halpin>
        <height>"6"</height>
        <width>"72"</width>
        <on_color>"green"</on_color>
        <off_color>"red"</off_color>
      </rectled>
    </vbox>
  </hbox>

<!-- The following is added to your .xml file inside the <pyvcp> </pyvcp> tags --> 
<!-- here we have to re-invent the camview missing stuffs -->
  <labelframe text="Calibrate machine">
    <hbox>
      <button>
        <halpin>"checkbutton1"</halpin>
        <text>"CamSW"</text>
        <font>('Helvetica',10)</font>
      </button>
      <button>
        <halpin>"button1"</halpin>
        <text>"CamStor"</text>
        <font>('Helvetica',10)</font>
      </button>
    </hbox>
    <rectled>
      <halpin>"camactive"</halpin>
      <height>"6"</height>
      <width>"150"</width>
      <on_color>"green"</on_color>
      <off_color>"red"</off_color>
    </rectled>	
  </labelframe>
  
  <labelframe text="Center machine">
    <vbox>
      <hbox>
        <button>
          <halpin>"button2"</halpin>
          <text>"CamCtr3"</text>
          <font>('Helvitica',10)</font>
        </button>
        <button>
          <halpin>"button3"</halpin>
          <text>"CamCtr4"</text>
          <font>('Helvetica',10)</font>
        </button>
      </hbox>
      <hbox>
		<rectled>
          <halpin>"camcentered3"</halpin>
          <height>"6"</height>
          <width>"80"</width>
          <on_color>"green"</on_color>
          <off_color>"red"</off_color>
        </rectled>
        <rectled>
          <halpin>"camcentered4"</halpin>
          <height>"6"</height>
          <width>"80"</width>
          <on_color>"green"</on_color>
          <off_color>"red"</off_color>
        </rectled>
      </hbox>
    </vbox>
  </labelframe>

<!-- and last, the alignment stuff -->

  <labelframe text="Align Sheet">
    <button>
      <halpin>"align-start"</halpin>
      <text>"Align Start"</text> 
      <font>('Helvetica',8)</font>
    </button>
    <rectled>
      <halpin>"align-enabled"</halpin>
      <height>"6"</height>
      <width>"225"</width>
      <on_color>"green"</on_color>
      <off_color>"red"</off_color>
    </rectled>
  </labelframe>
  <labelframe text="Mark x and y">
    <vbox>
      <hbox>
        <button>
          <halpin>"align-x"</halpin>
          <text>"  Align X  "</text> 
          <font>('Helvetica',8)</font>
        </button>
        <button>
          <halpin>"align-y"</halpin>
          <text>"  Align Y  "</text> 
          <font>('Helvetica',8)</font>
        </button>
      </hbox>
      <hbox>
		<rectled>
          <halpin>"aligned-to_x"</halpin>
          <height>"6"</height>
          <width>"99"</width>
          <on_color>"green"</on_color>
          <off_color>"red"</off_color>
        </rectled>
        <rectled>
          <halpin>"aligned-to_y"</halpin>
          <height>"6"</height>
          <width>"99"</width>
          <on_color>"green"</on_color>
          <off_color>"red"</off_color>
        </rectled>
      </hbox>
    </vbox>
  </labelframe>

  <vbox>
    <hbox>
      <button>
        <halpin>"clear-offset"</halpin>
        <text>" Clear Offsets "</text> 
        <font>('Helvetica',8)</font>
      </button>
    </hbox>
  </vbox>
</pyvcp>
# These files are loaded post GUI, in the order they appear
source postgui.hal
# the following is added to your postgui.hal file.
# This must be loaded after the pyvcp buttons are created.

# spindle dial & status display
net spindle-rpm         =>      pyvcp.spindle_rpm
net hard-spndl-pwr      =>      pyvcp.on-led
net spindle-cw          =>      pyvcp.fwd-led
net spindle-ccw         =>      pyvcp.rev-led

# camview stuff, newer 2016 version?  And now 2017 version here
#net forOnNet           pyvcp.checkbutton1      forOn.in        forOff.in       
# camera position toggle but doesn't???
# MDI commands start at 00 in the order listed in the ini file.
#net cam1               forOn.out               halui.mdi-command-00    # move 
to tool 99 for camera usage. or back if on
#net cam2               forOff.out              halui.mdi-command-01    # move  
back to machine's tool
#net cam2               pyvcp.button1   halui.mdi-command-01    # Save most 
recent camera offset point, shove 4th off end of array
#net cam3               pyvcp.button2   halui.mdi-command-02    # center based 
on 3 points
#net cam4               pyvcp.button3   halui.mdi-command-03    # center based 
on 4 points
# align stuff but seems bass ackwards?
#net align-start        halui.mdi-command-04    pyvcp.align-start
#net align-y            halui.mdi-command-05    pyvcp.align-y
#net align-x            halui.mdi-command-06    pyvcp.align-x
#net clear-offset       halui.mdi-command-07    pyvcp.clear-offset

# hook up tally for in cam position, use m64 p0 to turn it green, m65 p0 to 
turn it red
#net led4 motion.digital.out-00 pyvcp.camactive # the leds control pin
# same idea for m64 p1, m65 p1 for camcentered3 and p2 for camcentered4
#net led5 motion.digital.out-01 pyvcp.camcentered3
#net led6 motion.digital.out-02 pyvcp.camcentered4
# and need a horizontal scale to show how many points are stored by 
_camstore.ngc
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Emc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-users

Reply via email to