3
\$\begingroup\$

I am trying to implement a PID controller in the z-domain. What I have done so far is found some values of \$K_p\,ドル \$K_i\,ドル and \$K_d\$ that work in the time domain. I have found some information on how to translate these values into the z-domain, but when I run the new simulation with the digital PID controller, it no longer seems to work.

For your reference, the \$K_p\,ドル \$K_i\,ドル and \$K_d\$ values I have are 0.25, 0.6, 0.005, and when i converted these to the canonical form (in z domain) I had \$a_0 = 500.25\,ドル \$a_1 = -1000.25\$ and \$a_2 = 500\$. (used \$T = 10^{-6}\$. When i plot these two things (using a sinusoidal input), the outputs are different and I can't quite figure out where I am going wrong with this.

EDIT: I guess as a more direct question, how can i take time domain parameters\$K_p\,ドル \$K_i\,ドル and \$K_d\$ and turn that into a digital/ z domain difference equation for a microcontroller? TIA

asked Jun 27, 2012 at 19:29
\$\endgroup\$
7
  • \$\begingroup\$ From simple inspection we can immediately see something is clearly wrong with your Ki nd Kd values since the units don't make sense. Ki is in units of frequency, and Kd in units of time. Dimensionless as you show them is clearly wrong and therefore can't possibly be converted to the Z domain in any meaningful sense. \$\endgroup\$ Commented Jun 27, 2012 at 21:40
  • \$\begingroup\$ @OlinLathrop I can see where you are coming from, but these are formulas I have obtained from the wikibooks link. Are there other ways I can transform my time domain to z? \$\endgroup\$ Commented Jun 27, 2012 at 22:03
  • \$\begingroup\$ let us continue this discussion in chat @OlinLathrop \$\endgroup\$ Commented Jun 28, 2012 at 14:13
  • \$\begingroup\$ @OlinLathrop, I think your chat works, if it does not we can figure a different way to communicate. comments here are not the most productive. \$\endgroup\$ Commented Jun 28, 2012 at 14:20
  • \$\begingroup\$ @Kortuk: I followed your link and got to a chat page. It had blocks for things you said and I said, but none of the text was filled in. Chat has never worked for me yet. \$\endgroup\$ Commented Jun 28, 2012 at 16:06

2 Answers 2

2
\$\begingroup\$

Since you changed your question, here is my second answer:

You have your coefficients \$K_p\,ドル \$K_i\$ and \$K_p\$. The transfer function is \$D(z) = K_p + K_i \frac{T}{2}\left[ \frac{z+1}{z-1}\right] + K_d \left[\frac{z-1}{Tz}\right] =\frac{a_0 + a_1 z^{-1} + a_2 z^{-2}}{1 + b_1 z^{-1} + b_2 z^{-2}}\$. When you compare the two sides of the equation you will find can calculate everything you need. I assume you already have determined \$K_p\,ドル \$K_i\,ドル \$K_p\$ and \$T\$ either by measurement or from the requirements.

  1. Calculate the coefficients

    • \$a_0 = K_p + \frac{K_iT}{2} + \frac{K_d}{T}\$
    • \$a_1 = -K_p + \frac{K_iT}{2} - \frac{2K_d}{T}\$
    • \$a_2 = \frac{K_d}{T}\$
    • \$b_1 = -1\$
    • \$b_2 = 0\$
  2. Negative exponents for z basically mean a shift. The output is $$y[n] = x[n]a_0 + x[n-1]a_1 + x[n-2]a_2 + y[n-1]$$

The index \$n\$ is the current value, \$n-1\$ the previous one and so on.

answered Jun 28, 2012 at 8:05
\$\endgroup\$
2
\$\begingroup\$

You are of by one order of magnitude. \$a_2 = \frac{K_d}{T} \rightarrow T = \frac{K_d}{a_2} = \frac{0.005}{500} = 10^{-5}\$ and not (your) \$T = 10^{-6}\$ so your values need to be adjusted.

answered Jun 27, 2012 at 19:48
\$\endgroup\$
2
  • \$\begingroup\$ oops, i think i meant to write \10ドル*10^{-6}\$. \$\endgroup\$ Commented Jun 27, 2012 at 21:43
  • \$\begingroup\$ @suzu Was that causing the error? \$\endgroup\$ Commented Jun 28, 2012 at 7:26

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.