Linear scale correction: homing to index

More
16 May 2014 22:25 - 16 May 2014 22:27 #46985 by Todd Zuercher
Ok here they are.
first is the scan when it errors.





next is a scan of rehoming when it does not error.



Attachments:
Last edit: 16 May 2014 22:27 by Todd Zuercher.

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

More
16 May 2014 23:17 - 16 May 2014 23:21 #46986 by Todd Zuercher
Here are the interesting bits of data from the halscope log files

first home
axis.0.motor-pos-cmd -0.90056175865191 axis.0.motor-pos-fb -0.90026276480807 axis.0.f-error -0.00032023879384 axis.0.index-enable +1.00000000000000 pid.x.output +0.75501974447387 (null) +0.00000000000000 (null) +0.00000000000000 (null) +0.00000000000000 
axis.0.motor-pos-cmd -0.90054051370191 axis.0.motor-pos-fb -0.90026276480807 axis.0.f-error -0.00029899384384 axis.0.index-enable +1.00000000000000 pid.x.output +0.75501974447387 (null) +0.00000000000000 (null) +0.00000000000000 (null) +0.00000000000000 
axis.0.motor-pos-cmd -0.90051926875191 axis.0.motor-pos-fb -0.90021367741631 axis.0.f-error -0.00032683628560 axis.0.index-enable +1.00000000000000 pid.x.output +0.68332437153908 (null) +0.00000000000000 (null) +0.00000000000000 (null) +0.00000000000000 
axis.0.motor-pos-cmd -0.90019604324952 axis.0.motor-pos-fb -0.90021367741631 axis.0.f-error +0.00000000000000 axis.0.index-enable +0.00000000000000 pid.x.output +0.70568971392504 (null) +0.00000000000000 (null) +0.00000000000000 (null) +0.00000000000000 
axis.0.motor-pos-cmd +0.00004908739176 axis.0.motor-pos-fb +0.00004908739176 axis.0.f-error -0.90024513064127 axis.0.index-enable +0.00000000000000 pid.x.output +0.00000000000000 (null) +0.00000000000000 (null) +0.00000000000000 (null) +0.00000000000000 
axis.0.motor-pos-cmd +0.00004908739176 axis.0.motor-pos-fb +0.00004908739176 axis.0.f-error +0.00000000000000 axis.0.index-enable +0.00000000000000 pid.x.output +0.00000000000000 (null) +0.00000000000000 (null) +0.00000000000000 (null) +0.00000000000000 
axis.0.motor-pos-cmd +0.00009817478351 axis.0.motor-pos-fb +0.00009817478351 axis.0.f-error -0.00004908739176 axis.0.index-enable +0.00000000000000 pid.x.output +0.00000000000000 (null) +0.00000000000000 (null) +0.00000000000000 (null) +0.00000000000000 
axis.0.motor-pos-cmd +0.00009817478351 axis.0.motor-pos-fb +0.00009817478351 axis.0.f-error +0.00000000000000 axis.0.index-enable +0.00000000000000 pid.x.output +0.00000000000000 (null) +0.00000000000000 (null) +0.00000000000000 (null) +0.00000000000000 

2nd home
axis.0.motor-pos-cmd -0.00019936658560 axis.0.motor-pos-fb -0.00009817478351 axis.0.f-error -0.00012243675208 axis.0.index-enable +1.00000000000000 pid.x.output +0.59577809168124 (null) +0.00000000000000 (null) +0.00000000000000 (null) +0.00000000000000 
axis.0.motor-pos-cmd -0.00017812163560 axis.0.motor-pos-fb -0.00004908739176 axis.0.f-error -0.00015027919384 axis.0.index-enable +1.00000000000000 pid.x.output +0.69876745628810 (null) +0.00000000000000 (null) +0.00000000000000 (null) +0.00000000000000 
axis.0.motor-pos-cmd -0.00015687668560 axis.0.motor-pos-fb -0.00004908739176 axis.0.f-error -0.00012903424384 axis.0.index-enable +1.00000000000000 pid.x.output +0.69876745628810 (null) +0.00000000000000 (null) +0.00000000000000 (null) +0.00000000000000 
axis.0.motor-pos-cmd -0.00013563173560 axis.0.motor-pos-fb +0.00000000000000 axis.0.f-error -0.00015687668560 axis.0.index-enable +1.00000000000000 pid.x.output +0.64174430191708 (null) +0.00000000000000 (null) +0.00000000000000 (null) +0.00000000000000 
axis.0.motor-pos-cmd +0.00001763416680 axis.0.motor-pos-fb +0.00000000000000 axis.0.f-error +0.00000000000000 axis.0.index-enable +0.00000000000000 pid.x.output +0.64174430191708 (null) +0.00000000000000 (null) +0.00000000000000 (null) +0.00000000000000 
axis.0.motor-pos-cmd +0.00003165755039 axis.0.motor-pos-fb +0.00004908739176 axis.0.f-error -0.00003145322496 axis.0.index-enable +0.00000000000000 pid.x.output -2.58818630098118 (null) +0.00000000000000 (null) +0.00000000000000 (null) +0.00000000000000 
axis.0.motor-pos-cmd +0.00004207015078 axis.0.motor-pos-fb +0.00004908739176 axis.0.f-error -0.00001742984137 axis.0.index-enable +0.00000000000000 pid.x.output -1.02336793814546 (null) +0.00000000000000 (null) +0.00000000000000 (null) +0.00000000000000 
axis.0.motor-pos-cmd +0.00004887196796 axis.0.motor-pos-fb +0.00004908739176 axis.0.f-error -0.00000701724098 axis.0.index-enable +0.00000000000000 pid.x.output -1.05854957534516 (null) +0.00000000000000 (null) +0.00000000000000 (null) +0.00000000000000 
Last edit: 16 May 2014 23:21 by Todd Zuercher.

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

More
17 May 2014 01:15 #46991 by PCW
Look likes something is wrong with the order of execution
Notice that your position is cleared one cycle late relative to mine:






This is with master
Attachments:

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

More
17 May 2014 02:52 #46993 by Todd Zuercher
Might this be as simple as an ordering problem in my hal file. or is it a deeper problem.

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

More
17 May 2014 03:41 #47001 by PCW
The basic thread ordering in the hal file you posted looks right (I assume this is the exact one you are using)
cradek on IRC suggested that you add the encoder position to the plot as this is a more direct indication of what
the hardware is doing.

On my test machine I tried linuxcnc 2.5.0, 2.5.4 and 2.7-pre0 and in all cases
index enable falling happens at the same time as the count is cleared (which is correct)

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

More
17 May 2014 03:56 #47002 by DaBit
I tried a fresh 'git clone git://git.linuxcnc.org/git/linuxcnc.git linuxcnc-dev' and build cycle. That is master, right?
Made no difference using the same HAL/INI; count is cleared one cycle after the falling edge of index-enable. Somehow I didn;t save the HALscope screenshot; will do that again.

I still have to try with a minimal config.

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

More
17 May 2014 03:59 - 17 May 2014 04:08 #47003 by PCW
what hal file did you start with?

(and I dont think this is linuxcnc version dependent as I tried 2.5.0, 2.5.4, and 2.7-pre0 with the same (correct) results)
Last edit: 17 May 2014 04:08 by PCW.

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

More
17 May 2014 04:15 #47004 by Todd Zuercher
Should be the one that I sent earlier.

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

More
17 May 2014 04:18 #47005 by DaBit
This is mine. As said before: I still have to check with a more minimal config.
BTW: AXIS says 2.7-pre0
# #######################################
#
# HAL file for DaBit's Stone-'n-Steel mill
# Derived from Ted Hyde's original hm2-servo config
#
# #####################################################################


# ###################################
# Core EMC/HAL Loads
# ###################################

# kinematics
loadrt trivkins

# motion controller, get name and thread periods from ini file
loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[TRAJ]AXES

# standard components
loadrt pid names=xservo_pid,y1servo_pid,y2servo_pid,xscale_pid
loadrt comp names=yjoints_comp
loadrt not names=yjointscomp_not,xhomed_not
loadrt or2 names=yjoint_faultgen_or2_1,yjoint_faultgen_or2_2,
loadrt and2 names=xminsw_and2,xmaxsw_and2
loadrt mux2 names=xposfb_mux2
loadrt offset names=offset_yjoints
loadrt debounce cfg=1

# hostmot2 driver
loadrt hostmot2

# load low-level driver
loadrt [HOSTMOT2](DRIVER) config=[HOSTMOT2](CONFIG)
setp hm2_[HOSTMOT2](BOARD).0.watchdog.timeout_ns 10000000


# ################################################
# THREADS
# ################################################

addf hm2_[HOSTMOT2](BOARD).0.read          	servo-thread

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

addf xservo_pid.do-pid-calcs			servo-thread
addf y1servo_pid.do-pid-calcs			servo-thread
addf y2servo_pid.do-pid-calcs			servo-thread
addf xscale_pid.do-pid-calcs			servo-thread

addf hm2_[HOSTMOT2](BOARD).0.write		servo-thread
addf hm2_[HOSTMOT2](BOARD).0.pet_watchdog	servo-thread

addf yjoints_comp				servo-thread  
addf yjointscomp_not				servo-thread  
addf xhomed_not					servo-thread
addf yjoint_faultgen_or2_1			servo-thread   
addf yjoint_faultgen_or2_2			servo-thread   
addf xminsw_and2				servo-thread
addf xmaxsw_and2				servo-thread
addf offset_yjoints.update-output 		servo-thread
addf offset_yjoints.update-feedback		servo-thread
addf debounce.0					servo-thread
addf xposfb_mux2				servo-thread

# ######################################################
# Axis-of-motion Specific Configs (not the GUI)
# ######################################################


# ################
# X [0] Axis
# ################

# axis enable chain
net xenable <= axis.0.amp-enable-out
net xenable => xservo_pid.enable 
net xenable => hm2_[HOSTMOT2](BOARD).0.7i77.0.1.analogena
 
# encoder feedback, rotary
setp hm2_[HOSTMOT2](BOARD).0.encoder.00.counter-mode 0
setp hm2_[HOSTMOT2](BOARD).0.encoder.00.filter 1
setp hm2_[HOSTMOT2](BOARD).0.encoder.00.index-invert 0
setp hm2_[HOSTMOT2](BOARD).0.encoder.00.index-mask 0
setp hm2_[HOSTMOT2](BOARD).0.encoder.00.index-mask-invert 0
setp hm2_[HOSTMOT2](BOARD).0.encoder.00.scale  [AXIS_0]INPUT_SCALE
net xpos-servo-fb hm2_[HOSTMOT2](BOARD).0.encoder.00.position => xservo_pid.feedback
net xvel <= hm2_[HOSTMOT2](BOARD).0.encoder.00.velocity => xservo_pid.feedback-deriv

# encoder feedback, linear
setp hm2_[HOSTMOT2](BOARD).0.encoder.03.counter-mode 0
setp hm2_[HOSTMOT2](BOARD).0.encoder.03.filter 1
setp hm2_[HOSTMOT2](BOARD).0.encoder.03.index-invert 0
setp hm2_[HOSTMOT2](BOARD).0.encoder.03.index-mask 0
setp hm2_[HOSTMOT2](BOARD).0.encoder.03.index-mask-invert 0
setp hm2_[HOSTMOT2](BOARD).0.encoder.03.scale  [AXIS_0]INPUT_SCALE_LINEAR

# index homing, position feedback and ferror suppression
setp debounce.0.delay 16
net xindex_enable hm2_[HOSTMOT2](BOARD).0.encoder.03.index-enable <=> hm2_[HOSTMOT2](BOARD).0.encoder.00.index-enable <=> axis.0.index-enable <=> xservo_pid.index-enable <=> xscale_pid.index-enable => debounce.0.0.in
net x-debounced-indexenable <= debounce.0.0.out => xposfb_mux2.sel
net xscalepos <= hm2_[HOSTMOT2](BOARD).0.encoder.03.position => xscale_pid.feedback => xposfb_mux2.in0
net xpos-fb <= xposfb_mux2.out => axis.0.motor-pos-fb

# set PID loop gains from inifile
setp xservo_pid.Pgain [AXIS_0]P
setp xservo_pid.Igain [AXIS_0]I
setp xservo_pid.Dgain [AXIS_0]D
setp xservo_pid.bias [AXIS_0]BIAS
setp xservo_pid.FF0 [AXIS_0]FF0
setp xservo_pid.FF1 [AXIS_0]FF1
setp xservo_pid.FF2 [AXIS_0]FF2
setp xservo_pid.deadband [AXIS_0]DEADBAND
setp xservo_pid.maxoutput [AXIS_0]MAX_OUTPUT
setp xservo_pid.error-previous-target 1

setp xscale_pid.Pgain [AXIS_0]SCALE_P
setp xscale_pid.Igain [AXIS_0]SCALE_I
setp xscale_pid.deadband [AXIS_0]SCALE_DEADBAND
setp xscale_pid.FF0 1.0
setp xscale_pid.maxerrorI [AXIS_0]SCALE_MAXCORR
setp xscale_pid.maxerror [AXIS_0]SCALE_MAXCORR
setp xscale_pid.enable TRUE

# position command signals

# linear scale position PID

net xpos-cmd axis.0.motor-pos-cmd => xscale_pid.command => xposfb_mux2.in1
net xpos-scalecorrected xscale_pid.output => xservo_pid.command

setp hm2_[HOSTMOT2](BOARD).0.7i77.0.1.analogout0-scalemax [AXIS_0]OUTPUT_SCALE
setp hm2_[HOSTMOT2](BOARD).0.7i77.0.1.analogout0-maxlim [AXIS_0]OUTPUT_SCALE
setp hm2_[HOSTMOT2](BOARD).0.7i77.0.1.analogout0-minlim [AXIS_0]OUTPUT_SCALE_NEG
net xmotor-command xservo_pid.output  =>  hm2_[HOSTMOT2](BOARD).0.7i77.0.1.analogout0

# Home switch/index logic
net homesw-x <= hm2_[HOSTMOT2](BOARD).0.7i77.0.0.input-08-not => axis.0.home-sw-in

# X-axis limit switch logic
net xminsw-x hm2_[HOSTMOT2](BOARD).0.7i77.0.0.input-09-not => xminsw_and2.in0
net homesw-x xmaxsw_and2.in0
net x-is-homed <= axis.0.homed => xhomed_not.in
net x-not-homed <= xhomed_not.out => xminsw_and2.in1 => xmaxsw_and2.in1
net x-minlimsw <= xminsw_and2.out => axis.0.neg-lim-sw-in
net x-maxlimsw <= xmaxsw_and2.out => axis.0.pos-lim-sw-in


# ################
# Y [1] Axis, joint 1
# ################

# axis enable chain
net yenable1 <= axis.1.amp-enable-out
net yenable1 => y1servo_pid.enable
 
# encoder feedback
setp hm2_[HOSTMOT2](BOARD).0.encoder.01.counter-mode 0
setp hm2_[HOSTMOT2](BOARD).0.encoder.01.filter 1
setp hm2_[HOSTMOT2](BOARD).0.encoder.01.index-invert 0
setp hm2_[HOSTMOT2](BOARD).0.encoder.01.index-mask 0
setp hm2_[HOSTMOT2](BOARD).0.encoder.01.index-mask-invert 0
setp  hm2_[HOSTMOT2](BOARD).0.encoder.01.scale  [AXIS_1]INPUT_SCALE
net ypos-fb1 hm2_[HOSTMOT2](BOARD).0.encoder.01.position => y1servo_pid.feedback
net ypos-fb1 => axis.1.motor-pos-fb 
net y1vel <= hm2_[HOSTMOT2](BOARD).0.encoder.01.velocity => y1servo_pid.feedback-deriv

# set PID loop gains from inifile
setp y1servo_pid.Pgain [AXIS_1]P
setp y1servo_pid.Igain [AXIS_1]I
setp y1servo_pid.Dgain [AXIS_1]D
setp y1servo_pid.bias [AXIS_1]BIAS
setp y1servo_pid.FF0 [AXIS_1]FF0
setp y1servo_pid.FF1 [AXIS_1]FF1
setp y1servo_pid.FF2 [AXIS_1]FF2
setp y1servo_pid.deadband [AXIS_1]DEADBAND
setp y1servo_pid.maxoutput [AXIS_1]MAX_OUTPUT
setp y1servo_pid.error-previous-target 1

# position command signals
setp hm2_[HOSTMOT2](BOARD).0.7i77.0.1.analogout1-scalemax [AXIS_1]OUTPUT_SCALE
setp hm2_[HOSTMOT2](BOARD).0.7i77.0.1.analogout1-maxlim [AXIS_1]OUTPUT_SCALE
setp hm2_[HOSTMOT2](BOARD).0.7i77.0.1.analogout1-minlim [AXIS_1]OUTPUT_SCALE_NEG

net ypos-cmd1 axis.1.motor-pos-cmd => y1servo_pid.command
net ymotor-command1  y1servo_pid.output  =>  hm2_[HOSTMOT2](BOARD).0.7i77.0.1.analogout1


# ################
# Y [2] Axis, joint 2
# ################

# axis enable chain
net yenable1 => y2servo_pid.enable
 
# encoder feedback
setp hm2_[HOSTMOT2](BOARD).0.encoder.02.counter-mode 0
setp hm2_[HOSTMOT2](BOARD).0.encoder.02.filter 1
setp hm2_[HOSTMOT2](BOARD).0.encoder.02.index-invert 0
setp hm2_[HOSTMOT2](BOARD).0.encoder.02.index-mask 0
setp hm2_[HOSTMOT2](BOARD).0.encoder.02.index-mask-invert 0
setp  hm2_[HOSTMOT2](BOARD).0.encoder.02.scale  [AXIS_1]INPUT_SCALE
net ypos-fb2-int hm2_[HOSTMOT2](BOARD).0.encoder.02.position => y2servo_pid.feedback => offset_yjoints.fb-in
net ypos-fb2 <= offset_yjoints.fb-out
net y2vel <= hm2_[HOSTMOT2](BOARD).0.encoder.02.velocity => y2servo_pid.feedback-deriv

# set PID loop gains from inifile
setp y2servo_pid.Pgain [AXIS_1]P
setp y2servo_pid.Igain [AXIS_1]I
setp y2servo_pid.Dgain [AXIS_1]D
setp y2servo_pid.bias [AXIS_1]BIAS
setp y2servo_pid.FF0 [AXIS_1]FF0
setp y2servo_pid.FF1 [AXIS_1]FF1
setp y2servo_pid.FF2 [AXIS_1]FF2
setp y2servo_pid.deadband [AXIS_1]DEADBAND
setp y2servo_pid.maxoutput [AXIS_1]MAX_OUTPUT
setp y2servo_pid.error-previous-target 1

# position command signals
setp hm2_[HOSTMOT2](BOARD).0.7i77.0.1.analogout2-scalemax [AXIS_1]OUTPUT_SCALE
setp hm2_[HOSTMOT2](BOARD).0.7i77.0.1.analogout2-maxlim [AXIS_1]OUTPUT_SCALE
setp hm2_[HOSTMOT2](BOARD).0.7i77.0.1.analogout2-minlim [AXIS_1]OUTPUT_SCALE_NEG

net ypos-cmd1 => offset_yjoints.in
net ypos2_offsetted <= offset_yjoints.out => y2servo_pid.command
net ymotor-command2  y2servo_pid.output  =>  hm2_[HOSTMOT2](BOARD).0.7i77.0.1.analogout2

# Y-axis joint2 offset/squaring logic
setp offset_yjoints.offset 0.0


# ################
# Z Axis
# ################

setp   hm2_5i25.0.stepgen.00.dirsetup        [AXIS_2]DIRSETUP
setp   hm2_5i25.0.stepgen.00.dirhold         [AXIS_2]DIRHOLD
setp   hm2_5i25.0.stepgen.00.steplen         [AXIS_2]STEPLEN
setp   hm2_5i25.0.stepgen.00.stepspace       [AXIS_2]STEPSPACE
setp   hm2_5i25.0.stepgen.00.position-scale  [AXIS_2]STEP_SCALE
setp   hm2_5i25.0.stepgen.00.step_type        0
setp   hm2_5i25.0.stepgen.00.control-type     0
setp   hm2_5i25.0.stepgen.00.maxaccel         [AXIS_2]STEPGEN_MAXACCEL
setp   hm2_5i25.0.stepgen.00.maxvel           [AXIS_2]MAX_VELOCITY

net z-pos-fb     axis.2.motor-pos-fb   <=  hm2_5i25.0.stepgen.00.position-fb
net z-pos-cmd    axis.2.motor-pos-cmd  =>  hm2_5i25.0.stepgen.00.position-cmd
net z-enable     axis.2.amp-enable-out =>  hm2_5i25.0.stepgen.00.enable

net homesw-z <= hm2_[HOSTMOT2](BOARD).0.7i77.0.0.input-14-not => axis.2.home-sw-in

# ################
# Y-axis position verification: check if the Y-axes don't deviate too much
# ################

net ypos-fb1 => yjoints_comp.in0
net ypos-fb2 => yjoints_comp.in1
setp yjoints_comp.hyst [AXIS_1]SLAVEAXES_MAXDEVIATION
net yaxes_equal yjoints_comp.equal => yjointscomp_not.in
net slavedaxes_err <= yjointscomp_not.out

# ################
# Amplifier fault logic. Also (mis)used to signal slaved Y-axes position deviation
# sets-es are there until servos are wired completely
# ################

net jointXampfault <= hm2_[HOSTMOT2](BOARD).0.7i77.0.0.input-01-not => axis.0.amp-fault-in

net jointY1ampfault <= hm2_[HOSTMOT2](BOARD).0.7i77.0.0.input-02-not => yjoint_faultgen_or2_1.in0
net jointY2ampfault <= hm2_[HOSTMOT2](BOARD).0.7i77.0.0.input-03-not => yjoint_faultgen_or2_1.in1
net yjoints-ampfault <= yjoint_faultgen_or2_1.out => yjoint_faultgen_or2_2.in0
net slavedaxes_err => yjoint_faultgen_or2_2.in1
net jointYampfault_p <= yjoint_faultgen_or2_2.out => axis.1.amp-fault-in

net jointZampfault => axis.2.amp-fault-in
sets jointZampfault 0


# ################
# EStop chain.
# ################

net estop-out <= iocontrol.0.user-enable-out
net estop-ext => iocontrol.0.emc-enable-in <= hm2_[HOSTMOT2](BOARD).0.7i77.0.0.input-00

# ################
# Motor power relay control
# ################

#net motor-power => hm2_[HOSTMOT2](BOARD).0.7i77.0.0.output-00
#sets motor-power FALSE
net estop-ext <= hm2_[HOSTMOT2](BOARD).0.7i77.0.0.output-00

# ################
# Toolchanger
# ################

loadusr -W hal_manualtoolchange
net tool-change iocontrol.0.tool-change => hal_manualtoolchange.change
net tool-changed iocontrol.0.tool-changed <= hal_manualtoolchange.changed
net tool-number iocontrol.0.tool-prep-number => hal_manualtoolchange.number
net tool-prepare-loopback iocontrol.0.tool-prepare => iocontrol.0.tool-prepared

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

More
17 May 2014 05:03 #47006 by PCW
I dont see any that show encoder pins

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

Time to create page: 0.146 seconds
Powered by Kunena Forum