Category: General LinuxCNC Questions
doing some test I got this question. what is wrong with this script ?
# =============================================
# Configuración básica de hardware y componentes
# =============================================
loadrt hostmot2
loadrt hm2_rpspi config="num_encoders=1 num_pwmgens=0 num_stepgens=5 sserial_port_0=00xxxxxx"
setp hm2_7c80.0.watchdog.timeout_ns 5000000
loadusr -W hal_input -KRAL GreenAsia
# =============================================
# Componentes para control y filtrado
# =============================================
loadrt pid names=pid.x,pid.y,pid.z,pid.a,pid.b,pid.s
loadrt abs names=abs.spindle
loadrt lowpass names=lowpass.spindle
loadrt mux16 names=jogspeed,mvoincr
# Componentes para cálculo de velocidad/aceleración
loadrt ddt names=ddt_x,ddt_xv,ddt_y,ddt_yv,ddt_z,ddt_zv
loadrt hypot names=vel_xy,vel_xyz
# =============================================
# Hilos de ejecución en tiempo real
# =============================================
addf hm2_7c80.0.read servo-thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread
# Hilos para PID
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.b.do-pid-calcs servo-thread
addf pid.s.do-pid-calcs servo-thread
# Hilos para utilidades
addf jogspeed servo-thread
addf mvoincr servo-thread
addf abs.spindle servo-thread
addf lowpass.spindle servo-thread
# Hilos para cálculo de velocidad
addf ddt_x servo-thread
addf ddt_xv servo-thread
addf ddt_y servo-thread
addf ddt_yv servo-thread
addf ddt_z servo-thread
addf ddt_zv servo-thread
addf vel_xy servo-thread
addf vel_xyz servo-thread
addf hm2_7c80.0.write servo-thread
# =============================================
# Configuración de hardware Mesa 7i80
# =============================================
setp hm2_7c80.0.dpll.01.timer-us -50
setp hm2_7c80.0.stepgen.timer-number 1
# =============================================
# Configuración del eje X (ejemplo para servomotor)
# =============================================
# Parámetros 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 0.000500
# Conexiones PID
net x-index-enable => pid.x.index-enable
net x-enable => pid.x.enable
net x-pos-cmd => pid.x.command
net x-pos-fb => pid.x.feedback
net x-output <= pid.x.output
# Configuración StepGen para servo (modo velocidad)
setp hm2_7c80.0.stepgen.00.dirsetup [JOINT_0]DIRSETUP
setp hm2_7c80.0.stepgen.00.dirhold [JOINT_0]DIRHOLD
setp hm2_7c80.0.stepgen.00.steplen [JOINT_0]STEPLEN
setp hm2_7c80.0.stepgen.00.stepspace [JOINT_0]STEPSPACE
setp hm2_7c80.0.stepgen.00.position-scale [JOINT_0]STEP_SCALE
setp hm2_7c80.0.stepgen.00.step_type 0
setp hm2_7c80.0.stepgen.00.control-type 1 # Modo velocidad
setp hm2_7c80.0.stepgen.00.maxaccel [JOINT_0]STEPGEN_MAXACCEL
setp hm2_7c80.0.stepgen.00.maxvel [JOINT_0]STEPGEN_MAXVEL
# Conexiones para control en lazo cerrado
net x-pos-cmd <= joint.0.motor-pos-cmd
net x-vel-cmd <= joint.0.vel-cmd
net x-output => hm2_7c80.0.stepgen.00.velocity-cmd
net x-pos-fb <= hm2_7c80.0.stepgen.00.position-fb
net x-pos-fb => joint.0.motor-pos-fb
net x-enable <= joint.0.amp-enable-out
net x-enable => hm2_7c80.0.stepgen.00.enable
# =============================================
# Cálculo de velocidad/aceleración con ddt
# =============================================
# Conexiones para eje X
net Xpos joint.0.motor-pos-cmd => joint.0.motor-pos-fb ddt_x.in
net Xvel ddt_x.out => ddt_xv.in vel_xy.in0
net Xacc <= ddt_xv.out
# Conexiones para ejes Y y Z (similar a X)
net Ypos joint.1.motor-pos-cmd => joint.1.motor-pos-fb ddt_y.in
net Yvel ddt_y.out => ddt_yv.in vel_xy.in1
net Yacc <= ddt_yv.out
net Zpos joint.2.motor-pos-cmd => joint.2.motor-pos-fb ddt_z.in
net Zvel ddt_z.out => ddt_zv.in vel_xyz.in0
net Zacc <= ddt_zv.out
# Ejes rotacionales (sin ddt)
net Apos joint.3.motor-pos-cmd => joint.3.motor-pos-fb
net Cpos joint.4.motor-pos-cmd => joint.4.motor-pos-fb
# Velocidades cartesianas combinadas
net XYvel vel_xy.out => vel_xyz.in1
net XYZvel <= vel_xyz.out
# =============================================
# Habilitar hardware
# =============================================
setp hm2_7c80.0.stepgen.00.enable 1
Do hit the right way to get the 5 axis cnc configure ?
can someone help me with it?
thanks!!