MCU1 (Atmega128 hardware controller)

This is was originally designed as one of two Atmega128's on Tarzan.  The other was dedicated to sonar, however several decisions led to consolidating the functions of both boards into one, without requiring redesign:
* Reducing left and right encoders to just one freed up the right encoder port.
* Eliminating the r/c receiver "heartbeat" eliminated the LS157 multiplexer on Port C.
* Switching from Senscomp to Maxbotix sonars allowed room to interface 6 sonars on Port D.

At least one lesson was learned here, especially to provide a full set of pin-outs for a processor and include numerous power and ground pin arrays, in order to easily rewire for a change in plan.  This applies mainly to the prototype stage.  Once testing is complete and a production board (for higher reliability or to make more robots) is desired, then it is smart to switch to a functional port connector/cabling arrangement that supports ribbon cable connectors but also still leaves flexibility.

The processor is on a premade daughter board made by Olimex, so this is a carrier board design.  The functions of MCU1 are:
* IRQ-based quadrature decoding of the distance encoder (2 IRQ channels). * 50Hz sampling loop for encoder odometry
* Motor interface - drive the PWM servo protocol Novak ESC control line based on command from the PC.
* Steering interface - similar to motor interface but to Hitec steering servo.
* Battery voltage monitoring (not yet used).
* Front and back bump switch monitoring.
* Toggle button monitoring (located on top of the mast) for emergency stop or reset, depending on mode.

Here's the finished board:

Here is the final design schematic for the carrier board.

And the printed circuit board layout:

Discussion:

The Novak Goat Crawler BLDC motor is controlled directly by the Novak ESC that is wired to it at the factory.  The ESC accepts control settings for the motor as if it were a hobby servo, ie a 50Hz PWM signal with pulsewidth coding the direction and power.  The PWM line to the ESC is now hand-wired (on the back of the board) to pin B7, whose alternate function, OC1C, is used.  This pin is thus directly driven by 16-bit Timer/Counter 1 using mode 8 (PWM, Phase and Frequency Correct).

Motor PWM limits are:
1330us = motor stopped, center of deadband
1300us = upper edge of reverse deadband limit
1360us = lower edge of forward deadband limit
The useful limit for reverse power is tbd. (prelim ~1200us)
The useful limit for forward power is tbd. (prelim ~1600us)

The steering servo is a standard, metal gear, double ball-bearing Hitec servo. It is controlled using pin B6 (OC1B) driven by T/C 1. Steering PWM servo limits are:
1260us = full right
1500us = straight
1640us = full left

Gear shifting is not presently used, but an interface is reserved for it on pin B5 (OC1A).

MCU1 reports a fixed length binary packet of all measurement variables each period over RS232 at 500,000 baud.

It reads a fixed length binary command packet from the PC, carrying motor, steering and sonar binary control instruction.