Main Content

Control Vehicle Throttle Input Using a Powertrain Blockset Driver

This example shows how to control throttle input to a Simscape™ Driveline™ vehicle model using a Powertrain Blockset™ Longitudinal Driver block. You add the driver to an open-loop model that uses a Signal Builder block for feedforward control. Adding the driver allows you to model closed-loop control by supplying a reference velocity and a feedback loop.

Open-Loop Simulation Using a Signal Builder Block

In the open-loop simulation, a Simulink® Signal Builder block is used to ramp up the throttle. Simulate the model to see the open-loop response.

  1. Open the model. At the MATLAB® command prompt, enter this code.

     See Code

  2. Enable the signal that goes to the Motor RPM scope block for Simulink data logging and viewing with the Simulation Data Inspector.

     See Code

    The logging badge marks the signal in the model.

  3. Increase simulation time to get steady-state results. Simulate the model.

     See Code

    Even though the throttle input is nonzero at simulation time 0, the vehicle rolls down the hill at first because the input is too small to overcome the gravitational force of the incline. When the input is large enough, the vehicle accelerates up the hill and settles at a velocity of ~20 km/h.

Closed-Loop Simulation Using a Longitudinal Driver Block

To control throttle input, add a Powertrain Blockset Longitudinal Driver block.

  1. Add a Longitudinal Driver block to the model.

    1. Expand the model window to fit the Longitudinal Driver block.

       See Code

    2. Add the Longitudinal Driver block.

       See Code

    3. Change the source of throttle input from the Signal Builder block Throttle port to the Longitudinal Driver block AccelCmd port and terminate the unconnected Throttle port with a Terminator block.

       See Code

    4. Terminate the Info and DeclCmd outports on the Longitudinal Driver block

       See Code

    5. Input a 5.84 reference velocity to the Longitudinal Driver block VelRef port using a Constant block.

       See Code

    6. Input the incline angle signal from the Signal Builder block to the Longitudinal Driver block by connecting the Incline outport to the Grade inport.

       See Code

    7. Input the velocity feedback signal to the Longitudinal Driver block using a Unit Conversion block to convert from km/hr to m/s.

       See Code

  2. Simulate the closed-loop model using the Simple Tire blocks and plot the results.

     See Code

    The drive block increases the throttle input rapidly at the beginning of simulation due to the difference between the velocity feedback and reference signals.

Simulation Comparison

Compare the open and closed-loop results using the Simulation Data Inspector.

 See Code

To see the results in the Simulation Data Inspector, click the Compare icon and then, under Filter Comparisons, click PS-Simulink Converter1:1.

The first plot overlays the results from the open and closed-loop simulations. It shows how much faster the controlled vehicle goes to steady state.

The second plot shows the numerical difference in the results from the two simulations. It shows how much the two signals differ at the beginning of the simulation and how they eventually reach the same steady state.

You can also examine the results for other tire blocks.

 See Code for Magic Formula Tire

 See Code for Friction Parameterized Tire

See Also

| | | | |

Related Examples

More About