View previous topic :: View next topic |
Author |
Message |
prayami
Joined: 22 Dec 2004 Posts: 78
|
gains of PID controller |
Posted: Tue Mar 22, 2005 3:24 pm |
|
|
Hi...
We are going to develope a Boost(Pressure) Controller for Automobile
engine using 18F4525 and 20MHz crystal.
We need to adjust Duty Cycle supplied to the solenoid valve to control
the pressure. I am not sure that: the output we get from PID formula is the duty cycle we want or some thing else?
Quote: |
//Is the following formula is correct to find duty cycle to drive solenoid valve?
desire_duty = (signed int8)(Tp + Td + Ti);
|
Here is the some portion of the code
I have developed. I have written ISR to get error sum for Integral term.
Quote: |
Tp = Kp * error;
// calculate the integral term
//error_sum = error_sum + (signed int32)error;
Ti = Ki * (float)temp_error_sum;
// calculate the differential term
DeDt = prev_error - error;
Td = Kd * (float)DeDt;
prev_error=error;
// calculate the desired duty cycle
//Is the following formula is correct to find duty cycle to drive
//solenoid valve?
desire_duty = (signed int8)(Tp + Td + Ti);
|
I have also trouble in finding the gains etc. Please explain step by step in detail.
(1) How to find the constants(i.e gain) Kp, Kd and Ki ?
(2) Which is the best method to find these constants for this system?
(3) We have MATLAB, Can we use it some where to find these constants
and how?
(4) Which is the best sampling rate to get better control? |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Tue Mar 22, 2005 4:03 pm |
|
|
It looks like you have the makings of a PHD thesis there! This is not an easy task.
The first thing I notice is:
Quote: | desire_duty = (signed int8)(Tp + Td + Ti); |
It is nice you recognize that an 8 bit answer will give all the resolution you can use. But why are you using a signed number for duty cycle. Do you expect duty cycle to ever go negative?!?!
In theory you can calculate Kp Kd and Ki, but unless you are really good at modeling you will probably do better with a good test fixture and using lots of trial & error.
1) Try first to calculate a steady state answer and solve for Kp.
2) Then hit the system with a step input and adjust Kd for damping.
3) Next adjust Ki to get better accuracy.
4) Next go to step 1.
Adjusting PID loops is an aquired skill. It requires a good "feel" for how the system behaves. If you don't start with that feel, you will have it by the end! _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
Guest
|
|
Posted: Tue Mar 22, 2005 4:12 pm |
|
|
Get the last three issues of NUTS & VOLTS magazine to have an good training lesson on PID loops. |
|
|
Guest
|
|
Posted: Wed Mar 30, 2005 4:36 pm |
|
|
There are some methods of adjusting pid constans by hand,
such as Ziegler-Nichols rule, search net there are alot of info about it it is very simple method u can adjust the constants very close to the real mathematical calculations |
|
|
sseidman
Joined: 14 Mar 2005 Posts: 159
|
|
Posted: Tue Jul 19, 2005 6:49 am |
|
|
|
|
|
|