step motor compesation

More
30 Jan 2013 13:18 #29293 by maytzuc
Hi, I recently started using linuxcnc, I must say that I had never used a CNC program, but it has been very pleasing set. I managed to configure the stepper motors favorably with the wizard, I've also been able to acquire signals from an encoder. But I broke my head looking for a way to compensate for missing steps, if need be, with feedback, the truth I've been trying to use a PID, but i dont kwon if well well what I'm doing or even if the PID is working properly. I would like someone could explain me as I follow procedure and if I was given a small example would be very helpful. I annex a copy of what I have of HAL code waiting until they tell me to what extent I'm good or bad, thanks.
# Generated by stepconf at Fri Jan 25 09:34:03 2013
# If you make changes to this file, they will be
# overwritten when you run stepconf again
loadrt trivkins
loadrt [EMCMOT]EMCMOT base_period_nsec=[EMCMOT]BASE_PERIOD servo_period_nsec=[EM
loadrt probe_parport
loadrt hal_parport cfg="0x378 out  "            
loadrt encoder num_chan=1	                
loadrt pid num_chan=1		                
loadrt stepgen step_type=0,0,0		        

addf parport.0.read            base-thread      
addf encoder.update-counters   base-thread	
addf stepgen.make-pulses       base-thread	
addf parport.0.write           base-thread      


addf encoder.capture-position     servo-thread	
addf stepgen.capture-position     servo-thread	
addf pid.0.do-pid-calcs           servo-thread	
addf motion-command-handler       servo-thread	
addf motion-controller            servo-thread	


setp encoder.0.position-scale 2500.00			
addf stepgen.update-freq servo-thread		        
net spindle-cmd <= motion.spindle-speed-out		
net Xpos-fb =>     pid.0.feedback		        
net xoutput <=     pid.0.output				


net enc0A encoder.0.phase-A <= parport.0.pin-10-in	
net enc0B encoder.0.phase-B <= parport.0.pin-12-in	

net Xpos-fb <=  encoder.0.position			

net estop-out => parport.0.pin-01-out			
net xstep =>     parport.0.pin-08-out			
net xdir =>      parport.0.pin-14-out			
net xenable =>   parport.0.pin-17-out			

setp stepgen.0.position-scale [AXIS_0]SCALE		
setp stepgen.0.steplen 1				
setp stepgen.0.stepspace 1				
setp stepgen.0.dirhold 40000				
setp stepgen.0.dirsetup 40000
setp stepgen.0.maxaccel [AXIS_0]STEPGEN_MAXACCEL			
net xpos-cmd axis.0.motor-pos-cmd => stepgen.0.position-cmd		
net xpos-fb stepgen.0.position-fb => axis.0.motor-pos-fb		
net xstep <= stepgen.0.step						
net xdir <= stepgen.0.dir						
net xenable axis.0.amp-enable-out => stepgen.0.enable			

#set PID output limit to /- 1.00 
setp pid.0.maxoutput [AXIS_0]MAX_VELOCITY	  

# establecemos los parametros los cuales vendran del archivo ini
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

#deadband should be just over 1 count
setp pid.0.deadband [AXIS_0]DEADBAND		     

#posotion comand signal 
#net xpos-cmd axis.0.motor-pos-cmd =>pid.0.command   
net xpos-fb axis.0.motor-pos-fb => pid.0.command

#axis enable signals
net xenable axis.0.amp-enable-out => pid.0.enable    

net estop-out <= iocontrol.0.user-enable-out
net estop-out => iocontrol.0.emc-enable-in

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
30 Jan 2013 18:22 - 30 Jan 2013 18:28 #29302 by ArcEye
Replied by ArcEye on topic step motor compesation
Hi

I managed to configure the stepper motors favorably with the wizard,.......................... But I broke my head looking for a way to compensate for missing steps,


Afraid the 2 statements don't tally, if you are losing steps you have not set the steppers up optimally.
If they lack torque and lose steps getting going you need to look at gearing, if they lose steps on rapids especially retractions, you need to look at max acceleration and/or max velocity being set too high
(or excessive multi-stepping and always assuming that your base thread is set correctly in the first place)

The general consensus seems to be that there is no point trying to run steppers in a closed loop
See
www.linuxcnc.org/index.php/english/forum...oop-question--#28606
amongst many others on the subject

I won't reiterate all the reasoning contained therein

regards
Last edit: 30 Jan 2013 18:28 by ArcEye.

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

More
30 Jan 2013 19:19 #29304 by andypugh
Replied by andypugh on topic step motor compesation

I broke my head looking for a way to compensate for missing steps, if need be, with feedback

They way to use feedback and PID with steppers is to use a velocity-mode stepgen (see the stepgen docs for control_type).
The output from the PID then becomes a step-rate command.
However, this probably won't help recover lost steps.
The problem is that steppers lose torque as the step-rate increases. You typically lose steps at high speeds and accellerations.
If your PID detects a lost step all it can do is send more, faster, step pulses. Which simply makes things worse.
You _may_ find that it recovers from very slow-speed overload step loss. The Z-axis of my lathe, if pushing a big drill, can sit there ignoring steps coming in at the rate of about 1 per second. I think in that case a PID loop might be able to eventually get there.
However, in the typical scenario, all that the encoders can do is detect a stalled motor, and stop the machine.

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

More
30 Jan 2013 22:51 #29311 by maytzuc
Replied by maytzuc on topic step motor compesation
I think not explain well what I wanted to do, I'm so desperate with that and do not even know what I write, and my written English is not very good either. My question focuses on how to make a closed loop between the encoder and stepper motor, I read about it and found that it is possible to do it in linuxcnc but not yet how. I hope I can help and thanks again.

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

More
30 Jan 2013 23:04 - 30 Jan 2013 23:06 #29312 by BigJohnT
Replied by BigJohnT on topic step motor compesation
Steppers with encoder feedback has been done with LinuxCNC before. The results are usually not worth the effort and does not find much of a following.

The key points that I have seen are:

Stepgen ran with velocity mode
Encoder counts >2 times the step pulse

A very incomplete write up here .

John
Last edit: 30 Jan 2013 23:06 by BigJohnT.

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

Time to create page: 0.108 seconds
Powered by Kunena Forum