|
|
||
|
[ 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. |
||
|
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 ]
|
||
|
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 PE2: Difficulty Level Switch PD4: Auto/Manual Control PD5: Start Button IRQ: Reset button PA0: Starting Line sensor for auto car |
PA1: Both into corner sensors
for auto car PA2: Out of corner sensor for
auto car PA3: Starting line sensor for
user car PA6: PWM to Auto Car LCD Port: LCD display |
|
| [ 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
] |
||
|
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%. |
||
![]() |
||
|
[ back to top ] |
||
|
Home | Introduction | Concept | Timeline | Mechanical Design | Electrical Design | Software Design | Features | Team Members | Sponsors | Links Ryan Krauss / Lisa
Ellis / Joe Frankel |
||