MCT = PCT ? Cruise Program

From Rupert Young (970221.1900 UT)]

Bill Powers (970220.1445 MST)

Let's switch to using the cruise control as the example.....

dv/dt = F(t)/M, or

v(t+dt) = v(t) + F(t)*dt/M.

In the PCT model, the force would be

F(t+dt) = G*[r(t+dt) - v(t)],

Err, where did G come from ? This is gain presumably. Why did you have G as
1000 in your prog ? I notice that making g smaller slows down the response of
the controller. Is this what you mean on p276 of BCP "In order for good
feedback control to exist, this loop gain must be high" ? But why not make it
10000 ?

Hang on, couldn't these equations be made simpler/more general.

Doesn't
        v(t+dt) = v(t) + dv
so
        dv = F(t)*dt/M
but
        F(t) = G*[r - v(t-dt)]
which is
        F(t) = G*e where e is the error signal

so
        dv = e*G*dt/M

but G*dt/M is a constant (k)

so
        dv = k*e
or output = k*e

And this is basically all we need to work out the size of the output in each
iteration of the loop. k being the function that converts error signal to
output and is dependent upon the application.

I tried modifying the program, below, accordingly and came up with exactly the
same results. Again acceleration (dv) is limited to 2m/s.

Though as I see from the same page in BCP you say output is equal to k*e
so this is nothing new but I find the prog slightly clearer as the iterative
loop becomes independent of the output function, denoting that the behaviour
of the loop is the same no matter what the control system is.
Is this correct ?

ยทยทยท

--
Regards,
Rupert

********************************************************
program cruise;

var u,v,f,m,g,r,t,e,dt,dv,k,max: real;
    i: integer;

begin
   f := 4000; {maximum force}
   v := 0; {current velocity - perceptual signal}
   r := 30; {meters per second - reference signal}
   m:= 2000; {Kilograms - vehicle mass}
   g := 1000; {Newtons per m/sec error}
   dt := 0.1; {sec}
   t := 0.0;
   k := g*dt/m; {error to output constant}
   max := dt*f/m; {maximum acceleration}

   for i := 0 to round(24.0/dt) do
   begin
      dv := k*e;
      if dv > max then dv := max;
      v := v + dv;
      e := r - v;

      if abs((t - trunc(t+dt/10))) < 0.00001 then
      begin
        writeln('t = ',t:5:1,' sec e = ',e:6:2,' dv = ',dv/dt:4:3,' v = ',v:4:1,'
m/sec');
      end;
      t := t + dt;
   end;
end.

********************************************************
dt = 0.1

t = 0.0 sec e = 30.00 dv = 0.000 v = 0.0 m/sec
t = 1.0 sec e = 28.00 dv = 2.000 v = 2.0 m/sec
t = 2.0 sec e = 26.00 dv = 2.000 v = 4.0 m/sec
t = 3.0 sec e = 24.00 dv = 2.000 v = 6.0 m/sec
t = 4.0 sec e = 22.00 dv = 2.000 v = 8.0 m/sec
t = 5.0 sec e = 20.00 dv = 2.000 v = 10.0 m/sec
t = 6.0 sec e = 18.00 dv = 2.000 v = 12.0 m/sec
t = 7.0 sec e = 16.00 dv = 2.000 v = 14.0 m/sec
t = 8.0 sec e = 14.00 dv = 2.000 v = 16.0 m/sec
t = 9.0 sec e = 12.00 dv = 2.000 v = 18.0 m/sec
t = 10.0 sec e = 10.00 dv = 2.000 v = 20.0 m/sec
t = 11.0 sec e = 8.00 dv = 2.000 v = 22.0 m/sec
t = 12.0 sec e = 6.00 dv = 2.000 v = 24.0 m/sec
t = 13.0 sec e = 4.00 dv = 2.000 v = 26.0 m/sec
t = 14.0 sec e = 2.39 dv = 1.260 v = 27.6 m/sec
t = 15.0 sec e = 1.43 dv = 0.755 v = 28.6 m/sec
t = 16.0 sec e = 0.86 dv = 0.452 v = 29.1 m/sec
t = 17.0 sec e = 0.51 dv = 0.271 v = 29.5 m/sec
t = 18.0 sec e = 0.31 dv = 0.162 v = 29.7 m/sec
t = 19.0 sec e = 0.18 dv = 0.097 v = 29.8 m/sec
t = 20.0 sec e = 0.11 dv = 0.058 v = 29.9 m/sec
t = 21.0 sec e = 0.07 dv = 0.035 v = 29.9 m/sec
t = 22.0 sec e = 0.04 dv = 0.021 v = 30.0 m/sec
t = 23.0 sec e = 0.02 dv = 0.012 v = 30.0 m/sec
t = 24.0 sec e = 0.01 dv = 0.007 v = 30.0 m/sec

[From Bill Powers (970221.1410 MST)]

Rupert Young (970221.1900 UT) --

F(t+dt) = G*[r(t+dt) - v(t)],

Err, where did G come from ? This is gain presumably. Why did you have G
as 1000 in your prog ? I notice that making g smaller slows down the
response of the controller. Is this what you mean on p276 of BCP "In
order for good feedback control to exist, this loop gain must be high" ?
But why not make it 10000?

Why not, indeed? If you wanted to, you could. But try eliminating the
program step that limits the output to 4000 newtons. Then you will see that
as you raise the gain, two things happen: first, the speed approaches the
reference speed more rapidly, which is good. Second, the initial output
force rises to very large values, implying a high acceleration of the car,
which is bad if the car can't actually accelerate that fast.

I picked G to give what seemed a realistic acceleration of the car, so
basically it accelerated as fast as possible at first, then as the speed got
within a small range of the reference speed, began to accelerate more and
more slowly, in the way that real cruise controls work. By adjusting the
parameters of the control model, you can make it approximate the behavior of
the real system. You would use different values of G and of the output limit
(and weight) for different cars; a Formula 1 racing car could handle a lot
more G than a Ford Escort, and a higher value of maximum acceleration.
Although it does occur to me that Indy cars don't generally run on cruise
controls.

Hang on, couldn't these equations be made simpler/more general.

Doesn't
       v(t+dt) = v(t) + dv
so
       dv = F(t)*dt/M
but
       F(t) = G*[r - v(t-dt)]

Oops. You're going to get into infinite regress here because now you have to
calculate v(t - dt) which comes from F(t-dt) and so on forever. Hans can
probably tell you how to do this; sequential equations can't be handled with
straight algebra.

You can do some simplifying:

v(t+dt) = v(t) + F(t)*dt/M

which is
       F(t) = G*e where e is the error signal

so
       dv = e*G*dt/M

but G*dt/M is a constant (k)

so
       dv = k*e
or output = k*e

And this is basically all we need to work out the size of the output in
each iteration of the loop. k being the function that converts error
signal to output and is dependent upon the application.

Yes, but you have to calculate e first. And e comes from the difference
between the present velocity and the reference value, and the present
velocity comes from the previous acceleration and velocity, and so on. But
you're right: output = k*e. If that's easier to understand, by all means
write the program that way.

I tried modifying the program, below, accordingly and came up with exactly
the same results. Again acceleration (dv) is limited to 2m/s.

Right, that's the same as limiting the output force to 4000 newtons.

Though as I see from the same page in BCP you say output is equal to k*e
so this is nothing new but I find the prog slightly clearer as the
iterative loop becomes independent of the output function, denoting that
the behaviour of the loop is the same no matter what the control system
is. Is this correct?

The treatment in B:CP was very much simplified. It assumed a purely
proportional control system with a proportional environment. In that type of
system, the result is the same regardless of the output gain, if the gain is
high enough. In the present case, we have a proportional output function,
but an _integrating_ environment. The same rules of thumb don't apply. In
this sort of system, because of the integral, the static loop gain is
infinite. The gain of the output function now determines how rapidly the
error will be corrected; in the long run, the error will be corrected
exactly no matter what the gain (greater than zero). That's because any
output at all will increase the speed, so the speed will increase until the
output is exactly zero. That occurs only when the error is exactly zero.

Your program is fine -- it's exactly equivalent to mine, although it's
arranged differently and you achieve the limit of output differently. When
you can write the program for the same model in different ways, you know you
understand the model.

Best,

Bill P.