LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Transfer Function of the discrete PID controller embedded in PCI 7358

Hello everyone,

 

I have a motion control system composed of a NI PCI-7358 motion control card, a three phase sinusoidal servo amplifier (works in current mode), a three phase brushless DC motor and an optical incremental encoder as the position feedback device.

 

My goal is to control the angular position of the brushless DC motor.

 

Using NI PCI-7358 as the controller, limits the usage of the controller strategies other than the discrete PID controller, so I go with the discrete PID controller.

 

I had derived the mathematical model of my system because I wanted to design the discrete PID controller by using the mathematical model so that I can avoid any damage that can be caused by using the trial and error method to find the gains (Kp, Kd and Ki) of the discrete PID controller.

 

I designed a PD controller whose gains are Kp=0.018 and Kd=0.045. I used this PD controller in my simulation and I saw that the designed discrete PD controller satisfies the specifications.

 

So here comes my first question;

 

As I understand you can define the controller parameters only as positive integers for the embedded discrete PID control of the PCI-7358. So how can I apply the PD controller that I designed with parameters Kp=0.018 and Kd=0.045?

 

Since I couldn't apply my design with the real system, I also tried the trial and error approach in order to tune the PID gains.

 

First I set Kp=1 and the other parameters Kd and Ki to 0. When I examined the step response of the real system with these controller parameters, I noticed that there was 90% overshoot for the step response which actually verified my design in a way. Because 90% overshoot with Kp=1 shows that there is no need for such a relatively big value as Kp=1. I also tried these controller values with the controller in my simulation and my simulation gave nearly the same results with the real system.

 

But when I added derivative gain to the controller (which actually turned my controller from discrete P controller to discrete PD controller), things went bad. When I changed the Kd from 0 to 1, it damped the real system's behavior a bit, but when I made the same change to the controller in the simulation, the response of the simulation nearly went unstable.

 

So I think the reason for that inconsistency between the real system and the simulated system should be originated from using different discrete transfer functions.

 

The transfer function that I used for the discrete PID controller in my design was Gc(z)=Kp+((Ki*T)/(1-z-1))+((Kd*(1-z-1))/T)

 

where T is the sampling period which I took as 250 microseconds which is the PID control loop update period that I used with PCI-7358. Here in my transfer function the derivative term is approximated by "backward difference" technique.

 

So here is the second question;

 

What is the discrete transfer function for the embedded discrete PID controller of PCI-7358? Maybe the approximation method for the derivative term is different, it can be tustin (bilinear) transformation. Or maybe the Kd term I enter is internally divided by some number and then used in the PID loop?

 

I want to say that I was able to tune the PID gains of the PCI-7358 so that now I have a motion control system which satisfies my specifications. The parameters for the PID controller are Kp=8, Kd=60 and Ki=1. But when I used these values for the controller in my simulation the response I got was nothing like the response of the real system. So what I am trying to say is that; I have no problems about controlling the motion. I have problems in understanding how this embedded discrete time PID algotihm of PCI-7358 works.

 

I would be really grateful if somebody can answer my questions a.s.a.p.

 

Best Regards,

 

Kartal CAGATAY

Systems Engineer

0 Kudos
Message 1 of 9
(6,893 Views)

Hello Kartal,

 

You said the Discrete PID that you used was Gc(z)=Kp+((Ki*T)/(1-z-1))+((Kd*(1-z-1))/T)

From my calculation, should the Discrete PID has the following transferfunction?

Kp+Ki(T/2)*((z+1)/(z-1)) + Kd*(2/T)*((z-1)/(z+1)) 

 

What was your plant model used for simulation?

Andy Chang
National Instruments
LabVIEW Control Design and Simulation
0 Kudos
Message 2 of 9
(6,857 Views)

Hello Andy,

 

Thanks for your quick response.

 

The transfer function that you wrote can be obtained by tustin transformation. Which means replacing "s" term in the continuous PID controller transfer function which is Kp+(Kd*s)+(Ki/s), with (2/T)*((z-1)/(z+1)).

 

But the discrete PID controller that I used in my design was obtained by replacing "s" term in the continuous PID controller transfer function with (1-z-1))/T, which is called backward difference method. This is the reason for the difference between your discrete PID controller and my discrete PID controller.

 

My plant transfer function is 1/(J*s2+b*s) where "J" is the mass moment of inertia and "b" is the viscous damping coefficient.

 

You wrote that;

 

"From my calculation, should the Discrete PID has the following transferfunction?

Kp+Ki(T/2)*((z+1)/(z-1)) + Kd*(2/T)*((z-1)/(z+1)) "

 

So this expression you wrote above is the transfer function for the discrete PID controller embedded in NI PCI-7358?

 

And do you have an answer for the first question that I asked in my first message, which was about using Kp=0.018 and Kd=0.045 values with NI PCI-7358.

 

Regards

 

Kartal CAGATAY

Systems Engineer

0 Kudos
Message 3 of 9
(6,851 Views)

Hello Kartal,

 

I'm working on getting more information on how discrete PID is implemented on Motion Card. In the mean time, is it possible to have you share with me your simulation work for your system? I'd like to do some comparison between the two methods by calcualating CL transfer function and such.

Andy Chang
National Instruments
LabVIEW Control Design and Simulation
0 Kudos
Message 4 of 9
(6,828 Views)
Hello Andy, My simulation is in MATLAB, and there is nothing special about it. There is the plant whose transfer function I had given before, a discrete transfer function for the controller and a summing point to calculate the error. My simulation have lots of other parts that have nothing to do with this problem so I need to isolate the related part of the simulation from the unrelated part before sending it to you. But of course I can send my simulation in MATLAB to you if you really think that would help you for finding answers to my questions but you can also construct the model in 3-5 minutes if you like.  Actually, using "tustin transformation" or "backward difference" method for estimating the differential and integral terms in the discrete controller doesn't change thinks a lot as I can conclude from the results of my simulation (actually this should be the case!!) I made some further study today and here is what I think: 

I had written in my first post that I had used Kp=8 and Kd=60 as the discrete PID parameters of the NI PCI-7358 motion controller which make the system satisfy the desired specifications.

 

I think the transfer function for the embedded PID controller of the PCI-7358 is as you wrote in your reply, Kp+Ki(T/2)*((z+1)/(z-1)) + Kd*(2/T)*((z-1)/(z+1)). But I think here is the trick;

 

When I enter 60 for the Kd parameter from the MAX, actually the motion control card accepts this 60 as the value of Kd*(2/T), not the value of Kd. So for example when I enter 60 as the Kd value, if the control loop update period is 250 microseconds, actual Kd value becomes 60*0.00025/2 which makes 0.0075.

 

I think same thing also applies for the Ki parameter. So for example when I enter 1 for the Ki value, and if the control loop update period is again 250 microseconds, actual Ki value becomes 1*2/0.00025 which makes 8000. But for Ki, as it is written in the “User Manual of NI Motion” the Ki value we enter is divided by 256 internally which makes the actual Ki value used in the controller transfer function 8000/256.

 

I tried my guess above by using my simulation and I got pretty close results for the real time response and simulation response.

 

What do you think, could this be the case?

 

By the way, do you have an answer for my first question in my first post, which was,

 

 As I understand you can define the controller parameters only as positive integers for the embedded discrete PID control of the PCI-7358. So how can I apply the PD controller that I designed with parameters Kp=0.018 and Kd=0.045?

 

 

Kartal CAGATAY

 

0 Kudos
Message 5 of 9
(6,816 Views)

You have brought up a very good point and I believe that you are correct on how the gains are actually being implemented. I'm getting in touch with R&D to gather more information on this.

Andy Chang
National Instruments
LabVIEW Control Design and Simulation
0 Kudos
Message 6 of 9
(6,797 Views)
Andy, I studied a little bit more on the subject and now I'm 99% sure about how the discrete PID controller parameter gains are implemented by NI PCI-7358. I was right but not totally.  I thought that the transfer function of the PID controller of 7358 was Kp+Ki(T/2)*((z+1)/(z-1)) + Kd*(2/T)*((z-1)/(z+1)), where "tustin transformation" method is used for estimating the differential and integral terms in the discrete controller. But now I'm nearly certain that the transfer function of the PID controller is Kp+((Ki*T*z)/(z-1))+((Kd*(z-1))/(T*z)), where "backward difference" method is used for estimating the differential and integral terms in the discrete controller. So for example, When 60 is entered for the Kd parameter from the MAX, actually the motion card accepts this 60 as the value of (Kd/T), not the value of Kd. And when 1 is entered for Ki parameter, actually the motion card accepts this 1 as the value of (Ki*T), not the value of Ki. Let's assume that we enter Kp=8, Kd=60 and Ki=1 from MAX as the PID controller parameters of PCI-7358. In this case the transfer function of the discrete PID controller of the PCI-7358 becomes, 8+((1/256)*z/(z-1))+((60*(z-1)/z). There is 1/256 value in the integral gain because it is written in the “User Manual of NI Motion” that the Ki value entered is divided by 256 internally. I tried what I am explaining above with my simulation, and I got exactly the same results from the real system and from my simulation. Now there is only one question left. Is it possible to apply non-integer gains for the PID controller of the NI PCI-7358.  Kartal CAGATAY
0 Kudos
Message 7 of 9
(6,777 Views)

Andy,

 

I studied a little bit more on the subject and now I'm 99% sure about how the discrete PID controller parameter gains are implemented by NI PCI-7358. 

 

I was right but not totally.

 

I thought that the transfer function of the PID controller of 7358 was Kp+Ki(T/2)*((z+1)/(z-1)) + Kd*(2/T)*((z-1)/(z+1)), where "tustin transformation" method is used for estimating the differential and integral terms in the discrete controller.

 

But now I'm nearly certain that the transfer function of the PID controller is Kp+((Ki*T*z)/(z-1))+((Kd*(z-1))/(T*z)), where "backward difference" method is used for estimating the differential and integral terms in the discrete controller.

 

So for example,

 

When 60 is entered for the Kd parameter from the MAX, actually the motion card accepts this 60 as the value of (Kd/T), not the value of Kd. And when 1 is entered for Ki parameter, actually the motion card accepts this 1 as the value of (Ki*T), not the value of Ki.

 

Let's assume that we enter Kp=8, Kd=60 and Ki=1 from MAX as the PID controller parameters of PCI-7358.

 

In this case the transfer function of the discrete PID controller of the PCI-7358 becomes, 8+((1/256)*z/(z-1))+((60*(z-1)/z). There is 1/256 value in the integral gain because it is written in the “User Manual of NI Motion” that the Ki value entered is divided by 256 internally. I tried what I am explaining above with my simulation, and I got exactly the same results from the real system and from my simulation. 

 

Now there is only one question left. Is it possible to apply non-integer gains for the PID controller of the NI PCI-7358?

 

Kartal CAGATAY

 
0 Kudos
Message 8 of 9
(6,775 Views)

Hello Kartal,

 

I'm still in the process of finding documentation on that for you and I'll keep you posted on my findings.

Andy Chang
National Instruments
LabVIEW Control Design and Simulation
0 Kudos
Message 9 of 9
(6,734 Views)