Implementing Spindle Homing for DELTA C2000 Plus (In)correctly?

More
28 Jun 2025 15:55 #330961 by Marko6
Hi stenly,

could you tell me how you got on with it? Also, if you have a working CSV - Ethercat, I would be very happy if you could send it to me. I have some problems getting it to work.

I can get the drive turned on (C2000 + EC01 + PG01L) , but I can't set the speed. I can't find anything that works.

Thanks. BR,
Pavel

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

  • MKUltra
  • MKUltra's Avatar
  • Visitor
  • Visitor
03 Jul 2025 19:18 #331181 by MKUltra
Hi I did some corrections for you, definitely will work now

###########################################################
#  cia402.hal – Corrected and functional version

#  • Slave-0..2 = X,Y,Z in CSP (Cyclic Synchronous Position)
#  • Slave-3    = Spindle in CSV (Cyclic Synchronous Velocity)
#  • LinuxCNC 2.9+ · EtherLab lcec · servo-thread 1 ms
###########################################################

######################## 1. Real-time & Userspace Components ###
loadrt [KINS]KINEMATICS
loadrt [EMCMOT]EMCMOT    servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[KINS]JOINTS

loadusr -W lcec_conf ethercat-conf.xml
loadrt  lcec
loadrt  cia402 count=4               # 0,1,2 = axes | 3 = spindle

# Scaling for spindle speed command & feedback
loadrt scale            names=spin_cmd_scaler,spin_fb_scaler
loadrt conv_s32_float   names=spin_fb_converter

######################## 2. Add Functions to Servo Thread ###
addf lcec.read-all             servo-thread
addf cia402.0.read-all         servo-thread
addf cia402.1.read-all         servo-thread
addf cia402.2.read-all         servo-thread
addf cia402.3.read-all         servo-thread

# Process spindle feedback
addf spin_fb_converter         servo-thread
addf spin_fb_scaler            servo-thread

addf motion-command-handler    servo-thread
addf motion-controller         servo-thread

# Prepare spindle command
addf spin_cmd_scaler           servo-thread

# Write data back to drives
addf cia402.0.write-all        servo-thread
addf cia402.1.write-all        servo-thread
addf cia402.2.write-all        servo-thread
addf cia402.3.write-all        servo-thread
addf lcec.write-all            servo-thread

######################## 3. Global Settings & Parameters ###
# --- X/Y/Z axes in CSP mode ---
setp cia402.0.csp-mode 1
setp cia402.1.csp-mode 1
setp cia402.2.csp-mode 1

setp cia402.0.pos-scale 26214  # match your encoder counts
setp cia402.1.pos-scale 26214
setp cia402.2.pos-scale 26214

# --- Spindle in CSV mode ---
setp cia402.3.csp-mode   0
setp cia402.3.velo-scale 2048

# Gain for 0.1 RPM units ↔ RPM
setp spin_cmd_scaler.gain 10.0   # 1 RPM → 10 (0.1 RPM units)
setp spin_fb_scaler.gain  0.1    # 10 (0.1 RPM units) → 1 RPM

######################## 4. EtherCAT PDO Mapping ########

## X-Axis (slave-0)
net x-stw    lcec.0.0.cia-statusword      => cia402.0.statusword
net x-opdisp lcec.0.0.opmode-display     => cia402.0.opmode-display
net x-actpos lcec.0.0.actual-position    => cia402.0.drv-actual-position
net x-ctlw   cia402.0.controlword        => lcec.0.0.cia-controlword
net x-opcmd  cia402.0.opmode              => lcec.0.0.opmode
net x-tgtpos cia402.0.drv-target-position => lcec.0.0.target-position

## Y-Axis (slave-1)
net y-stw    lcec.0.1.cia-statusword      => cia402.1.statusword
net y-opdisp lcec.0.1.opmode-display     => cia402.1.opmode-display
net y-actpos lcec.0.1.actual-position    => cia402.1.drv-actual-position
net y-ctlw   cia402.1.controlword        => lcec.0.1.cia-controlword
net y-opcmd  cia402.1.opmode              => lcec.0.1.opmode
net y-tgtpos cia402.1.drv-target-position => lcec.0.1.target-position

## Z-Axis (slave-2)
net z-stw    lcec.0.2.cia-statusword      => cia402.2.statusword
net z-opdisp lcec.0.2.opmode-display     => cia402.2.opmode-display
net z-actpos lcec.0.2.actual-position    => cia402.2.drv-actual-position
net z-ctlw   cia402.2.controlword        => lcec.0.2.cia-controlword
net z-opcmd  cia402.2.opmode              => lcec.0.2.opmode
net z-tgtpos cia402.2.drv-target-position => lcec.0.2.target-position

## Spindle (slave-3)
net s-stw    lcec.0.3.cia-statusword      => cia402.3.statusword
net s-opdisp lcec.0.3.opmode-display     => cia402.3.opmode-display
net s-ctlw   cia402.3.controlword         => lcec.0.3.cia-controlword
net s-opcmd  cia402.3.opmode              => lcec.0.3.opmode

# — Velocity feedback: Drive → HAL → LinuxCNC
net s-vel-raw   lcec.0.3.actual-velocity    => spin_fb_converter.in \
                                             => cia402.3.drv-actual-velocity
net s-vel-float spin_fb_converter.out      => spin_fb_scaler.in

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

Time to create page: 0.154 seconds
Powered by Kunena Forum