NG02.


NG02 is in the preliminary construction stage.  It is a take-off from the SRS Workshop Robot, only, built from scratch, bigger, more powerful, with more and better sensors.  The design goal is to create a machine that can be free to roam in a human environment, providing entertainment  without getting stuck. 

NG01.

The first attempt to build a more powerful machine took ideas from DPA's SRF04, using a 3x5x7 Bud Box for primary chassis support.  This machine was names NG01.  The first attempt at building did not get completed.  NG01 did not make it to the point where it could move because of drive train instabilities.   A sketch of NG01 Layout shows the size is two times that of the SRS Workshop Robot.  NG01 and the SRS Workshop Robots, are shown in this comparison picture.  These are front view and an overhead view of NG01.

NG02.

Because of the drive train instabilities of NG01, that effort was abandonded and NG02 was started.  This is an Outline of NG02, considering the component plates.  The Drive Chain Consists of two GHM-16 motors with US Digital encoders driving drive shafts with timing belts.

A Concept of the NG02 using a stack of deck components indicates the size.  Pictures of NG02 in its preliminary configuration, before installation of the electronics. Picture 01, Picture 02, Picture 03, and, Picture 04.

NG02 has three decks for components, labeled from bottom to top as deck 0, deck 1, and, deck 2. Deck 0 holds the mechanical components of the drive train as well as the motor controller.   Deck 0 Layout  shows the cutouts for the wheels and the caster and the location of the supports for deck 1.  The Sharp GP2D12 IR sensors are mounted on the front supports.

Wheel Hubs

NG02 uses RC Airplane tires, which are not intended to be fixed to an axle, normally free wheeling.  A maching shop wanted about $100 to make the hubs!  Guess it is time to learn to do that.  I obtained a small lathe and my First Four Cuts ever, resulted in two usable hubs.  Actually, I think they are perfect.  The first one, on the left, I drilled the wrong size hole otherwise, it was perfect!  The second attempt was perfect.  The third attempt came out of the lathe when I was parting off the hub.  I think I either forced the cut-off tool or the chuck was not tight enough for the effort.  The 4th attempt is perfect.  I have two hubs for NG02 and a spare.  Wow!  Now for a mill...

Overview

The NG02 is, in general, a re-manufacture of the SRS Workshop Robot.
The SRS Workshop Robot Kit provides an excellent platform for beginning robot construction.  The control, sensor, and, display facilities allow experimenting with construction and algorithms without the frustration of searching for parts.
The SRS Workshop Robot Kit is well enough put together that it is worth remanufacturing to correct some deficiencies.
The SRS Workshop Robot Kit has encoder electronics and encoder wheels which are not at mechanically fixed distances, allowing some variance in behavior, such as missed counts and spurious counts.  The wheels use rubber bands as tires, a not very reliable tire, and, are small in diameter.  Crossing varied floor textures produces severe obstacles to odometry.  The sensor positioning on the SRS Workshop Robot may be less than optimal.
The design of the NG02 is such that it will turn within its circumference allowing easy escape from obstacles.
The NG02 has IR sensors on the front, a ultrasonic ranging device on the front, wheel encoders, an RF datalink, and, an LCD display.

IR Sensors
Sharp GP2D12
10 cm to 80 cm
Untrasonic Sensor
Devanotech SRF04
3 cm to 300 cm
Wheel Encoders
US Digital E2 Shaft Encoder
1000 counts/revolution
Datalink
UPM-96
9600 Baud
Motor Controller
PWM Dual H-Bridge
754410




Hardware

Inspiration

The hardware design is loosely related to the SRS Workshop Robot, and, more closely related to the SR04 Mobile Robot  by David Anderson, as described in an SRS Encoder Article. David Anderson documents his robots on the SMU Geology Department Page.

Chassis Parts


Wheel
Dave Brown 5"
part number
Axle
Stock Drive Products
"
Pillow Block
Stock Drive Products
A7Z6-F2208
Motor
Jameco

Gear 20 Tooth
Stock Drive Products
A 1P 2MYD08020D
Gear 44 Tooth
Stock Drive Products
A 1P 2MYD08044D
Bud Box
Digikey???











Layout

The NG02 is a three wheel with two wheel differential drive and one caster in the rear.  Following the mechanical design of the SR04 chassis in a 3x5x7 Bud Box, the two drive wheels are located forward of the center of the Bud Box, with the axles parallel to the long axis of the box.  The battery is located along the rear of the Bud Box to ensure the caster is in contact with the ground.  The drive wheels are mounted on axles connected by gears to the motors, thus relieving pressure from the motor bushings.  Each of the two axles are mounted in bushing based pillow blocks with retaining collars.

Locating the Axles and Motors

The wheels are mounted on axles connected by gears to the motors.  The GH12 motors have 6mm metric shafts.  To ease installation, 6 mm gears are used.  The axle shafts are 1/4 inch as are the pillow blocks.  The axle gears were drilled out to 1/4 inch.  The gear ratio from the motor to the drive axle is 20:44, the number of teeth on the gears.  The 20 tooth gear has an outside diameter of 17.6 mm and a pitch diameter of 16 mm.  The 44 tooth gear has an outside diameter of 36.8 mm and a pitch diameter of 35.2 mm.  The bore center distance between the gears, when meshed, is between (16+35.2)/2 mm and (17.6+36.8)/2 mm.  Converting to inches, the distance between the center of the axle and the center of the motor shaft is between 1.008 inches and 1.071 inches, closer to 1.008 inches since at 1.071 inches, the gears are not meshed.
The distance from the axle center to the edge of the pillow block is 3/8 inch.  The distance from the center of the motor shaft to the edge of the motor is 7/16 inch.  The maximum distance from the edge of the motor to the edge of the pillow block is 1 - (3/8 + 7/16) = 3/16 inch, so the axle and motor can be mounted such that the gears mesh properly, with 3/16 inch to spare.
The top of the motor must be below the top of the Bud box.   The diameter of the motor is 1.457 inches (37 mm) and the motor shaft is located 0.435 inches from the closest edge of the motor or 1.022 inches from the opposite edge of the motor.   The pillow block raises the center of the axle 0.345 inches.  The line between the center of the axle and the center of the motor shaft is approximately 45 degrees with respect to the edge of the Bud box.

Battery

The Battery is oversized for the application, being used because of a "good buy" from an online distributor.   The robot power draw is less than 1/4 mA and needs a 3 AH battery.  The installed battery is 10A AH, 2-1/2x2-1/2x6 inches.  The thickness of the battery moved the axle forward about 1 inch from the center of the Bud box.

Caster

The caster is a dual rim caster salvaged from an appliance.  The caster is mounted on an aluminum bracket attached to the bottom of the Bud box.

Platform

The electronics platform is 3/16 inch lexan mounted above the Bud box, rounded slightly in the front and a semi-circle in the rear.

Software

The software is based on an RTOS written by Larry Barello, AvrX, written for the Atmel 8-bit processors.
AvrX 2.6 supports a C-language interface, easily programmed with either AVR-GCC with  or AVR Studio.
The software design is similar to

Preliminary Design

The preliminary design of the SRS Workshop Robot was loosely based on the SR04 Mobile Robot  by David Anderson, as described in an SRS Encoder Article.
David Anderson documents his robots on the SMU Geology Department Page.
He has written an excellent article on system software design, see Dallas Personal Robots Group.

Motion Control

The motion of the Robot is controlled by the output of the behaviors as determined by the sensors and user input.  The sensors include physical contact switches, light sensors, IR sensors and sonar sensors.  The user input is determined at compile time of the application.

The primary control mechanism is contained in the behaviors periodic task, executing the functions listed in the Behaviors Table.

Motor Control

Motor control commands are from the motion control tasks, primarily behaviors.  The input to the motor function is includes a speed value and a turn argument.  The speed value is from -100% to 100%.  The turn value is a degree value, negative for left and positive for right.

The basic motion of the robot can be reduced to the left and right wheel encoder counts.  The wheel diameter and the wheel base are the constants of proportionality.  The distance moved by each wheel can be calculated from the respective encoder counts.  The encoder is connected to an ATmega external interrupt pin and the interrupt sense is set to any logic level change.  The wheel encoders have 32 light and dark stripes, giving 64 interrupts per wheel revolution.  The wheel diameter is 2.1 inches and the wheel base is 5.3 inches.  The robot travels 6.6 inches per wheel revolution.

If the robot is traveling straight, either forward or backwards, the wheel counts should be equal.  If the robot is turning, the wheel counts should differ by an amount determined by the number of degrees the robot has turned.  This applies equally to the robot rotating in place, one drive wheel turning forward and the other turning backwards.
The difference in encoder counts can be calculated from the number of degrees desired, Encoder Scilab.

Applying the encoder counts per revolution, wheel diameter and wheel base, the number of encoder count versus the number of degrees turned can be calculated: 
Counts = 0.897 * Degrees.

Determining Encoder Counts From Motion Commands























Direction
Turn
Encoder Relationships
Target
Forward
Straight
Left Encoder == Right Encoder
0

Left
Left Encoder  <   Right Encoder
-- Counts

Right
Left Encoder  >   Right Encoder
+ Counts
Reverse
Straight
Left Encoder == Right Encoder 0

Left
Left Encoder  >   Right Encoder + Counts

Right
Left Encoder  <   Right Encode -- Counts
Rotate
Left
Left Encoder  <   Right Encode -- Counts

Right
Left Encoder  >   Right Encoder + Counts
Stop
N/A
Left Encoder == Right Encoder == 0
0

Task Organization

The task organization is loosely based on the SR04 system design.
A series of behaviors read the robot status and decide indivudual actions to take.
Arbitration selects the highest priority behavior and passes its decision to the motor function.
The motor function uses a PID to decide on the appropriate drive to each of the motors.

The behaviors are
Behaviors
Behavior
Priority
Reacts To
Description
Pseudo Code
Escape
  1
IR sensors
Avoids physical contact.  The IR sensors are 10 to 30 cm.
Escape
Steps
  2
Light sensors looking down.
Uses the analog voltage from light sensors mounted on the bottom front of the robot.  As a ballistic behavior, it is an augmented finite state machine.  Upon detecting a step or an increased distance from the bottom of the robot to a lower reflective surface, the robot stops, spins in place to the left ninety degrees.  If the distance has returned to normal, the robot goes forward at full speed.  If the distance has not returned to normal, the robot repeats the turn and detection.  If the robot does not detect a normal surface after a full turn, it stops and cries for help. Steps
Distance
  3
Ultrasonic sensors.
Uses the analog voltage from IR distance sensors mounted on the front corners of the robot.
Distance
Boundary
  4
Abstract navigation.
Uses artificial lines from an initial point.
Boundary
Sonar
  5
Acoustic ranging.
Uses ranging data from a sonic distance sensor mounted on the front of the robot.
Sonar
Xlate
  6
Turn and rotate.
Turns and offsets the robot position, based on current position and direction parameters.
Xlate
Navigate
  7
Abstract navigation.
Go from the current position to a position defined in x-y coordinates.
Navigate
Prowl
  8
Wander around.
Go in random directions for random times.
Prowl
Passive
 9
Hide and watch.
Go to a point of least sensor detection and stop.
Passive
Cruise
  10
Go straight.
Go straight ahead at full speed.
Cruise

The Periodic Tasks are run by AvrX from the timer queue, in priority order.  Those tasks with lower priority will be run before those with higher priority.  Tasks with equal priorities will be run in a round-robin manner.

Periodic Tasks
Task
Rate
Priority
Description Pseudo Code
ADC
Runs at 20 Hz
6
Primary Control task, calls each behavior function, selects the highest priority and passes the command to the motor function. ADC
Audio
Runs at 20 Hz
6
Primary Control task, calls each behavior function, selects the highest priority and passes the command to the motor function. Audio
Behaviors
Runs at 20 Hz
6
Primary Control task, calls each behavior function, selects the highest priority and passes the command to the motor function. Behaviors
CLI
Runs at 20 Hz
6
Primary Control task, calls each behavior function, selects the highest priority and passes the command to the motor function. CLI Task
Datalog

Runs every 30 seconds

8
Telemetry to a local computer for later analysis of inputs and reactions. Datalog
Display
Runs at 2 Hz
10
Displays selected data on an on board LCD. Display
Health Runs every 1 minute 14
Checks things like battery voltage and puts the result in the telemetry stream
Health
Range Runs every 50 msec 4
Pulses the sonar and waits for a return which may take up to 40 msec.
Range
Trace If debugging, runs every 50 msec 15
For debugging, as an alternative to the datalog task, provides a more detailed data stream.
Trace

The Support functions perform miscellaneous functions for the periodic tasks, behaviors, and run the timer.

Support Functions
Location
Calculates the relative location of a given target. Location
Odometer
Calculates the current location relative to the last reset. Odometer
odometer_reset()
Resets the odometer.  Future locations are relative to the position when the odometer was cleared.

timer_clear()
Clears the time counter.

ISR(SIG_OVERFLOW0)
Interrupts every 1 msec, incrementing the time counter.  Calls  AvrXTimerHandler() to possibly do a context switch.

motor(*motor_CB)
The motor_CB argument is the control block from the highest priority behavior needing service.  Use the control block to change the respective motor PWM and direction values, thus controlling the motion of the robot.
Motor






Tasks and Behaviors

ADC Task

The adc task is run periodically from the avrx kernel.  An interrupt handler stows the adc data into the adc structure and starts the next channel conversion.
On startup, main() calls the adc task.  The adc task calls adc_init() then enters a continuous loop, starting a timer, starting the first adc conversion and waiting until the timer completes.
When the first conversion completes, the interrupt handler puts the adc value into the adc_data[] structure and starts a conversion on the next channel.  When all channels have been converted and stowed, the channel number is set back to zero.
When the ADC_LOOP_TIME timer expires, the adc task loop starts the timer again, starts a conversion on the first channel, and waits for the timer. interrupts

Audio Task

The audio task is a message-based task.  After initialization, the task waits for a message on the audio task message queue.  Upon receipt of a message, the audio task plays the notes or tunes indicated by the contents of the message.

Behaviors Task

The behaviors task is run periodically from the avrx kernel.
On startup, main() calls the behaviors task.  The behaviors task calls behaviors_init() then enters a continuous loop, starting a timer, calling the odometer and location functions, then calling each of the behaviors, in priority order, passing the highest priority behavior to the motor task and waiting until the timer completes.
The order of calling the behaviors is determined by the location of the call in the behaviors source file.
***FIXME***  This needs to be changed to be based on the priority of the behavior and independent of the location of the call in the source file.
The order of the calls is:
escape(&escape_CB);      // Priority  1
steps(&steps_CB);        // Priority  2
distance(&distance_CB);  // Priority  3
boundary(&boundary_CB);  // Priority  4
sonar(&sonar_CB);        // Priority  5
xlate(&xlate_CB);        // Priority  6
navigate(&navigate_CB);  // Priority  7
prowl(&prowl_CB);        // Priority  8
passive(&passive_CB);    // Priority  9
cruise(&cruise_CB);      // Priority 10
The priority of the behaviors is defined only by the order of the function call in the behaviors source code.

Bin_Ascii Support Functions

The binary ascii functions provide conversions between binary and ascii for input and output with human readable devices.

Boundary Behavior

The boundary behavior keeps the robot within specific boundaries, based on information from the odometer and location tasks.

CLI Task

The CLI task provides interaction with a remote host via either a direct connection or the RF datalink.
The CLI task allows for enabling and disabling various behaviors, etc.

Cruise Behavior

The cruise behavior drives the robot straight ahead at a preset speed.

Datalog Task

The datalog task transmits a predefined data stream out the RS-232 port, normally via the RF link to a remote host.

Display Task

The display task controls the LCD display.

Distance Behavior

The distance behavior reacts to input from the range task, primarily avoiding obstacles, aligning with walls, etc.

Encoder Task

The encoder task counts the encoder interrupts from each of the wheel encoders.

Escape Behavior

The escape behavior avoids or extracts the robot from obstacles.

Global_Variable Definitions

External definitions of global variables.  The glogal variables are defined as file-scope variables in the various source code files.  Some of these variables are needed in other files, for example, the adc_data array.

Health Task

The health task monitors various aspects of the robot, providing monitor of particular conditions, such as sensor reaction, battery charge, etc.

Location Task

The location task calculated the location of a target, based on the position and heading information from the odometer task.

Motor Task

The motor task is called by the behaviors task, after calling each of the behaviors.  The input to the motor task is the control block from the highest priority behavior.
The motor task only applies the directed control to the motors.

Navigate Behavior

The navigate behavior goes to a specific target, directing the robot heading and speed, based on the data from the odometer and location tasks.

Odometer Task

The odometer task calculates position, velocity, and, heading from the encoder counts.

Passive Behavior

The passive behavior seeks a location with minimal sensor input and stays there.

Prowl Behavior

The prowl behavior simply roams continously, avoiding obstacles.

Range Task

The range task controls interaction with the SRF04 untrasonic ranging device.

SRF02 Jitter

The jitter in the SRF02 range measurements can be seen on the scope and in the timing values obtained with an ATmega16.   The graph Raw Counter Data is of data collected with a box sitting 17.75 inches in front of the SRF04, as measured from the mid-point of the transducer.  The graph Calculated Distance in Inches is of the same data, converted to inches, using the conversion factor 2227 and modulo 2^16 arithmetic.
The transducer is 0.5 inches tall, so the box was 18 inches from the surface of the PC board.
A future set of measurements will be made, with varying distances from a wall to test the linearity.

Servo Task

The servo task is a future enhancement.

Sonar Behavior

The sonar behavior avoids obstacles detected by the range task.

SPI Task

The SPI task sends and receives data over the SPI bus.

Steps Behavior

The steps behavior is a future enhancement.  The steps behavior reacts to changes in detection of light changes from the QRB113 phototransistors below the robot platform.

Tilt Task

The tilt task is a future enhancement.  The tilt task responds to inclination detected by the MLX90609 gyro and the LIS3LV02 Accelerometer.

Timer Task

The timer task is the heartbeat of the robot.  The timer provides 100 usec interrupts to the avrs kernel to control  CPU allocation, task timing, etc.

Trace Task

The trace task is a future enhancement for debugging.

Xlate Behavior

The xlate behavior allows the robot to translate its position and heading.

Future Enhancements

Attitude

The attitude of the platform, Gyro Test Turntable, was measured with an Atmel STK500v2, two MLX90609 Gyros and one LIS3LV02DQ accelerometer, all from Sparkfun.    The turntable was rotated one turn clockwise, one turn counter-clockwise, one turn counter-clockwise, one turn clockwise, two turns clockwise, two turns counter-clockwise, two turns counter-clockwise, two turns clockwise.  Then, the turntable was wiggled plus and minus approximately forty-five degrees, rather rapidly as can be seen from the amplitude of the heading gyro and the accelerometers.

The preliminary code is working and available as Preliminary Code.  The test turntable was rotated with the preliminary code running, collecting data on a workstation.  The raw data is graphed in Raw Data.

The Gyros and Accelerometer were rotated in a horizonal plane, so the Accelerometer saw very little change in 'vertical', which is its measurement.  Applying several filter algorithms finally revealed a similar structure in the output of the accelerometer and the gyro and potentiomenter measurements.  Gyro and Accel Data.  This similar structure may not be enough to discipline the gyro.

The fall-back position is to merge odometry and gyro data to maintain a more accurate heading.

The data collection rate depends on the processor clock, in this case, 16MHz.

SCK Divisor
Time to Read Gyros
Time to Read Accel
Total Time
32
830 usec
470 usec
1.3 msec
128
232 usec
82 usec
314 usec

It should be noted, the Gyros and the Accelerometer use different SPI modes, the Gyros using mode zero and the Accelerometer using mode three.

Future work will be to add a Kalman filter to reduce the drift shown in Gyro Potentiometer.

MLX90609

Testing the MLX90609 Gyro, I installed it on a turntable.  Gyro Test Turntable.  Then, I rotated it a full turn, CW, CCW, CW, CCW, CCW, CW, CW, CCW.  Then, I rotated it two full turns, CCW then CW.  During all this, after each of the rotations, I let it sit for some 10 seconds.  The data is graphed in Raw Gyro Data.

The drift of the gyro is obvious in Gyro Angles.

I connected a potentiometer to the turntable, as can be seen in Gyro Test Turntable.  The three breakout boards are two each MLX90609, 300 degree/second gyros and a LIS3LV02DQ, 3D accelerometer, all from Sparkfun, part numbers SEN-08372 and SEN-00758, respectively.  The potentiometer is 10-turn, .1% linearity, 10K, from, Jameco, part number 183548.

I repeated the prevoius rotation sequence, but, the time and angles vary somewhat because the rotation is by hand.  The measurements are  graphed in Gyro Potentiometer.

LIS3LV02DQ

Testing the LIS3LV02DQ proved interesting.  The data sheet is short in explaining some facts.  Like de-selecting the chip between single reads.  If you do not de-select the chip, you must use multi-reads.  Using multi-reads, I read the three acceleration values in 82.00 usec.  I wrote an interactive application, Interactive Test Code, to test the chip.

Some Pictures of Parts.

Parts on a Table.  And, More Parts on a Table.
I have to change things around some.  I just got the pillow blocks, today.  They are nice block, bearings, but, WAY too big!

Preliminary Controller Board

Controller Board Block Diagram.
I have been working on the controller strategy.   I am leaning toward a distributed computing model, with possibly more than one simple controller board and some interconnect boards.
Simple Controller and a more complex one-does-all Complete Controller.

Pinouts

Here is a preliminary pinout list.  This is given in three sections.  First, an unsorted connection grouped by sensor..  Second, a sorted list ordered by pin type, analog, digital input, etc.  Third, a sorted list attempting to associate pins with a particular processor.

Unsorted Signals Grouped by Sensor

SPI - SPI Bus
        MOSI - SPI output
        MISO - SPI output
        SCK  - SPI output

GPS - Garmin GPS18 LVC
        TXD - RS-232 data to the GPS
        RXD - RS-232 data from the GPS

L Bumper - two parallel micro switches on the left side of the bumper
        LBUMP - digital input
R Bumper - two parallel micro switches on the right side of the bumper
        RBUMP - digital input

L IR - Sharp on the left front
        LIR_ADC - analog input
C IR - Sharp on the center front
        CIR_ADC - analog input
R IR - Sharp on the right front
        RIR_ADC - analog input

L Light - Light sensor on the front left pointing down
        LLT_ADC - analog input
R Light - Light sensor on the front right pointing down
        RLT_ADC - analog input

Battery - raw battery voltage
        BAT_ADC - analog input

Gyro - SPI based gyro
        GYRO_CS - digital output

Accel - SPI based accelerometer
        ACCEL_CS - digital output

Left Motor - h-bridge input
        LMTR_PWM - PWM output
        LMTR_DIR - digital output
Left Encoder - encoder interrupt and direction
        LMTR_ENC_INT - external interrupt
        LMTR_ENC_DIR - digital input

Right Motor - h-bridge input
        RMTR_PWM - PWM output
        RMTR_DIR - digital output
Right Encoder - encoder interrupt and direction
        RMTR_ENC_INT - external interrupt
        RMTR_ENC_DIR - digital input

Sonar - fixed sonar on the front center
        F_SONAR_PULSE - digital output
        F_SONAR_INT - external interrupt

Sonar - rotating sonar mounted on a servo with blind zone to the front
        R_SONAR_PULSE - digital output
        R_SONAR_INT   - external interrupt
Servo - S148 Servo to rotate the sonar
        R_SONAR_PWM  - PWM output

IR - IR sensor mounted on a mast
        MAST_IR_ADC - analog input
Servo - S148 Servo to raise/lower the mast
        MAST_IR_PWM - PWM output

UM96 - 9600 baud RF serial link
        TXD - TTL Level RS-232 output
        RXD - TTL Level RS-232 input

LCD - SPI based lcd display
        LCD_E   - digital output
        LCD_RS  - digital output
        LCD_RW  - digital output
        LCD_CS  - digital output

List Sorted by Pin Type

PWM output                LMTR_PWM
PWM output                MAST_IR_PWM
PWM output                RMTR_PWM
PWM output                R_SONAR_PWM
SPI output                MISO
SPI output                MOSI
SPI output                SCK
TTL Level RS-232 input    RXD
TTL Level RS-232 output   TXD
analog input              BAT_ADC
analog input              CIR_ADC
analog input              LIR_ADC
analog input              LLT_ADC
analog input              MAST_IR_ADC
analog input              RIR_ADC
analog input              RLT_ADC
digital input             LBUMP
digital input             LMTR_ENC_DIR
digital input             RBUMP
digital input             RMTR_ENC_DIR
digital output            ACCEL_CS
digital output            F_SONAR_PULSE
digital output            GYRO_CS
digital output            LCD_CS
digital output            LCD_E
digital output            LCD_RS
digital output            LCD_RW
digital output            LMTR_DIR
digital output            RMTR_DIR
digital output            R_SONAR_PULSE
external interrupt        F_SONAR_INT
external interrupt        LMTR_ENC_INT
external interrupt        RMTR_ENC_INT
external interrupt        R_SONAR_INT

Attempting to Associate Signals to a Processor, Atmega-xx

PA0 analog input             BAT_ADC
PA1 analog input             CIR_ADC
PA2 analog input             LIR_ADC
PA3 analog input             LLT_ADC
PA4 analog input             MAST_IR_ADC
PA5 analog input             RIR_ADC
PA6 analog input             RLT_ADC
PA7 analog input             RLT_ADC

PB0 digital input            LBUMP
PB1 digital input            LMTR_ENC_DIR
PB2 external interrupt       F_SONAR_INT
PB2 external interrupt       R_SONAR_INT
PB3 PWM output               LMTR_PWM
PB4 digital output           RMTR_DIR
PB5 SPI output               MOSI
PB6 SPI output               MISO
PB7 SPI output               SCK

PC0 digital input            RBUMP
PC1 digital input            RMTR_ENC_DIR
PC2 XCS decoder
PC3 XCS decoder
PC4 XCS decoder
PC5 digital output           LCD_RS
PC6 digital output           LCD_RW
PC7 digital output           LMTR_DIR

PD0 TTL Level RS-232 input   RXD
PD1 TTL Level RS-232 output  TXD
PD2 external interrupt       LMTR_ENC_INT
PD3 external interrupt       RMTR_ENC_INT
PD4 PWM output               MAST_IR_PWM
PD5 PWM output               RMTR_PWM
PD6 digital output           LCD_E
PD7 PWM output               R_SONAR_PWM

XCS digital output           ACCEL_CS
XCS digital output           F_SONAR_PULSE
XCS digital output           GYRO_CS
XCS digital output           LCD_CS
XCS digital output           R_SONAR_PULSE

Add a CS decoder, using 3 lines.