Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

How to combine two PID controllers in one system?

  1. Jun 12, 2015 #1
    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.
     
  2. jcsd
  3. Jun 12, 2015 #2

    Hesch

    User Avatar
    Gold Member

    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: Jun 12, 2015
  4. Jun 12, 2015 #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 modelled in this car model.
    snapshot3.png
     
  5. Jun 12, 2015 #4

    Hesch

    User Avatar
    Gold Member

    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:
    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 wont have as many problems with "wind-up" in your integrator ( PID-function).
     
    Last edited: Jun 12, 2015
  6. Jun 14, 2015 #5

    jim hardy

    User Avatar
    Science Advisor
    Gold Member
    2016 Award

    So you're controlling distance, using throttle and brakes ? Those control acceleration...



    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"
     
  7. Jun 18, 2015 #6

    jim hardy

    User Avatar
    Science Advisor
    Gold Member
    2016 Award

    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.
     
  8. Jun 19, 2015 #7
    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. :)
     
  9. Jul 15, 2015 #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?
     

    Attached Files:

    • SCL.png
      SCL.png
      File size:
      81.8 KB
      Views:
      186
    • SCL.png
      SCL.png
      File size:
      82.2 KB
      Views:
      194
  10. Jul 15, 2015 #9

    Hesch

    User Avatar
    Gold Member

    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 )
     
  11. Jul 16, 2015 #10
    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 :/
     

    Attached Files:

  12. Jul 16, 2015 #11

    Hesch

    User Avatar
    Gold Member

    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: Jul 16, 2015
  13. Jul 17, 2015 #12

    Hesch

    User Avatar
    Gold Member

    Correction: Should have been:

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

    Sorry.
     
  14. Jul 17, 2015 #13

    FactChecker

    User Avatar
    Science Advisor
    Gold Member

    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: Jul 17, 2015
  15. Jul 28, 2015 #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
     

    Attached Files:

  16. Jul 29, 2015 #15

    donpacino

    User Avatar
    Gold Member

    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.
     
  17. Aug 27, 2015 #16

    Henryk

    User Avatar
    Gold Member

    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: Aug 27, 2015
  18. Sep 7, 2015 #17
    Thank you very much for your help :) I managed to solve it, I was not using proper saturation parameters.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: How to combine two PID controllers in one system?
  1. PID Control (Replies: 3)

  2. PID control doubt (Replies: 1)

Loading...