PID questions in finding Kp Ki and Kd

I'm trying to run a PMAC motor in a closed loop. The program used by the TMS320F2812 implenents a PID control element to control the Iq and Id.

Problem is that I don't know how to set the gains on the Kp Ki Kd.

There is an AVR app note that the motor driver "plays" with the motor to determine the gain factors. What do I need to stimulate and measure to figure out the PID gains?

Thanks

Reply to
Mook Johnson
Loading thread data ...

The no brain solution is Ziegler Nichols Method. Google gives somewhat 418k hits for it. If you would like to understand how does this stuff work, you might want to get a book on Control Systems by Tim Wescott.

Vladimir Vassilevsky DSP and Mixed Signal Consultant

formatting link

Reply to
Vladimir Vassilevsky

Thanks for the plug. If you do get the book, keep an eye on my web page

-- I taught a class this spring that helped expand the errata, and if I get enough time free I'm going to pour all of the homework problems and answers into the addenda.

Ziegler Nichols is a good way to get starting values, but it tends to be aggressive with the gains and produces systems that often don't have very good margins. Once you understand Z-N look around for the Astrom-Hagglund method. It does the data collection step in much the same way as Z-N, but it uses different conversions to get controller gains that are more conservative and safer (mostly) in practice.

--
Tim Wescott
Control systems and communications consulting
http://www.wescottdesign.com

Need to learn how to apply control theory in your embedded system?
"Applied Control Theory for Embedded Systems" by Tim Wescott
Elsevier/Newnes, http://www.wescottdesign.com/actfes/actfes.html
Reply to
Tim Wescott

Thanks,

I've read your articls on PID without a PHD and things are clearing up.

TI has a multistep process to build feeback contolled PMSM with resolver FB.

1) is to run the motor open loop with and Id and Iq command 2) is to apply the Id and Iq feedback and close the torque control loop 3) is the aply thespeed control look using resolver feedback.

We have run the motor with a DC paramaters for Id and Iq. Id = 0 since we are running a PMAC motor with resolver feedback. We run these values into the Ipark- Iclark block to generate the 3 phase SVM signal for the motor windings.

In the open look it works OK but pulls WAY too much current. We have to turn the power supply voltage down to keep from saturating the current sensors (2A). There is no load on the motor as we are just starting out. my recommendation is to reduce Iq until the current is under control and the motor still spins openloop. The FW guy is resistant to this for some reason.

One the open loop is stabilized, the next step in the build procedure is to connect the clark/park Id and Iq output from the measured 3 phase currents and for a feedback loop with a difference block subtracting the target Iq and Id from the measured Iq and Id to generatethe error. That is feed to the PID block then to the ipark/iclark to generate the corrected SVM waveforom on the motor.

Using the Z-N method, I should set the Kp = 1 and Kd = Ki = 0? Then make the Iq command step up and down between values in the operational range of the motor and look at the feedback iq response. Should be slugish.

Increase Kp until you get some overshoot on the steps. Then begin oncreasing Kd until the overshoots damp out. Then increase Ki to reduce the steady state error.

Is this the proper method to apply Z-N for motor controll of the current.

Once the current loop is stabilized, a speed control loop will be added to provide the Iq target. The speed control Fb will come from the resolver. I do the same process with this on by stepping the speed command and watching the speed Fb response?

Does this sound like the proper approach?

thanks.

Reply to
Mook Johnson

I havent looked at the TI PMSM code, but the normal approach is to have a current setpoint, and a closed-loop current controller, that then generates a voltage setpoint to the waveform generator. If you try running it open-loop, with a current setpoint, it'll saturate PDQ.

What you need to do is bypass the current controller, and provide a fixed voltage setpoint to the waveform generator.

you might be better off with some inductors rather than a machine to get the open-loop control working. check your waveform generator is working nicely (I built some 8th order passive bessel filters that Tektronix P5200 probes plug into, to measure the fundamental voltage waveform from a hairy-assed PWM mess, for this purpose).

once you are happy that you can produce the voltage waveforms you intend to (IOW the WG is working), then add in the current controller. If Id =

0 then Vd = 0, so you dont need the Id controller at all.

And yes, you start with a nice small Iq. My personal preference is to use inductors, because there arent any rotating bits to worry about, and you dont have to worry about getting the darned thing started.

Once you have got the current regulator working at a variety of currents with an L-R load (mostly L), you can do step responses etc. I find it handy to feed actual Id, Iq out a DAC port, so you can see whats going on in the SRRF on a scope - there are devices called vector visualisers that implement Parke, Clarke transforms with analogue ICs, to let you do this with V,I measurements directly, but if you have a DAC port its way easy

with the current regulator working and a machine attached, organise to slowly bring it up to speed with open-loop voltage control (if you ramp the voltage slowly, the unloaded machine will easily follow it), then kick in the current controller. at this point you can tune it, using small step-changes in Iq*

you dont need any Kd for the current controller. PI is fine, and thats one less parameter to mess with.

a crude analysis of ZN is:

- crank up Kp until it gets pissy

- wind it back a bit

- ditto with Ki

but really its not too hard to sit down and write some control-loop equations, so you can figure out the "ideal" Kp, Ki for whatever response you desire. Dynamically its just a current controller providing a voltage setpoint which is driving into an L-R circuit.

In practice its more complex, there are sampling issues etc, but as long as your sampling rate is fast c.f. the machine rated speed, they wont affect you too much - and the analyutic approach provides a good starting point.

Reply to
Terry Given

Terry,

Sincere thanks man.

Its really starting to clear up for me now.

You are correct, the open loop build (phase 2) had ramp generator to run theta (phase angle) as a user provided frequency (RPM). The theta is used to feed the Inv_Park and Park transform modules.

Two user inputs are Vd and Vq into the inverse park module and the alpha and beta outputs of that feed the inverse clark module that provides the modulation signal to the PWM registers.

So you are correct and in the open loop build, we are simply setting the motor voltage amplitude across the motor and the currents are what ever they work out to be.

During this step we look at the measured currents on the line, at the output of the Clark and at the output of the Park module.

Good Good. This corrolates well with what I've seen in the lab.

In phase 3 we are forming the current loop. In this loop, the Iq and Id output of the Park module in the feed back loop is compared to a Iq and Id (Id = 0) reference. The PID block generated a voltage signal appropriate to regulate the current at a particular value.

I started with a Kp = 1 and Ki = Kd =0, motor just buzzed. Thats where I left off. Monday, I plan to increase Kp util its at least kind of functional then keep going until it goes from being "kinda functional" to disfunctional. then back off to near the top of the kinda functional range. (Z-N method recommend halfing the disfunctional Kp value)

Then step change the Iq command by a small amount and watch the response as I add Ki gain. leave Kd =0 for now.

Follwing that a similar approach is used for the speed control loop that ouputs the Iq command required to maintain the speed setpoint at various loads.

In think this will get me there.

Thanks again Terry,

P.S

If, theres anything above that looks incorrect, or you have a few more nuggets of info, please let me know.

Reply to
Mook Johnson

no worries mate. someone might as well get some use out of this knowledge....

Im not familiar with the TI code, but you might want to think about the numerical scaling of the gains - is the TI code per-unitised (Kp = 1 =

100%) or is it scaled in V/A etc? if the latter, then 1 might turn out to be an astonishingly small gain.

actually if its the former, Kp = 1 may also be a very small gain if, for example, 1PU = 8192.....

not really, you've got the basic idea.

It took me a long time to grok this stuff - didnt really do so until I went to a seminar with Ramu Krishnan and Joachim Holtz; I asked Prof Holtz about tuning current loops, and he basically said "how come people dont understand this stuff" then cranked thru the maths. Recognition eventually dawned, and nowadays I always calculate my gains before I start fiddling.

Cheers Terry

Reply to
Terry Given

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.