Step or velocity control for servo gantry

More
14 Apr 2016 09:55 - 14 Apr 2016 09:56 #73287 by crisiacuf
Long time no see :)
Been working on the gantry lately.
Velocity control seems to work very good after pid setup and such.
I tried to escape the problems induced by paralleling two joints in linuxcnc and used the Y master encoder output as the Y slave axis input as it seems bulletproof, but i have a delay as expected because of the MR J2S servo drive processing.
The problem is that this delay is bigger than expected and gives me noticeable squaring errors.

So back to hal configuration.
I am now using my X and Z axis to simulate the two Y joints that makeup my Y axis and adapted the Y part paralleling part from SnSmill hal writen by DaBit(thank you again for your work) in my hal.

It works in normal conditions, X and Z move as expected, in parallel, but if I stop my Z axis(using the amplifier max or min limit) no error is reported altough more than 1mm is the position error between the two.
More than that, after I release the motor to move freely it's racing in the direction it couldn't move and hits the software limit.

File Attachment:

File Name: machine5.hal
File Size:16 KB
#*******************
#  AXIS Yd [1], joint 1
#*******************

# axis enable chain
net yenable1 <= axis.1.amp-enable-out
net yenable1 => pid.yd.enable



setp   pid.yd.Pgain     [AXIS_1]P
setp   pid.yd.Igain     [AXIS_1]I
setp   pid.yd.Dgain     [AXIS_1]D
setp   pid.yd.bias      [AXIS_1]BIAS
setp   pid.yd.FF0       [AXIS_1]FF0
setp   pid.yd.FF1       [AXIS_1]FF1
setp   pid.yd.FF2       [AXIS_1]FF2
setp   pid.yd.deadband  [AXIS_1]DEADBAND
setp   pid.yd.maxoutput [AXIS_1]MAX_OUTPUT
setp   pid.yd.error-previous-target true

net yd-index-enable  <=> pid.yd.index-enable
#net yd-enable        =>  pid.yd.enable
#net yd-pos-cmd       =>  pid.yd.command
#net yd-vel-cmd       =>  pid.yd.command-deriv
#net yd-pos-fb        =>  pid.yd.feedback
#net yd-output        =>  pid.yd.output

# ---PWM Generator signals/setup---

setp   hm2_5i25.0.7i77.0.1.analogout3-scalemax  [AXIS_1]OUTPUT_SCALE
setp   hm2_5i25.0.7i77.0.1.analogout3-minlim    [AXIS_1]OUTPUT_MIN_LIMIT
setp   hm2_5i25.0.7i77.0.1.analogout3-maxlim    [AXIS_1]OUTPUT_MAX_LIMIT

net ypos-cmd1 axis.1.motor-pos-cmd => pid.yd.command


net yd-output     pid.yd.output                         => hm2_5i25.0.7i77.0.1.analogout2





# ---Encoder feedback signals/setup---

setp    hm2_5i25.0.encoder.00.counter-mode 0
setp    hm2_5i25.0.encoder.00.filter 1
setp    hm2_5i25.0.encoder.00.index-invert 0
setp    hm2_5i25.0.encoder.00.index-mask 0
setp    hm2_5i25.0.encoder.00.index-mask-invert 0
setp    hm2_5i25.0.encoder.00.scale  [AXIS_1]ENCODER_SCALE

net yd-pos-fb               <=  hm2_5i25.0.encoder.00.position => pid.yd.feedback
net yd-vel-fb               <=  hm2_5i25.0.encoder.00.velocity => pid.yd.feedback-deriv

net yd-pos-fb               =>  axis.1.motor-pos-fb
net yd-index-enable    axis.1.index-enable  <=>  hm2_5i25.0.encoder.00.index-enable
net yd-pos-rawcounts        <=  hm2_5i25.0.encoder.00.rawcounts

# ---setup home / limit switch signals---

net home-yd     =>  axis.1.home-sw-in
net min-yd     =>  axis.1.neg-lim-sw-in
net max-yd     =>  axis.1.pos-lim-sw-in


#*******************
#  AXIS Ys [2], joint 2
#*******************

# axis enable chain
net yenable1 => pid.ys.enable



setp   pid.ys.Pgain     [AXIS_1]P
setp   pid.ys.Igain     [AXIS_1]I
setp   pid.ys.Dgain     [AXIS_1]D
setp   pid.ys.bias      [AXIS_1]BIAS
setp   pid.ys.FF0       [AXIS_1]FF0
setp   pid.ys.FF1       [AXIS_1]FF1
setp   pid.ys.FF2       [AXIS_1]FF2
setp   pid.ys.deadband  [AXIS_1]DEADBAND
setp   pid.ys.maxoutput [AXIS_1]MAX_OUTPUT
setp   pid.ys.error-previous-target true

net ys-index-enable  <=> pid.ys.index-enable
#net ys-enable        =>  pid.ys.enable
#net ys-pos-cmd       =>  pid.ys.command
#net ys-vel-cmd       =>  pid.ys.command-deriv
#net ys-pos-fb        =>  pid.ys.feedback
#net ys-output        =>  pid.ys.output

# ---PWM Generator signals/setup---

setp   hm2_5i25.0.7i77.0.1.analogout0-scalemax  [AXIS_1]OUTPUT_SCALE
setp   hm2_5i25.0.7i77.0.1.analogout0-minlim    [AXIS_1]OUTPUT_MIN_LIMIT
setp   hm2_5i25.0.7i77.0.1.analogout0-maxlim    [AXIS_1]OUTPUT_MAX_LIMIT


# ---Encoder feedback signals/setup---

setp    hm2_5i25.0.encoder.02.counter-mode 0
setp    hm2_5i25.0.encoder.02.filter 1
setp    hm2_5i25.0.encoder.02.index-invert 0
setp    hm2_5i25.0.encoder.02.index-mask 0
setp    hm2_5i25.0.encoder.02.index-mask-invert 0
setp    hm2_5i25.0.encoder.02.scale  [AXIS_1]ENCODER_SCALE

net ys-pos-fb-int           <=  hm2_5i25.0.encoder.02.position => pid.ys.feedback => offset_yjoints.fb-in
net ys-pos-fb <= offset_yjoints.fb-out

net ys-vel-fb               <=  hm2_5i25.0.encoder.02.velocity => pid.ys.feedback-deriv

net ypos-cmd1 => offset_yjoints.in
net ypos2_offsetted <= offset_yjoints.out => pid.ys.command
net ymotor-command2  pid.ys.output  =>  hm2_5i25.0.7i77.0.1.analogout4



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




#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 jointY1ampfault <= hm2_5i25.0.7i77.0.0.input-16  => yjoint_faultgen_or2_1.in0
net jointY2ampfault <= hm2_5i25.0.7i77.0.0.input-17  => 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
Can anyone help me spot the problem in my Y axis setup?
Attachments:
Last edit: 14 Apr 2016 09:56 by crisiacuf.

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

More
14 Apr 2016 09:57 #73288 by andypugh
Have a look at the "gantry" component:
linuxcnc.org/docs/2.7/html/man/man9/gantry.9.html

Better still would be to use gentrivkins and the Joints-Axes branch of LinuxCNC.

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

Time to create page: 0.058 seconds
Powered by Kunena Forum