Configuring the simulation

First and foremost, with the knowledge we gained in this chapter, we have to choose the right simulation times, the solvers, and their options. Let's open the model's Configuration Parameters window (or press Ctrl + E) for the last time.

Simulation times

The Start time parameter will be left as 0.0 seconds. We're not going to wait at the car parking, are we?

Having a powerful engine, we'll reach the target speed of 100 km/h from standstill in less than 10 seconds. But we want to see how the vehicle speed settles to the target speed (to detect overshoots and make sure the target is actually reached), so we'll use a long enough Stop time, 50 seconds.

The step size will be large enough to allow an external (soft real-time) application to run synchronously but small enough to not allow the car to reach a speed higher than the target before the cruise control can cut the throttle. This happens when the target speed is low and the car is in the first gear and jumps from 0 to 20 km/h in less than 2 seconds. Therefore, we're choosing a step size of 0.1 seconds.

In a simulation of 50 seconds, we'll be getting 500 samples.

Tip

Remember that the Scope block is limited to 5000 samples by default with a step size smaller than 0.01 seconds we would have to edit or remove the Limit data points to last option in the 'Scope' parameters window under the History tab.

Solvers

Since we're going to test our cruise controller with an external application, we cannot use a variable-step solver; we have to choose a fixed-step solver.

It must be continuous since we've got three integrators (two in the cruise controller, and one in the car).

The system is mildly stiff: the throttle command, even if clamped, can vary very fast from 0 to 1 (depending on the Kp constant), and the speed signal can be problematic at lower speeds for the reasons we listed earlier.

Since Kp will not have a big value (otherwise, driving the car would be an unpleasant experience) and the chosen step size is small, the ode1 Euler solver is likely to work well, so we're using it.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.79.84