Category: General LinuxCNC Questions
I moved wires around on my BOB so that the encoders are connected to the proper inputs on the Mesa 7i92.. I made some changes to the .HAL file. I got several things working:
1) The spindle speed shows up on my display, and matches what I see on my separate DRO, even at 2,000 RPM.
2) Based on Tommylight's earlier question, I figured out why my HalScope was running at 250Hz (double click on samples button, and changed divisor from 4 to 1. That change made the missed pulses go away completely, and validated my cheap Chinese BOB was not glitching.This is the first time I've ever seen 180 pulses per revolution on the HalScope.
3) I used a stopwatch to time 10 seconds, and watched hm2_7i92.0.encoder.00.count. I had calculated I should get 1440 pulses in 10 seconds at 48 rpm, and that's almost exactly what the difference was in the pulse counts before and after. That means that all the pulses are all being seen! I figured out later that I also could just rotate the chuck by hand, and see 180 counts per revolution.
The only remaining problem I have is that something is mis-configured in my .HAL. When I try to thread, the cutter moves in to position, and is either not receiving the index pulse to start or the 180 pulses per revolution or both, and is not starting to thread.
loadrt [KINS]KINEMATICS
#autoconverted trivkins
loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[KINS]JOINTS
loadrt pid names=pid.x,pid.z,pid.s
loadrt hostmot2
loadrt [HOSTMOT2]DRIVER config=[HOSTMOT2]CONFIG
#setp hm2_7i92.0.watchdog.timeout_ns 25000000
setp hm2_7i92.0.watchdog.timeout_ns 10000000
#loadrt encoder num_chan=1
loadrt abs count=1
#0-invert is used in pendant hal file
loadrt scale names=scale.0,0-invert
loadrt lowpass count=1
addf hm2_7i92.0.read servo-thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread
#addf encoder.update-counters servo-thread
addf pid.x.do-pid-calcs servo-thread
addf pid.z.do-pid-calcs servo-thread
addf pid.s.do-pid-calcs servo-thread
addf hm2_7i92.0.write servo-thread
#addf encoder.capture-position servo-thread
addf abs.0 servo-thread
addf scale.0 servo-thread
addf lowpass.0 servo-thread
# latch all stepgen position counts 50 usec before nominal read time (add per PCW):
setp hm2_7i92.0.dpll.01.timer-us -50
setp hm2_7i92.0.stepgen.timer-number 1
# increase tolerance to read errors
# setp hm2_7i92.0.packet-read-timeout 30 --removed per pcw 12/25/24
setp hm2_7i92.0.packet-error-limit 100
# ---setup spindle---
# set the HAL encoder to 180 pulses per revolution.
setp hm2_7i92.0.encoder.00.scale 180
# set the encoder to non-quadrature simple counting using A only.
setp hm2_7i92.0.encoder.00.counter-mode true
# connect the HAL encoder outputs to LinuxCNC
net spindle-position hm2_7i92.0.encoder.00.position => spindle.0.revs
net spindle-at-speed => spindle.0.at-speed
net spindle-velocity-feedback-rps hm2_7i92.0.encoder.00.velocity => spindle.0.speed-in
net spindle-index-enable hm2_7i92.0.encoder.00.index-enable <=> spindle.0.index-enable
net spindle-phase-a hm2_7i92.0.encoder.00.input-a
#net spindle-phase-b hm2_7i92.0.encoder.00.input-b
net spindle-index hm2_7i92.0.encoder.00.input-index
# ---probe signal---
net probe motion.probe-input <= hm2_7i92.0.gpio.020.in
# --- ESTOP-EXT ---
net estop-ext <= hm2_7i92.0.gpio.014.in_not
# --- BOTH-HOME ---
net both-home-x <= hm2_7i92.0.gpio.016.in
net both-home-z <= hm2_7i92.0.gpio.003.in_not