So far we've learned how to use the Step source block. This is arguably the most important source because it presents clearly the system's transient answer to a stimulus.
But that's about it; it doesn't show the response to a wave, a random signal, or a noise.
A more thorough test with other sources could help us detect problems that were overlooked. For instance, we didn't take into account while testing that the car can show a very different response in lower gears: at 100 km/h, it was running in fourth gear.
The cruise controller is acting only on the throttle, so we can predict that it will be hard for it to follow decreasing speeds.
Let's try using a Sine Wave block as the target speed source, which was configured as follows:
100
(km/h)20
(km/h)0.2
(rad/s)The simulation result is shown as follows:
Our cruise controller can't use the brakes, so it isn't able to follow the falling side of the wave. But it's able to rise up fast from zero and follow the rising wave accurately.
The Ramp block will give us a linear increase in speed to match. We could use it to observe the maximum speed the car is able to give us. Of course, at some point the car won't accelerate anymore because the opposing drag and rolling resistances will be equal to the force produced by the engine, and a maximum speed will be reached.
Let's try a slow-rising Ramp block using the following configuration:
6
) for this field.0
.0
.The result would look like this:
Everything looks in place: zooming in on the throttle and speed graphs when the car is in first gear doesn't reveal any problems so far.
Let's make a more thorough test using a configurable source: the signal builder block.
The Signal Builder block allows you to create and edit your own signals through a supposedly intuitive graphical user interface. Once you put the Signal Builder block in the model and open it, you should see the following screenshot:
With the mouse you can:
That's all that you can do with the GUI. You may try to delete the signal, but Simulink will complain because this is the only signal in the block. The easiest way to make it work is to create a new signal.
First of all, increase the time range; we've got a 50 second simulation time and this block keeps the default of 10 seconds. To do so, navigate to Axes | Change Time Range as shown in the following screenshot and set Max time as 50
:
Then, create a new signal by navigating to Signal | New | Custom..., represented in the following screenshot:
We'll have to insert Time values and Y values. Spending 5 seconds in lower gears, 10 seconds in higher gears, and using speeds slightly below the thresholds at which gear-shifting occurs, the strings to insert are:
Time values |
|
Y values |
|
Now that we've created another signal, we can safely delete the previous one and obtain the situation presented in the following screenshot:
Let's connect it to the target speed Goto block input and run the simulation again. Now the Scope block will show the following result:
Again, we make sure that there are no problems by zooming in on the Speed and Throttle graphs.
Having found the right calibration constants, we can finally use our cruise controller on something more interesting than a model.