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 the Test - Hill Subcomponent Block
In the open-loop simulation, a subcomponent block is used to ramp up the throttle. Simulate the model to see the open-loop response.
Open the model. At the MATLAB® command prompt, enter this code.
Enable the signal that goes to the Motor RPM scope block for Simulink® data logging and viewing with the Simulation Data Inspector.
The logging badge marks the signal in the model.
Increase simulation time to get steady-state results. Simulate the model.
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.
Add a Longitudinal Driver block to the model.
Expand the model window to fit the Longitudinal Driver block.
Add the Longitudinal Driver block.
Change the source of throttle input from the
Test - Hillblock Throttle port to the Longitudinal Driver block AccelCmd port and terminate the unconnected Throttle port with a Terminator block.
Terminate the Info and DeclCmd outports on the Longitudinal Driver block
5.84reference velocity to the Longitudinal Driver block VelRef port using a Constant block.
Input the incline angle signal from the Signal Builder block to the Longitudinal Driver block by connecting the Incline outport to the Grade inport.
Input the velocity feedback signal to the Longitudinal Driver block using a Unit Conversion block to convert from km/hr to m/s.
Simulate the closed-loop model using the Simple Tire blocks and plot the results.
The drive block increases the throttle input rapidly at the beginning of simulation due to the difference between the velocity feedback and reference signals.
Compare the open and closed-loop results using the Simulation Data Inspector.
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.