I am using PID control on DSP platform(TMS320f28069)
how to fix the sampling interval time while performing discretization of controller. What is the suitable method like tustin, backward/forward euler?
can any one help
Thanks
Tarakanath.
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
I am using PID control on DSP platform(TMS320f28069)
how to fix the sampling interval time while performing discretization of controller. What is the suitable method like tustin, backward/forward euler?
can any one help
Thanks
Tarakanath.
Tarakanath,
Correct selection of sample rate is critical to good performance. For a control system, the choice should be based on the response speed of the plant. If you can conduct an open loop step response, or have some idea what is would look like, you should aim for a sample period at least 4 to 10 times shorter than the rise time. This should be safe. In general, the faster you sample the better control performance you get, but there are trade-offs in terms of t available processing time and complexity of any anti-aliasing filter in your system.
Several methods are available for discretisation of an existing continuous time controller. Among the methods you name, Tustin has the best performance and is reasonably easy to compute by hand. In general, forward and backward approximation methods yield poorer performance.
These topics are covered in detail in a control theory seminar I run. Details are here... https://sites.google.com/site/controltheoryseminars/
You can download the seminar manual on the "downloads" page. Look for part 4, on discrete time systems. You can view a video here...https://www.youtube.com/watch?v=4lQcG_fpPis
You will also find useful information, including a discussion of PID discretisation, in chapter 4 of this book...http://www.amazon.com/Control-Theory-Fundamentals-Richard-Poley/dp/1496040732/ref=sr_1_2?s=books&ie=UTF8&qid=1395331948&sr=1-2&keywords=poley
Regards,
Richard
Thanks alot Richard for your guidance.But can you give a suggestion on this please?
Yes, I conducted open loop test to the plant(transfer function) which i designed and i found 6.4 milliseconds as my plant time constant and I designed the plant for switching frequency of 40khz(switching time period=25microseconds). I am using TMS320f28069 which has 80 MHZ clock frequency. i checked the computation time taken for computing pid controller is about 1.3microseconds.Now can you suggest what is the best sampling frequency to PID discretisation, so that i can achieve better control response with digital(TMS320f28069) platform?
Thanks
Tarakanath
Tarakanath,
Your time constant suggests the rise time is about 14ms, which puts the maximum sample period at 3.52ms and the minimum sampling frequency at 284Hz. You're already sampling much faster than you need to for this plant, at least from the point of view of the control loop. It may be your sampling frequency is dictated by the switching frequency of a power electronic system, which is another matter. In any case, increasing the sampling frequency will make no noticable difference to control performance. Your sample rate is already high enough and I wouldn't recommend increasing it.
Improved performance may be possible through tuning adjustments to the PID controller. Part 3 of the seminar I mentioned gives an outline of how to go about that.
From the point of view of controller performance, you have plenty in hand. 1.3us is 104 CPU cycles, which is about what I'd expect for a basic PID controller. You can optimise that by hand coding in assembly, and you can clock the device a little faster if you're getting close to full CPU load (the F28069 will run up to 90MHz). You can also consider lowering the sample rate to reduce the CPU load, but again there may be other reasons why you've chosen 40kHz.
I hope this helps.
Regards,
Richard
Yes it helped.
But following is my transfer function of the plant(model)
-0.0002819 s^2 - 10.98 s + 1.558e05
--------------------------------------------------
0.0007013 s^2 + 0.2196 s + 1400
plant has its rise time about 0.8ms ,i found this by using stepinfo command in Matlab.
designed PID controller is : 1.819e-08 s^2 + 2.918e-05 s + 0.005
-----------------------------------------
3.637e-07 s^2 + 0.005126 s
This PID works very wel in Matlab simulation , but when I tried on f28069 with sampling rate of (12-15)microseconds to discretize the PID controller with tustin transformation.but it didn't work . So, Is there any cross verification for the discretized PID controller to validate that it will work in dsp platform?
Thanks
Tarakanath
Tarakanath,
This plant model has a RHP zero and a pair of very lightly damped poles. A little time with a root locus plot will convince you that control with the basic PID is going to limited to a very small P & I gain terms. Such small numbers might be a problem even on a 32-bit floating point machine. Can you elaborate on what you mean by “didn’t work” please?
Also, a couple of more questions:
- is there a reason why you’re stipulating a PID controller, rather than some other type?
- what are the tuning objectives – do you have any specific control objectives?
Thanks & regards,
Richard
Thanks Richard, Yes you are absolutely right.The plant has lightly damped poles.and PID controller parameters are:
1 s
Kp + Ki * --- + Kd * -------- with Kp = 0.00562, Ki = 0.975, Kd = 3.15e-06, Tf = 7.1e-05
s Tf*s+1
In Matlab simulation,the designed pid controller has worked very well to achieve the objectives of regulation and rejecting disturbances . But when i use the corresponding discretized PID controller with 'tustin' transformation,with most of the sampling frequencies, the discretized PID controller seems to have poles on/very near to unit circle.So, i feel this might be a reason for not working on actual hardwareset-up.
other type in the sense, to use type 3 compensator right!
I didn't get this "Such small numbers might be a problem even on a 32-bit floating point machine"
please suggest me if there is anything going wrong .
Thanks
Tarakanath.
Tarakanath,
Thanks for sending your PID settings. I was speculating you had much smaller controller coefficients than these which might have run into resolution problems in floating-point, but these should not cause a problem. What did you see when you implemented it in hardware - was it unstable, or something else?
Yes, by "another type" I had a 3P3Z in mind. Then you might try to cancel out those lightly damped poles and replace them with others further inside the unit circle. For example:
0.46754 (z^2 - 1.991z + 0.9924)
-------------------------------
(z-1) (z^2 - 0.4431z + 0.06085)
I attach a Matlab script which compares these responses.
http://e2e.ti.com/cfs-file.ashx/__key/communityserver-discussions-components-files/171/0044.testpid.m
You will get better transient response with this controller, but I'm still concerned about why your PID wasn't working. Do you have anything in the feedback path, like an anti-aliasing filter or ADC attenuator?
Regards,
Richard
Thanks alot Richard . Yes with 3P3Z, response is improved as poles of discreted plant has been cancelled with discreted controller. But can you tell how to get the other part like
0.46754
-------------------------------
(z-1) (z^2 - 0.4431z + 0.06085)
Here there is pole on unit circle, doesn't it have problem of becoming unstable?
When i did closed loop operation, ADC samples are passed through digital low pass filter (in dsp code) with cut-off frequency of 500-1500Hz.the out put of this is passed through discretized PID controller.
Voltage_ADC = AdcResult.ADCRESULT0;
Voltage_actual = (Voltage_ADC) * (3.3/4095)*46.8372; % 46.8372 is sensing circuit conversion factor
e_k=75.0 - Voltage_actual;
vc_k=1.56*vc_k_1 - 0.5603*vc_k_2 + 0.04026*e_k - 0.078*e_k_1 + 0.03776*e_k_2;
e_k_2=e_k_1;
e_k_1=e_k;
vc_k_2=vc_k_1;
vc_k_1=vc_k;
if (vc_k > 0.4) // Anti-wind up design
vc_k = 0.4;
else if (vc_k < 0.2)
vc_k = 0.2;
else
vc_k=vc_k;
EPwm3Regs.CMPA.half.CMPA = (vc_k)* period;//period=1000
In the watch window, I observed both ADC and Voltage_actual values keep changing (which shouldn't be). So i felt like controller is unstable since it has poles at 0.999, 0.5606.I got strcuk at this point because i couldn't conclude whether it is the problem of ADC or controller? Can you suggest at this point.
Thanks
Tarakanath.
Tarakanath,
The pole at z = 1 is an integrator. It’s there to remove steady state error. The pole pair selection in my suggested controller was somewhat arbitrary. I chose a complex pole pair much closer to the origin of the unit circle than those cancelled in the plant, which gives a faster rise time than with the PID. I used sisotool in Matlab to place this pole pair.
Everything simuates fine so I'm not sure why you aren't getting a stable loop with the MCU. Sorry, but I don’t see where the probem is.
You will always see some variation in the ADC readings, even with an absolutely static DC input. It could be worth checking the ADC is functioning correctly by applying a fixed input and logging the results. If this checks out, try attenuating the output of the controller. Maybe there’s a gain in there somewhere I’m not seeing.
By the way, what is the purpose of your filter in the feedback path? Can you try removing it to see if it makes a difference?
Regards,
Richard
Richard,
That was a very refreshing seminar. In my college days I used the Aström & Wittenmark book ( the other one was Ogata for Discrete Time). I was more interested in the Kalman filter theory and I just wanna ask you if you know about a good seminar for this (like you did for TI) and if you can point me to some references too.
Best regads
Gastón
Gaston,
I'm pleased to know you enjoyed it, and thank you for your kind words. I expect to record the second day of the seminar in early 2015. That does contain a section on estimator design, but unfortunately the Kalman filter is not included. Let me ask some colleagues here if they can provide some recommendations for you. Thanks again.
Regards,
Richard
Hi Gaston,
R. G. Brown and P. Y. C. Hwang, Introduction to Random Signals and Applied Kalman Filtering, 4th, J. Wiley, NY, 2012
There are actually too many on Kalman filter, but this one looks good for beginners.
Ling