How do I include a PID block to control the required torque? I want to control the vehicle speed with a speed setpoint or speed profile (NEDC)
17 views (last 30 days)
Show older comments
I have a basic electric car model where I can see speed, displacement, acceleration, force, etc as the torque of the motor moves the car. I want to add a PID controller so I can control the vehicle speed. I tried having the PID directly connected to the torque input and add them, and I would get a good velocity vs time graph but every other graph became a mess. Anyone help?
3 Comments
Sam Chak
on 26 Sep 2024
If Kd ≠ 0, then PID Controller will produce a derivative action. However, if you put the PID in the displacement loop, you aren't controlling the velocity.
Answers (1)
Aravind
on 1 Oct 2024
A PID controller can be implemented using a “PID Controller” block in Simulink. Typically, a PID controller will take the error, defined as the difference between the desired speed and the current speed of the car, as input, and output the necessary torque to achieve the desired speed. Here’s how you can set up speed control using a PID loop:
- Include the “PID Controller” block in your model. Set up the PID gains as required. You might need to tune these values to achieve the desired performance. Simulink provides a “PID Tuner” app that can assist with this process.
- Use a “Difference” block in Simulink to calculate the error, which is the difference between the desired and current speeds. Connect the output of this block to the input of the “PID Controller” block.
- The output of the “PID Controller” block, which is the required torque, should be connected as an input to your plant (the electric car model). This will form a feedback loop to control the car’s speed to follow the setpoint, provided the gains are tuned correctly.
- Run the simulation and observe the vehicle speed, torque, and other relevant outputs. If the performance is not satisfactory, adjust the PID gains manually or use the “PID Tuner” app to optimize them.
For additional resources, you can check out the following documentations:
- Official documentation of The “PID Controller” block: https://www.mathworks.com/help/releases/R2023a/simulink/slref/pidcontroller.html
- Official documentation of The “PID Tuner” App: https://www.mathworks.com/help/releases/R2023a/control/ref/pidtuner-app.html
- An example explaining how to use the “PID Tuner” App: https://www.mathworks.com/help/releases/R2023a/slcontrol/gs/automated-tuning-of-simulink-pid-controller-block.html
I hope this helps!
0 Comments
See Also
Categories
Find more on PID Controller Tuning in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!