|
by Jeff Loeliger
Start ý The
Answer Isý ý Designing Functions ý Demonstration
ý Youýre in Control ý Sources
and PDF
DEMONSTRATION
To give a working example, I wrote a
sample program for using this servo TPU function. The program, which
reads one input knob and controls two output servos, was written for
the Motorola MPC555 Evaluation Board as shown in Photo 1. The program
configures the TPU, inputs custom microcode, and sets up the TPU to
run the servo function on two channels.
 |
| Photo 1ýThe
MPC 555 EVB runs demo code using a potentiometer to control
two servos (one in normal mode and one in reverse mode). |
The queued analog-to-digital converter
(QADC) is configured to convert one channel continuously with the
QADC value from the input knob and is then used to drive two servos
in a continuous loop. One servo is run in normal mode while the other
is run in reverse mode to complement each other as the knob is moved.
The MPC555 is a complex device with hundreds
of registers. To make the device easier to use, thereýs an MPC555
header file that defines all the registers and associated bit fields.
The MPC555 also has a utilities header that provides macros to make
using the on-chip TPU simpler.
In order to run the servo program, the
user must first calculate the MIN_COUNT and MAX_COUNT servo values.
Doing this depends on how the TPU is configured. When determining
how fast to run the timebases, all functions running on every TPU
channel must be taken into consideration. To get the best resolution
on the output signal, the timebase should be run as fast as possible
(constrained only by the fact that MAX_COUNT must be less than $8000
timer counts).
" width="254" height="117">
Now,
Getting Connected to the
Internet Can Earn You Cash.
Win
your share of $26,500 CASH
plus great Development Tool Prizes!
Deadline May 1, 2000
More information
For this sample program, the MPC555 has
been configured to run at 40 MHz with the timebase set to system clock
divided by four, giving a resolution of 100 ns. For a typical servo
with a MIN_COUNT of 1 ms and MAX_COUNT of 2 ms, MIN_COUNT and MAX_COUNT
values of $2710 and $4E20 respectively will result. In addition to
defining the MIN_COUNT and MAX_COUNT values, the frequency of repetition
of the output signal must also be established. The REPEAT parameter
has a resolution of $8000 counts which, with a timebase of 100 ns,
equates to 3.2 ms. As servos should be refreshed every 20ý30 ms, and
the formula for calculating the repeat value is [REPEAT ý $8000],
setting REPEAT to seven gives a safe value of 22.6 ms. This is the
value used in the given sample program.
The demonstration program for running
the servo function can be downloaded CPU
code, TPU code.
PREVIOUS
NEXT
Circuit Cellar provides up-to-date information for engineers. Visit
www.circuitcellar.com for
more information and additional articles.
For subscription information, call (860) 875-2199, subscribe@circuitcellar.com
or subscribe online.
ýCircuit Cellar, the Magazine for Computer Applications. Posted with
permission. |