Config HAL with encoder and step/dir

More
01 Jun 2010 07:14 #3053 by wmaeder
Hello,

Our hardware configuration is:
- one drive controled by step/dir
- one encoder returning the real position (exact position verified)

In the HAL we use:
- the stepgen component with the output (step / dir) connected to the drive input (step / dir)
- the input of stepgen is connected to "axis.0.motor-pos-cmd "
- the output of the encoder is connected to "axis.0.motor-pos-fb"

Whatever is the value returned by the encoder, the input of stepgen does not change and there is no correction of the error
(this results in a slow drift of the axe).

We thought that the emcmot (axis) component generated a regulation between the instruction and the error of position.
Does anybody know how to solve this problem ? What component to use with this configuration ?

Thank you very much for all suggestion.
Willy

HAL configuration with MESA 5i20 and hm2:


loadrt trivkins
loadrt [EMCMOT]EMCMOT base_period_nsec=[EMCMOT]BASE_PERIOD servo_period_nsec=[EMCMOT]SERVO_PERIOD traj_period_nsec=[EMCMOT]SERVO_PERIOD key=[EMCMOT]SHMEM_KEY num_joints=[TRAJ]AXES
loadrt hostmot2
loadrt hm2_pci config="firmware=hm2/5i20/SVST2_4_7I47.BIT num_encoders=1 num_pwmgens=0 num_stepgens=1"

# read inputs
addf hm2_5i20.0.read servo-thread

# write outputs
addf hm2_5i20.0.write servo-thread

# handle motion commands
addf motion-command-handler servo-thread

# run the motion controller
addf motion-controller servo-thread

###############################################
# Encoder
###############################################
# Get feedback scaling from ini file.
setp hm2_5i20.0.encoder.00.scale [AXIS_0]INPUT_SCALE

# connect position feedback from step generators to motion module
net Xpos-fb hm2_5i20.0.encoder.00.position => axis.0.motor-pos-fb

# Connect index enables to motion controller, for homing.
net Xindex-enable hm2_5i20.0.encoder.00.index-enable <=> axis.0.index-enable

###############################################
# STEPGEN
###############################################
setp hm2_5i20.0.stepgen.00.dirsetup 2500
setp hm2_5i20.0.stepgen.00.dirhold 2500
setp hm2_5i20.0.stepgen.00.steplen 2500
setp hm2_5i20.0.stepgen.00.stepspace 2500
setp hm2_5i20.0.stepgen.00.position-scale [AXIS_0]SCALE
setp hm2_5i20.0.stepgen.00.maxaccel [AXIS_0]STEPGEN_MAXACCEL
#setp hm2_5i20.0.stepgen.00.maxvel [AXIS_0]STEPGEN_MAXVEL

# connect position commands from motion module to step generator
net Xpos-cmd axis.0.motor-pos-cmd => hm2_5i20.0.stepgen.00.position-cmd

# connect enable signals for step generators
net xenable axis.0.amp-enable-out => hm2_5i20.0.stepgen.00.enable

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

  • moopy
  • moopy's Avatar
  • Visitor
  • Visitor
25 Jul 2010 09:15 #3483 by moopy
Replied by moopy on topic Re:Config HAL with encoder and step/dir
i was considering trying a setup like you describe, did you get it working?

could you show configuration for your solution?

I imagine you should maybe use a PID?

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

More
25 Jul 2010 11:20 #3484 by andypugh
wmaeder wrote:

Whatever is the value returned by the encoder, the input of stepgen does not change and there is no correction of the error
(this results in a slow drift of the axe).

We thought that the emcmot (axis) component generated a regulation between the instruction and the error of position.
Does anybody know how to solve this problem ? What component to use with this configuration ?


There should not be any slow drift of the axis with a stepper setup. Even without encoders the stepper motors should stay stationary when told to, and move to their commanded position with 100% accuracy unless there is some other problem.
Sevos on step-dir drives should also not drift, if the drive itself is set up correctly.

EMC2 only uses the axis.N.pos-fb input to detect following errors (and you should be seeing such errors, if the drives are drifting like you describe).

If you want to close the servo loop, then you need to add an extra function to the HAL file. This would normally be a PID function (there is also an AT_PID which you might use).
The theory is here:
linuxcnc.org/docs/html/motion_pid_theory.html
The documentation is here:
linuxcnc.org/docs/html/man/man9/pid.9.html
And tuning instructions are here:
wiki.linuxcnc.org/emcinfo.pl?Tuning_EMC2/HAL_PID_Loops

There are sample configs in the EMC installation that use servos and PID. Generally the output of the PID function is connected to a PWM signal to drive the external hardware. In your case you probably need to connect it to the Stepgen instead.

You might want to use the stepgen in velocity mode. You would have to see which works better.

There is a configuration wizard for servo / Mesa systems in the latest versions of EMC2. You can start it by typing 'pncconf' at the command line. That might help with the configuration, though I am not sure if it supports PID to stepgen linking.

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

More
25 Jul 2010 15:58 #3487 by PCW
For closed loop with encoder feedback, as other have mentioned, you need to close the loop with a PID component
also the stepgen should be set to velocity mode (mode 1 for HM2 stepgen)

Starting point for PID tuning in velocity mode is 1.000 for FF1 (since you want the stepgens step rate to be = to the commanded rate)
and a small amount of P term to correct for EMC/5I20 clock differences and direction change delays

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

More
03 Apr 2018 01:14 #108278 by mungkie

i was considering trying a setup like you describe, did you get it working?

could you show configuration for your solution?

I imagine you should maybe use a PID?


I am not sure why this is here?

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

Time to create page: 0.091 seconds
Powered by Kunena Forum