EmbeddedRelated.com
Forums

Re: Electromechanical servo control & update rates

Started by Jay February 23, 2004
Robert,

Thanks for your last reply.

> I thought that your target phase was determined by some external > event. But it is only determined by an internal counter. Is anything > else external locked to this reference counter? If not, then I wonder > why you specified an phase lock tolerance of .5 degrees to a reference > that is just an arbirary internal oscillator?
The counter is actually clocked by a synthesized 1000x version of the reference clock(which it is also in phase with). The 1000x multiplier comes from the number of quadrature counts. So, the system is actually attempting to acquire lock based on the reference signal.
> In any case, you must reduce all phase error readings to a range of > +/- 500 counts (half a rev), because in their raw form, these > differences are in the range of +/- 1000 counts. You must recognize > -999 counts as really just +1 count of phase error.
Thanks for this tip. I did take care of the "normalization" so I don't hunt around the circle to correct errors , etc.
> The error is just a signed value. Whatever PID implementation you > choose will have an obvious place to stuff the error term. The PID > output will also be a number. If you have your gains set right, this > number will be in just the right form to put in the "on-time" register > of your PWM controller. Of course you will have to perform software > limiting since the PWM on-time register can only express 0 to 100%.
I'm having problems with the loop locking and I think part of it might have to do with the PWM representation. I'm using a unipolar PWM representation where 0% == off and 16383 == 100%, and the H-bridge is wired with VCC and GND(0V). When running, I see the duty_cycle making large jumps between say 15000 and 2000. I'm wondering should I have used a 50% centered PWM output so negative values result in a reduction of speed? I don't see how I can add an offset in software to take care of this. I'd appreciate your suggestions. Regards, Jay.
On Mon, 23 Feb 2004 10:53:33 -0600, Jay <127@127.0.0.1> wrote:

>> The error is just a signed value. Whatever PID implementation you >> choose will have an obvious place to stuff the error term. The PID >> output will also be a number. If you have your gains set right, this >> number will be in just the right form to put in the "on-time" register >> of your PWM controller. Of course you will have to perform software >> limiting since the PWM on-time register can only express 0 to 100%. > >I'm having problems with the loop locking and I think part of it might >have to do with the PWM representation. I'm using a unipolar PWM >representation where 0% == off and 16383 == 100%, and the H-bridge is >wired with VCC and GND(0V). > >When running, I see the duty_cycle making large jumps between say 15000 >and 2000.
That could be simply from too much gain. Start with zero gain (open loop) and manual control of the PWM register to make sure it is behaving the way you expect. Then add in the smallest possible "I" term gain and watch what happens. It might take a long time to lock, but at least it will not jump around if your implementation of PID calculations is correct.
>I'm wondering should I have used a 50% centered PWM output so negative >values result in a reduction of speed? I don't see how I can add an >offset in software to take care of this.
It does not matter if you use a 50% centered output or not. If you have any "I" term at all in your PID controller, then the action of the "I" term will develop just the right offset in the calculation of the PWM output, regardless of what artificial offsets you add or do not add in the mix. If you would like to contract with me to make this implementation work, then you may e-mail me directly at rscott at tunelab hyphen world dot com. -Robert Scott Ypsilanti, Michigan (Reply through this forum, not by direct e-mail to me, as automatic reply address is fake.)