[ Software Flow Chart | Pin Assignments | Pulse Width Modulation Strategy | Speed vs. Duty Cycle | C code ]

Click the links to jump to one of the sections below.

Software Flow Chart

Below is a diagram illustrating the logical flow of the software written to operate the automated slot car system.

At startup, a string of characters are sent to the LCD to welcome the user to the race, and then the processor goes into an infinite loop while waiting for the user to press the start button. When the start button is pressed, PD5 goes high and a countdown begins while the LCD is updated. If the user crosses the sensor at the starting line during this period, a false start will be detected and the race will stop.

When the countdown reaches zero, the automated car takes off at 100% duty cycle (15V) and the race begins. During the race, the duty cycle is updated each time the auto car crosses a sensor going into and out of a turn. See the Pulse Width Modulation Strategy section below. In addition, when each of the cars cross the start/finish line sensors, lap counters are incremented, lap times calculated, and the results are sent to the LCD display.

When a preset number of laps are met by either car, the race is finished, the auto car stops, and the winner is determined by which car's lap counter reached the lap count first. A message is sent to the user on the LCD display declaring who won the race.

The user can press the reset button at this point if he or she wants to start another race.

To see the C code that operates the Automated Slot Car system, click here.

[ back to top ]

Pin Assignments

The following pin assignments determine how the MCU is connected to the rest of the system.

Note that the pin connections to the chip are routed through the MCU and LCD Ports on the EVB.

PE0: Auto Car Voltage
0-15V analog input, used for calculating current speed

PE1: User Car Voltage
0-15V analog input, used for calculating current speed

PE2: Difficulty Level Switch
0V = Lo difficulty
2.5V = Med difficulty
5V = Hi difficulty

PD4: Auto/Manual Control
Hi = Auto, Lo = manual control to outside lane

PD5: Start Button
Breaks loop and continues with start sequence

IRQ: Reset button
Triggers interrupt routine to cut voltage to cars and return to waiting for start button to be pressed

PA0: Starting Line sensor for auto car
Triggers service routine to count laps, and to increase duty cycle when falling edge is detected

PA1: Both into corner sensors for auto car
Two sensors tied to this pin through an AND gate which checks a toggle to determine which sensor

PA2: Out of corner sensor for auto car
Triggers service routine to increase duty cycle when falling edge is detected

PA3: Starting line sensor for user car
Triggers service routine to count laps, update user's lap time, and to detect a false start when a falling edge is detected

PA6: PWM to Auto Car
Variable duty cycle square wave output, sent to PWM circuit for amplification and auto car speed control

LCD Port: LCD display
Port D pins are temporarily used for sending print commands to LCD display during welcome sequence, start sequence, while racing, and winner/loser results.


[ back to top ]


Pulse Width Modulation Strategy

A total of five photomicrosensors were mounted in the track, four in the automated car's (outside) lane, and one in the manual car's (inside) lane. Two of the four sensors on the outside lane were placed approximately six inches before each turn and the other two at the exit of each turn, one at the starting line. The sensor in the manual lane was placed at the start line also. Sensors pulses were used for adjusting duty cycle, counting laps, computing speed lap times, and determining the winner of the race.

The outside lane was then divided into eight regions where the duty cycle was held constant over each region, as illustrated below.

A counter is defined in the software that counts timer overflows. Each time the automated car passes through a sensor, this counter is set to zero and the current timer value is stored. Since the timer resets every $FFFF (65,535) clock cycles and the clock speed is 2MHz, a timer overflow and subsequent increment of the counter occurs approximately every 30ms.

In the beginnings of the straight-aways, (regions 2 & 6 in the diagram above), the automated car is driven at 100% duty cycle, the full 15V available. When 210ms has elapsed (about 7 overflows), the car is going full speed, nearing the turn, and the duty cycle is reduced to zero (regions 3 & 7). The car then coasts through the sensor going into the turn, during which time an input capture is detected from the sensors. At a predefined time after the sensor pulse going into the turn has been detected, the duty cycle is then changed to a variable percentage that depends on calibration (see data collected below) as the car goes around the turn (regions 1 & 5). An interrupt service routine is executed at each sensor pulse: input capture for the start of regions 2, 4, 6, and 8, and output compare at the start of 1, 3, 5, and 7.

The outside lane was chosen to be the automated car's lane in an effort to ensure that the human challenger would have the inside lane advantage. Testing has shown that the computer controlled car overcomes this disadvantage and is nearly impossible to beat when set to the Hi difficulty level.

[ back to top ]

Speed vs. Duty Cycle

Data was collected to correlate the steady-state speed of the car with duty cycle. Using this data, the car could be driven at any desired speed between 6 and 9 ft/s by changing the duty cycle accordingly. The data is summarized in the chart below. As shown, duty cycle ranged between 30 and 40%.


Data

Data Summary

[ back to top ]

Home | IntroductionConcept | Timeline | Mechanical Design | Electrical Design | Software Design | Features | Team Members  | Sponsors | Links

Ryan Krauss / Lisa Ellis / Joe Frankel
For problems or questions regarding this web contact [Joe Frankel].
Last updated: 11/25/02.