CS452 - Real-Time Programming - Winter 2015

Lecture 20 - Calibration III

Public Service Annoucements

  1. Final exam: 16.00, 14 April, 2015.
  2. First Train Control Demo, Wednesday, 11 March, 2015.

Calibration

1. Calibrating Stopping Distance

Measuring the time to stop


2. Calibrating Constant Velocity

Using Resources Effectively

How much time does it take to stop?

Try the following exercise.

  1. Choose a sensor.
  2. Put the train on a course that will cross the sensor.
  3. Run the train up to a constant speed.
  4. When you are the right distance away that a speed zero command will stop the train on the sensor
  5. Wait for the train to trigger the sensor.
  6. Read the time.

3. Calibrating Acceleration and Deceleration: short distances.

Trains often must travel short distance, starting with the train stopped, and finishing with it stopped. When doing so the train spends its whole time either accelerating or decelerating. Your constant speed calibration is useless because the train doesn't travel at constant speed. Simmilarly your measured stopping distances are not useful.

Creating a perfect calibration of the train's position while it is accelerating is hard. But there is an easy and precise calibration that covers most of the moves the train makes where you need a good calibration It's the subject of this section.

Most of the your train project can get away with ignoring acceleration and decelleration. The one place you can't is when you are doing a short move, giving a speed command followed by a stop command before it gets up to speed. How far will the train go? How long will it be before the train is fully stopped?

Short moves are common when the train is changing direction, which you need to increase the number of possible paths from one point to another.

The general idea is to give the train a carefully timed series of commands knowing how far and for how long the train moves during the series of commands.

A procedure to calibrate short moves.

Write a small application that performs the following sequence of actions.

  1. Place the train on the track in the sort of location where you expect to make short moves.
  2. Give the train a speed n command, where n is big enough to get the train moving reliably.
  3. Wait t seconds.
  4. Give the train a speed 0 command.
  5. Measure how far the train travelled from its initial location.
  6. You how far the train will travel for the chosen values of n and t.
Experiment with different values of t and n until you have a reasonable set of distances you can travel.

You now know how far the train moves for a given sequence of commands.

  1. Position the train that distance ahead of a sensor.
  2. Read the time and give a speed n command.
  3. After t seconds give a speed 0 command.
  4. When the train triggers the sensor read the time again.
The distance between the two readings is the time it takes to make that short move.

Together with knowing when and where the train will stop if given the speed 0 command when running at a constant velocity, this will provide most projects with all the calibration they need. But you can do better.

4. Calibrating Acceleration and Deceleration: Doing Better

At this point you can do most of the things you will want to do for your project. But some things can only be done from a standing stop. It's more elegant to keep the train moving, speeding up and slowing down as required. To do so it's necessary fully to calibrate velocity during the act of accelerating and decelerating. Keeping a train at a pre-determined velocity, for example, requires changing from one speed to another frequently.

To explain velocity changes we must introduce models. On the track the train has a real location, so mant cm past sensor S. In your program the train has a position, so many cm past sensor S'. The model is linked to the real train by the calibration. Neither the number of cm nor even the sensor is necessarily the same in the model and in reality because no calibration is perfect. The performance of a project, such as whether trains collide or not, depends on the difference between the model and reality. The remainder of this section is based on minimizing different measures of discrepancies beteen a model and reality.

Back to real trains. When you give the train a command to change speed, we know roughly how the velocity changes.

  1. slowly at first
  2. increasing
  3. reaching a maximum, possibly for a non-zero time
  4. decreasing
  5. more and more slowly as the new velocity is approached

How should we model the process of speed changes?

The simplest possible model is a step change from the initial velocity to the final velocity. When should the change occur?

You can improve this by constructing a linear velocity change model, a bilinear velocity change model, a quadratic velocity change model, or whatever. Oral comments in class give possibly helpful, possibly extraneous suggestions.

When you drive a train there are four things you care about, all of which are functions of time. Particularly you care about the effects of discontinuities in them.

  1. Location on the track, specified by x(t), usually anchored at the previous sensor.
  2. Velocity along the track, specified by v(t) = x'(t).
  3. Acceleration, specified as a(t) = v'(t) = x''(t).
  4. Jerk, specified as j(t) = a'(t) = v''(t) = x'''(t)

Back to real trains. When you drive a train there are four things you care about, all of which are functions of time. Particularly you care about the effects of discontinuities in them.

  1. Location on the track, specified by x(t), usually anchored at the previous sensor.
  2. Velocity along the track, specified by v(t) = x'(t).
  3. Acceleration, specified as a(t) = v'(t) = x''(t).
  4. Jerk, specified as j(t) = a'(t) = v''(t) = x'''(t)

Models with infinite acceleration (= infinite force)

One model we discussed in Lecture 19 has a discontinity in velocity.

Models with infinite jerk

Models with infinite acceleration approximate velocities with linear segments. We can smooth out the corners using a quadratic approximation.

Models with finite jerk.

Let's look at this from another direction. We have a collection of constraints.

A quartic function has five parameters. Substituting the constraints into the function gives five linear equations in five unknowns. This is the simplest function that has discontinuities in jerk only where it joins the constant solutions. It is the solution to x''''(t) = C. Confidence that this is a reasonable solution is bolstered by noticing that this equation occurs frequently in biodynamic models.


Return to: