Category: Driver Boards
Ah yes I see it now. I have assigned it to a timer, now I'm seeing the 8us request pulse on the scope at 3 volts (is that correct?). No response from the encoder yet and I'm getting this error, I'll have to check the wiring:
Here's where I made it to with the .hal thus far for those who may be on a similar path:
# fanuc encoder test .hal
# kinematics
loadrt [KINS](KINEMATICS)
# motion controller
loadrt [EMCMOT](EMCMOT) servo_period_nsec=[EMCMOT](SERVO_PERIOD) num_joints=[KINS](JOINTS)
# hostmot2 driver
loadrt hostmot2
loadrt [HM2](DRIVER) board_ip=[HM2](ADDRESS) config="num_dplls=-1 num_encoders=1 fanuc_chan_0=AA64 sserial_port_0=00000000"
setp hm2_[MESA](BOARD).0.watchdog.timeout_ns 5000000
setp hm2_7i97.0.dpll.01.timer-us -200
setp hm2_[MESA](BOARD).0.fanuc.00.timer-number 1
loadrt pid names=pid.x
# THREADS
addf hm2_[MESA](BOARD).0.read servo-thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread
addf pid.x.do-pid-calcs servo-thread
addf hm2_[MESA](BOARD).0.write servo-thread
# amp enable
net motion-enable <= motion.motion-enabled
# Global PWM setup
setp hm2_[MESA](BOARD).0.pwmgen.pwm_frequency 48000
# Board: 7i97
# Axis: X Joint: 0 Output: 0
# PID Setup
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
# joint-0 enable chain
net joint-0-index-enable <=> pid.x.index-enable
net joint-0-index-enable <=> joint.0.index-enable
net joint-0-index-enable <=> hm2_[MESA](BOARD).0.encoder.00.index-enable
net joint-0-enable <= joint.0.amp-enable-out
net joint-0-enable => pid.x.enable
net joint-0-enable => hm2_[MESA](BOARD).0.pwmgen.00.enable
# PWM Generator setup
setp hm2_[MESA](BOARD).0.pwmgen.00.output-type 1 #PWM pin0
setp hm2_[MESA](BOARD).0.pwmgen.00.offset-mode 1 # offset mode so 50% = 0
setp hm2_[MESA](BOARD).0.pwmgen.00.scale [JOINT_0]SCALE
# ---Encoder feedback signals/setup---
setp hm2_[MESA](BOARD).0.encoder.00.counter-mode 0
setp hm2_[MESA](BOARD).0.encoder.00.filter 1
setp hm2_[MESA](BOARD).0.encoder.00.index-invert 0
setp hm2_[MESA](BOARD).0.encoder.00.index-mask 0
setp hm2_[MESA](BOARD).0.encoder.00.index-mask-invert 0
setp hm2_[MESA](BOARD).0.encoder.00.scale [JOINT_0]ENCODER_SCALE
# position command and feedback
net joint-0-pos-cmd <= joint.0.motor-pos-cmd
net joint-0-pos-cmd => pid.x.command
net joint-0-pos-fb <= hm2_[MESA](BOARD).0.encoder.00.position
net joint-0-pos-fb => joint.0.motor-pos-fb
net joint-0-pos-fb => pid.x.feedback
# PID Output
net joint.0.output <= pid.x.output
net joint.0.output => hm2_[MESA](BOARD).0.pwmgen.00.value
# Encoder Setup
setp hm2_[MESA](BOARD).0.encoder.00.scale [JOINT_0](ENCODER_SCALE)
setp hm2_[MESA](BOARD).0.encoder.00.counter-mode 0
setp hm2_[MESA](BOARD).0.encoder.00.filter 1
setp hm2_[MESA](BOARD).0.encoder.00.index-invert 0
setp hm2_[MESA](BOARD).0.encoder.00.index-mask 0
setp hm2_[MESA](BOARD).0.encoder.00.index-mask-invert 0
# Standard I/O Block - EStop, Etc
# create a signal for the estop loopback
net estop-loopback iocontrol.0.emc-enable-in <= iocontrol.0.user-enable-out