Next: Threads in Java
Up: No Title
Previous: Real-time simulation
Simulating a cruise control system
On the CS100A home page, you can find program CruiseControl, which
you can execute from the web. Start it. Besides a system output
window, five small windows will appear, each of which represents one
component of the cruise control system. (To see the full title on a
window, you may have to make the window wider.)
- 1.
- A clock. You can see the clock ``ticking'' away.
The period 1000 means that the clock ticks every 1,000 milliseconds,
or every 1 second. You can change this to a smaller or larger number
of milliseconds by clicking in that text field, typing a
new number, and pressing button Read period. The program won't
allow a period of less than 100 milliseconds).
- 2.
- The road grade is set initially at 3 degrees -- slightly
uphill -- since this is Ithaca. Typically, a microprocessor would be
attached to a sensor of some sort that would detect the road grade. In
our simulation, you, the user, can change the road grade by typing a
new integer and pressing button Read grade. The program won't
allow a grade steeper than +/- 10 degrees.
- 3.
- The accelerator will be switched on or off by the program
as needed. This window just displays its status. There is also a
button that you can press to turn output on or off. Press it;
thereafter, at each clock tick, a single line of output is printed in
the system output window, telling you the status of the accelerator,
the change in the current speed due to the accelerator being on, the
change in speed due to the road grade, the total speed change for this
tick, and finally the new current speed.
- 4.
- The desired speed is set initially at 65. You can change
the desired speed, just as you can change the road grade. Go ahead;
raise it or lower it.
- 5.
- The current speed is initially 50 because we just merged
into faster traffic and want to let the cruise control bring us back
up to speed. The current speed is simulated by the program; how much it
changes at each clock tick depends on whether the accelerator is on,
the difference between the current and desired speeds, and the
road grade.
Spend some time experimenting with this cruise control simulation.
Become familiar with the five components on the screen.
Next: Threads in Java
Up: No Title
Previous: Real-time simulation
Claire Cardie
1998-11-11