Test with other sources

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.

Sine Wave

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:

  • Bias: 100 (km/h)
  • Amplitude: 20 (km/h)
  • Frequency: 0.2 (rad/s)

The simulation result is shown as follows:

Sine Wave

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.

Ramp

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:

  • Slope: As we have a simulation time of 50 seconds, set the final target speed to 300 km/h. So the slope parameter will be 300/50 = 6 km/h per second. Enter this value (6) for this field.
  • Start time: 0.
  • Initial output: 0.

The result would look like this:

Ramp

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.

Signal Builder

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:

Signal Builder

With the mouse you can:

  • Drag the points up and down (but not right/left)
  • Drag the vertical lines right and left
  • Drag the horizontal/oblique lines up and down
  • Open a fancy menu by right-clicking the mouse

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:

Signal Builder

Then, create a new signal by navigating to Signal | New | Custom..., represented in the following screenshot:

Signal Builder

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

[0 5 5 10 10 20 20 30 30 40 40 50]

Y values

[30 30 50 50 80 80 100 100 120 120 140 140]

Now that we've created another signal, we can safely delete the previous one and obtain the situation presented in the following screenshot:

Signal Builder

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:

Signal Builder

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.

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

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