How to combine two PID controllers in one system?

In summary, the conversation discusses the creation of a model for adaptive cruise control in a car. The only input for the model is a user-set distance between the car and the leading vehicle. The goal is to control this distance using throttle and brakes, but currently, only the throttle is being controlled using a PI controller. The conversation then moves on to discussing the possibility of using two parallel controllers for throttle and brakes, but it is determined that this is not feasible and a decision-making process is suggested instead. The conversation also touches on the importance of considering the physical meaning of gas and brake inputs in the model. The idea of using an inner speed-control
  • #1
Gauzi
13
0
I have a model of car, my aim is to make a simple model of adaptive cruise control. The only input to this model is a user set distance (range 2 to 50 meters), this is the distance that our vehicle should maintain between itself and the leading vehicle. I plan to control this using throttle and brakes, presently I am controlling only throttle using PI controller, and hence I am able to follow a car which moves with a fixed velocity and does not slow down in middle ( the leading car should not slow down because the following car does not have brakes, so its not possible to slow the following car).

Now I want to introduce brake controller, and I need some suggestions or guidance with respect to how can I have two controller in parallel i.e one for throttle and one for brakes.

Note: I am doing all this using Simulink.
 
Engineering news on Phys.org
  • #2
Gauzi said:
how can I have two controller in parallel i.e one for throttle and one for brakes.
You cannot. The PID-controllers will start a fight.
Use one PID-controller. Then make some decision-making proces: If the output of the PID-controller is negative: use the brake. If it's positive: use the throttle.
You must have some "dead-band" built into this decision, or there will be a fight anyway:

If (output>3%) then throttle = output-3% else trottle = 0;
If (output< -3%) then brake = -3%-output else brake = 0;

Is your PID-controller digital or analog?

Why don't you use the motor as a brake (negative torque)?
 
Last edited:
  • Like
Likes FactChecker
  • #3
My PID controller is analog.
I cannot use motor as a brake because I already have a car model which expects only two inputs namely Throttle and Brakes, so the Brakes are already modeled in this car model.
snapshot3.png
 
  • #4
Gauzi said:
I cannot use motor as a brake because I already have a car model which expects only two inputs namely Throttle and Brakes, so the Brakes are already modeled in this car model.
Well, models are to be changed. In your model there are not two parallel PID-controllers, but one PI-controller.

How come that you can ignore this by your question? You are changing your model!

You can insert this function-block:
Hesch said:
If (output>3%) then throttle = output-3% else trottle = 0;
If (output< -3%) then brake = -3%-output else brake = 0;
just in front of the brake/gas block.

If a D-function is needed , I'd recommend inserting this function in the feed-back path. Otherwise the tyres of the car will be worn very quickly. In your model you must consider what "gas" and "brake" means physically. It would clarify what you are doing if you call the inputs "positive force" and "negative force" instead. Then it becomes clear that the gas/brake/speed block includes an integrator. Also the "distance_from_other_car" block includes an integrator. So now you have three integrators in the loop ( alert ).

You will need two D-functions in the loop, to keep the the closed loop stable.

In your model, you have this label: "Error". What kind of error: position/velocity/force? For your own sake: Write what is meant so you know what you are doing.

If I were to build a controller, I'd make up an inner speed-control-loop and an outer distance-control-loop. Then the controller, as a whole, would be much more robust. Having "tuned" the speed-controller, it's "a piece of cake" to tune the distance-controller. You won't have as many problems with "wind-up" in your integrator ( PID-function).
 
Last edited:
  • #5
So you're controlling distance, using throttle and brakes ? Those control acceleration...
Gauzi said:
The only input to this model is a user set distance (range 2 to 50 meters), this is the distance that our vehicle should maintain between itself and the leading vehicle.
Hesch grasped it
The car itself integrates twice - once to turn acceleration into speed, again to turn speed into distance...
So you have three integrators in cascade,

Does your block diagram reflect that? The print on your drawing is too small to read.

Look up "Three Element Control"
 
  • Like
Likes donpacino
  • #6
What is that model you posted?
It's too small to read the text.

Hesch said:
If I were to build a controller, I'd make up an inner speed-control-loop and an outer distance-control-loop. Then the controller, as a whole, would be much more robust. Having "tuned" the speed-controller, it's "a piece of cake" to tune the distance-controller. You won't have as many problems with "wind-up" in your integrator ( PID-function).

that was good advice.
Sounds a lot like three element controls, but I've only worked with them on steam boilers.

"A question well stated is half answered"

When you help the folks here to understand your question they usually shower you with help.
 
  • Like
Likes Gauzi
  • #7
jim hardy said:
What is that model you posted?
It's too small to read the text.
that was good advice.
Sounds a lot like three element controls, but I've only worked with them on steam boilers.

"A question well stated is half answered"

When you help the folks here to understand your question they usually shower you with help.
Hi, thank you for the suggestion, I will try to express myself better. Presently, I am trying to work with the idea presented by Hersch, will post a question when I am done with the modification. Thank you again. :)
 
  • #8
Here is my speed control loop. I am controlling brakes and throttle depending on situation. Does it seem like a correct way to control it?
 

Attachments

  • SCL.png
    SCL.png
    29.3 KB · Views: 780
  • SCL.png
    SCL.png
    23.6 KB · Views: 1,057
  • #9
Gauzi said:
Does it seem like a correct way to control it?
You have attached the speed controller two times. What about the position controller?

Anyway I see that you are using some program (Simulink?) in where continuous and discrete signals are mixed up ( PI(s) , z-1 ). It's indeed a clever program. I hope it knows what it is doing. Discrete controllers (digital controllers) are very clever to handle time-delays, as delays are already "built in" the controller because calculations include calculation delays. But earlier you wrote that your PID was analog, so stick to that. A time delay of T sec. could be adapted by ( 1 / ( s + T ) ).

Your plant has two different tranfer functions included: Brake ( B(s) ) and throttle ( T(s) ). You could insert a prefilter before the brake = T(s)/B(s). Then in theory the brake and the throttle should act identical on a signal from your PI, because T(s)/B(s) * B(s) = T(s).

I would measure/calculate the transfer function as for the throttle. Then I would calculate a PID so that the damping was exact = 1 ( just an example). Having done so I would split the PID into a PI filter (forward) and a PD filter (backward). The characteristic equation will not be changed due to this split.

The transfer function, T(s), should look something like:

speed(s)/throttle(s) = k1 / ( s2 + k2*s + k3 )
 
  • Like
Likes Gauzi
  • #10
Hesch said:
You have attached the speed controller two times. What about the position controller?

Sorry I uploaded SCL twice, here I have uploaded distance control. My speed controller seems to work really fine, I replaced the discete delay block by ( 1 / ( s + T )). The tuning of my distance loop is a problem now, trying to tune it since past 4 hours :/
 

Attachments

  • distancecontroller.png
    distancecontroller.png
    9.5 KB · Views: 873
  • #11
Gauzi said:
The tuning of my distance loop is a problem now
I guess that the transfer function for the speed controller could be something like

ks / ( s + 2 )( s + 2 )) = ks / ( s2 + 4s + 4 )

The right block, making speed difference to distance, contains an integrator ( 1/s ). Thus the open loop of the distance controller without the PID must have a transfer function like

kd / ( s3 + 4s2 + 4s )

Now you could design a PID2 as for the distance controller like

Hpid = kpid( s + 2 )( s + 2 ) / ( s + 0.5 ) which results in an open loop transfer function as for the distance controller:

kpid*ks / ( s( s + 0.5 ) ), if you split the PID2 into PID * PD ( forward/backward).

You have to use two D's ( two zeroes: (s+2)(s+2) ) here because you have two poles at origo.

Now calculate kpid so that the transfer function of the closed loop distance controller will be about ( damping ratio = 1 )

G(s) = 1 / ( s + 0.25 )( s + 0.25 )

I know that the explanation above may be hard to understand, but study root locus, be familiar with what is happening here. Sketch some root locus.
Don't hesitate to ask.
 
Last edited:
  • Like
Likes Gauzi and jim hardy
  • #12
Hesch said:
A time delay of T sec. could be adapted by ( 1 / ( s + T ) ).
Correction: Should have been:

. . . could be adapted by ( 1 / ( sT + 1 ) )

Sorry.
 
  • #13
The first thing you need to do is to implement Hesh's first recommendation of introducing a dead-band to a single PID signal where the negative values below the dead-band are directed to the brakes and the positive values above the dead-band are directed to the gas (and 0.0 goes to the other control). Without it, the controls will be fighting each other and the result will be a mess. There is no reason that can not be implemented in an analog controller. Split a single command into two signals. Subtract a small positive number from the gas command and a small negative number from the brake command. Then send the gas command through at limiter with a zero lower limit and send the brake command through a limiter with a zero upper limit.
 
Last edited:
  • #14
Hi,
I have a speed controller and a distance controller. The distance controller has speed controller as inner loop. Now I want to limit the speed to which my car can follow the leading car, any idea on how I could achieve it? I am trying to use a switch in distance controller where the input to inner loop changes depending on the max speed limit. Will post this pic later as am still trying to get it to work. Any suggestions would be appreciated.
Thank you
 

Attachments

  • Screenshot-1.png
    Screenshot-1.png
    21.1 KB · Views: 729
  • Screenshot.png
    Screenshot.png
    29.6 KB · Views: 710
  • #15
Gauzi said:
Hi,
I have a speed controller and a distance controller. The distance controller has speed controller as inner loop. Now I want to limit the speed to which my car can follow the leading car, any idea on how I could achieve it? I am trying to use a switch in distance controller where the input to inner loop changes depending on the max speed limit. Will post this pic later as am still trying to get it to work. Any suggestions would be appreciated.
Thank you

Do you know how to use saturation blocks?
If you don't look them up.
If you do, the challenge now is creating a saturation block that is variable. You can do this through min and max blocks.
 
  • Like
Likes Gauzi
  • #16
You can 'wire OR' distance and speed controller together. For throttle it would look something like this:

WIRE OR.png


For the brake, the diodes are the other way around.
 
Last edited by a moderator:
  • Like
Likes Gauzi
  • #17
Thank you very much for your help :) I managed to solve it, I was not using proper saturation parameters.
 

FAQ: How to combine two PID controllers in one system?

What is a PID controller?

A PID controller is a feedback control system that uses proportional, integral, and derivative components to regulate a process and maintain a desired setpoint.

Why would I need to combine two PID controllers in one system?

Combining two PID controllers can increase the control accuracy and stability of a system. It can also allow for more complex control strategies to be implemented.

How do I combine two PID controllers?

There are several ways to combine two PID controllers, including parallel, series, and cascade configurations. The specific method will depend on the specific system and control objectives.

What are the benefits of combining two PID controllers?

Combining two PID controllers can improve the performance and efficiency of a control system. It can also allow for more precise and robust control of complex systems.

Are there any drawbacks to combining two PID controllers?

Combining two PID controllers can add complexity to the control system and may require more tuning and maintenance. It is important to carefully consider the benefits and drawbacks before implementing a combined PID controller system.

Similar threads

Replies
0
Views
1K
Replies
5
Views
3K
Replies
2
Views
5K
Replies
0
Views
1K
Replies
5
Views
2K
Back
Top