
The mtr_tab.h file is an array in which elements represent pwm duty
cycles expressed in terms of E clocks.  On my 8mhz 68hc11, an E clock
is 500 ns.  Due to the nonlinear response of pwm-controlled DC motors
there is not a 1:1 mapping of increments in speed to increments in pwm
duty cycle.  It is desireable that the speed increments be linear, so
speed is used as an index into the mtr_tab array with the value at that
index be the duty cycle required to achieve that speed. 

The values for this table are to be filled in experimentally.  In
order to do this, you should first get both pwm and motor encoder
services working.  The problem of mounting an encoder on the motor
shaft may be significant, but in order to have proportional responses
from the speed controller, you must have feedback from the motor.  I
have included an encoder.ps program which you can use to print encoder
wheels (edit the file to set the number of divisions and the size in
inches, then lpr it).  I generally glue the printed encoder wheel on
some card stock to make it stiffer, then use super glue to mount it on
the motor shaft.  The encoder wheel is read by pointing a reflective
IR indicator at it.  This sounds pretty fragile, but in practice has
lasted a couple of years on at least four different robots.  If you
can find a motor with a mounted encoder you can read, so much the
better.  Be forewarned, though, that the interrupt rate is the motor
speed times the number of divisions on the encoder; high speeds with
dense encoder wheels makes for large numbers of interrupts.

When you have the encoders connected to Timer Input Compare ports, the
program named motest.c should help in gathering the data appropriate
for your particular motor/encoder combination.  You should end up with
a data table that looks like mtr_tab.data.  If you have gnuplot
installed, you can use the plotme script to check the results (edit
the file motor_plot.input to change the file named in the plot command
to your data file).  You may want to add data points "in between" the
ones you have to allow the speed controller more choices (a spline fit
does a nice looking job).  When you have an acceptable table, you can
reflect it around zero and put it in the final form of mtr_tab.h.

The mtr_tab.h provided is for some canon motors I picked up surplus.
It is possible this mtr_tab.h file will work OK with your motors, but
then again, it may not work at all.  It is probably a good idea to
build one of these just to learn about how your hardware performs in
this critical function.  Just remember, the values in your mtr_tab file
must be smaller than the interrupt period of the pwm routine (ie 4.1ms
is 8200 E clocks on my system).


