On Fri, Mar 5, 2010 at 5:25 AM, Andy Pugh <[email protected]> wrote:
> I tried setting up closed-loop spindle control last night. It took me > a while to figure out why it wasn't working (my encoder had lost the B > channel) but during my investigations I found some interesting points. > > The output of the Hostmot2 PWM block gives 100% duty cycle at +100% > and -100% input, though it inverts the direction bit. This is, of > course, perfectly sensible. > > The output of the PID hal component is limited to +/- maxoutput. > > The effect of this seems to be that if the spindle is faster than > setpoint, the PID controller can wind down to the negative limit, > which sets the PWM to 100%, which sets the spindle speed to max. One > solution would be to wire the PWN direction pin to the spindle > direction buttons, but this ia a VFD and that seems unwise. > > Curiously > http://wiki.linuxcnc.org/cgi-bin/emcinfo.pl?Closed_Loop_Spindle_Speed_Control > seems to address this by using the PID block in a rather unusual way, > adding the output of the PID block to the motion.spindle-speed-out > pin, so that the output of the PID becomes a correction to the > setpoint rather than the actual setpoint (which might explain why he > suggests a PGain of zero). > The other alternative would be to limit the output of the PID to zero > before sending it to the PWM, but then it will tend to take some time > to wind up from the negative limit to zero and that seems potentially > troublesome. > If you limit the PID outut to only values of zero or above, then the dir line of the PWM would never switch which would make the winding down to the negative limit problem go away since it could never window down to anything less then zero. Maybe a safer way to do it, instead of limiting the PID output to zero, since it may be undetermined what the dir line does when you are at zero, is to wire the PWM dir output line to the PWM enable line so that if the dir line ever sends the spindle in a negative direction it turns off the PWM effectively setting the PWM output to zero for any PWM value that is negative or zero. > Which way is best? I am coming round to the idea that the documented > solution (using motion,spindle-speed-out effectively as a > precontroller and the PID as a tuning offset) actually makes a lot of > sense, even if it does seem a little unconventional. I suspect it > could still get "stuck" on its negative limit, though? > > -- > atp > > I'm the original author of that wiki page, glad you found it useful. It's an awful way to use the PID, but it works ok especially if you have a very non-linear speed controller like the one I cobbled together for my mill. I believe you are correct, if you set the spindle speed to zero, the integral output of the PID will quickly go negative, which summed to the motion-spindle-speed-out which is zero, will make the PWM go into a negative value and in your case start speeding up the spindle again and very quickly be stuck at full speed. Lawrence ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ Emc-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/emc-users
