Closed loop with steppers

More
30 Aug 2010 13:44 #3916 by Zoidberg1977
Hello everbody,

I'am new to this forum and to EMC2 B) . I have a question about doing closed loop with steppers and EMC. I did search the forum as well as the internet concerning
the topic, but did not find any answers just questions.

My hardware is:
3 axis milling machine with 10Nm Steppers (resolution: 1 step =approx. 0.0025mm).
Glass scale encoders on all axis (resolution 0.005mm).
Computer Laptop Pentium4, 2.8Ghz, 1GB Ram, onboard video.
Steppers are controlled by parallel port (step/dir pulses). Second parallel port is used for the encoders.

I know that a closed loop system with steppers is not advised, because lost steps due to a too weak motor can not be compensated.
But I do not have problems with that (the motors are strong enough). My Problem is that my mill uses acme thread spindles and not
ballscrew ones, which have a quite big backlash and are also not that accurate (especially during milling operation when a force acts on the spindles).:angry:
I know that ballscrews are much better but they are very expensive
and I do not want to dismantle my complete machine to install them (perhaps only as a matter of last resort) :unsure: . So the software should compensate
the backlash and all inaccuracies with a closed loop taking into account the measurements from the encoders.

I heard that EMC2 can do closed loop, but so far I only read something about closed loop using servos (also in the manual).
Is a closed loop with steppers even possible with EMC2? If so, I think it requires a deeper understanding of the EMC configuration which I do not have
(I'm just in the process of installing and configuring EMC2).

Can anyone give me a hint of how to implement a closed loop with steppers (or perhaps a short instruction set).

Greetings
Thomas

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

More
30 Aug 2010 18:00 #3917 by PCW
Replied by PCW on topic Re:Closed loop with steppers
1. EMC can do closed loop control with step motors.
basically you use a servo configuration where the encoder based real position and commanded position from the trajectory
go into a PID loop and the output of the PID loop drives the step generator in velocity mode, This arrangement simulates
a velocity mode servo with the step motor. Starting PID loop tuning for this configuration is FF1 = 1.0, with some small P term to correct for errors

2. Dont expect good results trying to compensate for backlash with encoder feedback.
First it will be really hard to make the feedback stable with backlash in the drive mechanics
Also if the cutting force reverses, bad things will happen...
(EMC can compensate for backlash without feedback but of course the same force reversal limitation applies)

3. The scale will compensate for leadscrew errors and deflection in the drive system

4. Your scale resolution is pretty low. I think this will make encoder feedback difficult. Ideally you would want more than10 encoder counts per step
to have a workable stepmotor system with encoder feedback

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

More
31 Aug 2010 07:32 #3923 by Zoidberg1977
Hello,

thanks for the answer. I think I will just try it out and see what happens.
Is there some kind of setup screen in the EMC programm itself where I can set the necessary steps
for the closed PID loop (encoder position and commanded position to PID, PID to step generator...),
or do I have to manipulate some config files directly.

And what do you mean by "bad things will happen" :dry: ?

A general problem that I noticed is that when I am milling some workpiece the cutter is actually pulled or pushed into
the material. So I see the encoder position changing (about 0.2mm) but the motor itself is not moving. I think
this happens because of the backlash in the lead screw.
The problem with the normal backlash compensation is that the backlash is not constant for every position.
I think I have read something that in EMC it is possible to define a table of some kind to define variable backlash
(e.g. 0.1mm backlash at X=10mm and 0.15mm backlash at X=200mm and so on).
Perhaps if I use this backlash compensation together with the closed loop it may improve the results.

Greetings
Thomas

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

More
31 Aug 2010 12:48 #3925 by andypugh
Zoidberg1977 wrote:

I think I have read something that in EMC it is possible to define a table of some kind to define variable backlash
(e.g. 0.1mm backlash at X=10mm and 0.15mm backlash at X=200mm and so on).
Perhaps if I use this backlash compensation together with the closed loop it may improve the results.


The screw compensation table allows you to define a screw error in each direction at as many points as you want to use. (Your linear scales should make it very easy to derive this table). This should work pretty well in open-loop mode but won't compensate for the difference between "climb" milling and "conventional" milling. Basically EMC2 has no way to know which style of milling you are doing, or whether the screw is pulling the work onto the cuttter, or holding it off.
You probably need to read this thread on the developers mailing list. It is about a slightly different question, but touches on many of the issues you are likely to have.
thread.gmane.org/gmane.linux.distributio...evel/3355/focus=3359

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

More
31 Aug 2010 14:58 #3926 by gtom
Replied by gtom on topic Re:Closed loop with steppers
Hello, here is the hal of my machine:

loadrt trivkins
loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[TRAJ]AXES
#loadrt probe_parport

# hostmot2 driver
loadrt hostmot2

# load low-level driver
loadrt [HOSTMOT2](DRIVER) config=[HOSTMOT2](CONFIG)

# watchdog
setp hm2_5i20.0.watchdog.timeout_ns 10000000

#PID
loadrt pid num_chan=3

# THREADS
addf hm2_5i20.0.read servo-thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread

addf pid.0.do-pid-calcs servo-thread
addf pid.1.do-pid-calcs servo-thread
addf pid.2.do-pid-calcs servo-thread

addf hm2_5i20.0.write servo-thread
addf hm2_5i20.0.pet_watchdog servo-thread

# io- spindle
net spindle-cw <= motion.spindle-forward

# io- coolant
net coolant-flood <= iocontrol.0.coolant-flood

#linear encoders
setp hm2_5i20.0.encoder.00.scale 200
setp hm2_5i20.0.encoder.00.filter 1
setp hm2_5i20.0.encoder.01.scale 200
setp hm2_5i20.0.encoder.01.filter 1
setp hm2_5i20.0.encoder.02.scale -200
setp hm2_5i20.0.encoder.02.filter 1

#mpg encoder
#setp hm2_5i20.0.encoder.03.scale 1
#setp hm2_5i20.0.encoder.03.filter 0

# Heidenhain ROD270 encoder
setp hm2_5i20.0.encoder.03.scale 1000
setp hm2_5i20.0.encoder.03.filter 0


net jogwheel-counts <= hm2_5i20.0.encoder.03.rawcounts

net jogwheel-counts => axis.0.jog-counts

net jogwheel-counts => axis.1.jog-counts

net jogwheel-counts => axis.2.jog-counts

## connect encoder index-enables for homing on index
net xindex-enable hm2_5i20.0.encoder.00.index-enable <=> axis.0.index-enable
#net xindex-enable => hm2_5i20.0.stepgen.00.reset

net yindex-enable hm2_5i20.0.encoder.01.index-enable <=> axis.1.index-enable
#net yindex-enable => hm2_5i20.0.stepgen.01.reset

#gpio
setp hm2_5i20.0.gpio.024.is_output 1
setp hm2_5i20.0.gpio.025.is_output 1
setp hm2_5i20.0.gpio.026.is_output 0
setp hm2_5i20.0.gpio.027.is_output 1
setp hm2_5i20.0.gpio.028.is_output 1
setp hm2_5i20.0.gpio.029.is_output 0
setp hm2_5i20.0.gpio.030.is_output 0
setp hm2_5i20.0.gpio.031.is_output 0
setp hm2_5i20.0.gpio.032.is_output 0

#set stepgen.2 z-direction
setp hm2_5i20.0.gpio.061.invert_output 1

net coolant-flood => hm2_5i20.0.gpio.024.out
net spindle-cw => hm2_5i20.0.gpio.025.out

net both-home-x <= hm2_5i20.0.gpio.032.in
net both-home-y <= hm2_5i20.0.gpio.031.in
net both-home-z <= hm2_5i20.0.gpio.029.in


#stepgen
setp hm2_5i20.0.stepgen.00.control-type 1
setp hm2_5i20.0.stepgen.01.control-type 1
setp hm2_5i20.0.stepgen.02.control-type 1

# X
# enable chain
newsig emcmot.00.enable bit
sets emcmot.00.enable FALSE
net emcmot.00.enable => pid.0.enable
net emcmot.00.enable => hm2_5i20.0.stepgen.00.enable
net emcmot.00.enable <= axis.0.amp-enable-out

net motor.00.pos-fb <= hm2_5i20.0.encoder.00.position <= pid.0.feedback
net motor.00.pos-fb => axis.0.motor-pos-fb

net emcmot.00.pos-cmd axis.0.motor-pos-cmd => pid.0.command
net motor.00.command pid.0.output => hm2_5i20.0.stepgen.00.velocity-cmd

# homing
net both-home-x => axis.0.home-sw-in
net both-home-x => axis.0.neg-lim-sw-in
net both-home-x => axis.0.pos-lim-sw-in

# timing parameters
setp hm2_5i20.0.stepgen.00.dirsetup [AXIS_0]DIRSETUP
setp hm2_5i20.0.stepgen.00.dirhold [AXIS_0]DIRHOLD
setp hm2_5i20.0.stepgen.00.steplen [AXIS_0]STEPLEN
setp hm2_5i20.0.stepgen.00.stepspace [AXIS_0]STEPSPACE
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]MAX_VELOCITY
setp hm2_5i20.0.stepgen.00.step_type 0


# set PID loop gains from inifile
setp pid.0.Pgain [AXIS_0]P
setp pid.0.Igain [AXIS_0]I
setp pid.0.Dgain [AXIS_0]D
setp pid.0.bias [AXIS_0]BIAS
setp pid.0.FF0 [AXIS_0]FF0
setp pid.0.FF1 [AXIS_0]FF1
setp pid.0.FF2 [AXIS_0]FF2
setp pid.0.deadband [AXIS_0]DEADBAND
setp pid.0.maxoutput [AXIS_0]MAX_VELOCITY

same for y & z axis...

and the PID- Params from the ini-file:

DEADBAND = 0.0025
P = 1
I = 0
D = 0
FF0 = 0
FF1 = 1
FF2 = 0
BIAS = 0

regards, Thomas

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

More
31 Aug 2010 15:06 #3927 by gtom
Replied by gtom on topic Re:Closed loop with steppers
The most important thing is the DEADBAND,
this has to be at least 2 times greater than the resolution of one step of the motor.


Thomas

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

More
01 Sep 2010 18:17 #3945 by aike
Replied by aike on topic Re:Closed loop with steppers
Thank you for information!
We are working now about connect stepper and encoder and add index-enable.

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

More
01 Sep 2010 18:42 #3946 by aike
Replied by aike on topic Re:Closed loop with steppers
Question:
What values you used for FERROR and FERROR_MIN?
Has your axis stopped due follow error?

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

More
01 Sep 2010 19:11 #3948 by gtom
Replied by gtom on topic Re:Closed loop with steppers
start with a value of 1 (both ferror and min_ferror) then reduce the min value until you get joint follow errors,
i was able to reduce the min ferror to 0.02 but i had problems to reduce the ferror to values lower than 0.5.
This depends also on the setup of the machine (ballscrews,gears,weight etc)
regards, Thomas

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

Time to create page: 0.084 seconds
Powered by Kunena Forum