Fanuc Serial Pulse Coders - Red cap servos, mesa 7i76e, how to?

  • bnet
  • bnet's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
13 Oct 2025 02:49 #336358 by bnet
Here's a version that uses the digitally settable preset velocity mode to seek for the index of the encoder:
# =====================================================
#  LinuxCNC HAL — Ultra3000 preset velocity index seek
#  Board: 7i76e main + 7i84 (outputs) + 7i85 (encoder)
#  Axis: X
# =====================================================

loadrt threads name1=servo-thread period1=1000000

# --- Load components ---
loadrt bldc count=1
loadrt encoder num_chan=1
loadrt mux2 count=1
loadrt and2 count=1
loadrt not count=1
loadrt timedelay count=1
loadrt oneshot count=1

addf encoder.update servo-thread
addf bldc servo-thread
addf timedelay servo-thread
addf oneshot servo-thread

# =====================================================
#  Encoder setup (7i85)
# =====================================================
setp hm2_7i85.0.encoder.00.scale 800
setp hm2_7i85.0.encoder.00.counter-mode 0
setp hm2_7i85.0.encoder.00.filter 1

net x-enc-a     hm2_7i85.0.encoder.00.input-a
net x-enc-b     hm2_7i85.0.encoder.00.input-b
net x-enc-z     hm2_7i85.0.encoder.00.input-index

# =====================================================
#  BLDC Hall synthesis (for Ultra3000 commutation)
# =====================================================
# 8-pole motor = 4 pole pairs
setp bldc.0.pole-pairs 4
setp bldc.0.encoder-scale 800
setp bldc.0.hall-offset 0      # will be updated after index alignment

net x-enc-pos       hm2_7i85.0.encoder.00.position => bldc.0.enc-pos
net hall-u          bldc.0.hall-u => hm2_7i84.0.output-00
net hall-v          bldc.0.hall-v => hm2_7i84.0.output-01
net hall-w          bldc.0.hall-w => hm2_7i84.0.output-02

# =====================================================
#  Preset Velocity Control Output (7i84)
# =====================================================
# Choose an available output (here output-03)
net preset-vel-enable => hm2_7i84.0.output-03

# =====================================================
#  Step/Dir control enable (7i76e stepgen 0)
# =====================================================
net stepgen-enable => hm2_7i76e.0.stepgen.00.enable

# =====================================================
#  State control logic for startup alignment
# =====================================================

# --- Delay after power-up before preset allowed ---
setp timedelay.0.on-delay 0.25
net startup-delay timedelay.0.out => preset-allow
net always-true timedelay.0.in <= true

# --- Oneshoot from encoder index detection ---
setp oneshot.0.width 0.05
net x-enc-index hm2_7i85.0.encoder.00.index => oneshot.0.in
net index-found oneshot.0.out

# --- Preset velocity enable logic ---
# When not yet found index and startup delay done -> enable preset rotation
loadrt and2 count=1
net not-found-delay and2.0.in0 <= preset-allow
net not-found-delay and2.0.in1 <= not-index-found
net preset-active and2.0.out => hm2_7i84.0.output-03

# --- index found logic ---
loadrt not count=1
net index-found oneshot.0.out => not.0.in
net not-index-found not.0.out

# --- On index detection, disable preset and enable stepgen ---
net index-found stepgen-enable
# (this ties directly; optionally route through another delay)

Please Log in or Create an account to join the conversation.

Moderators: PCWjmelson
Time to create page: 0.068 seconds
Powered by Kunena Forum