Word

advertisement
Problem Solving Lab - Initial Program Outline Assignment
Goals: The goals of this project are to solve a real world problem using the Problem Solving
Methodology that you were introduced to earlier in the course. You will have an opportunity to
apply your programming knowledge and to use your Matlab skills. As part of the project, you
will become familiar with a microcontroller and the use of sensors to control a program. To
accomplish the tasks you will need to be able to plan the program development, work as a
team, and use time efficiently.
Scenario: You have been hired by the Brutus Buckeye Train Co. to create a prototype of a fully
automated train and road crossing. You are part of a team of developers working to design the
program for the system. Your task is to create a program that ensures the proper functioning
and safety of the system. There is a video available through another link that shows the general
setup and expected performance.
You will be using a standard n-scale model train and control it with an Arduino. The Arduino is
an open source microcontroller. Functions have been created that are callable from Matlab
and which interface with the Arduino to control signals sent to the various devices as shown in
Figure 1. You should read the project description document to get a more complete
understanding of the project and tasks.
MATLAB
Train /
Arduino
Break
Beam
Sensors
Track
Crossing
Lights
Crossing
Gate
Figure 1: Relationships between Matlab, the Arduino, and Devices.
Functionality: When the train is detected as approaching the railroad crossing, the train
should slow down and the lights on the crossing gate flash alternately. After a delay the gate
should close. The delay should be long enough for cars to reasonably stop and occur before the
train arrives. It’s important to note that although the size of the prototype has been scaled,
time is not scaled. So timing should be realistic for real world situations. When the train is
detected departing after passing the railroad crossing, the train should speed up to normal train
speeds, the gate should go up, and the lights on the gate turn off.
Your Task: You will need to create an outline (1 page maximum) of code intended to solve the
above problem. This outline is an individual assignment and will be due at the beginning of the
first Problem Solving Project Lab. Your team will then combine ideas from each of the
individual outlines to come up with the initial design for the software.
Additional Information: Infinite loops are used with continuous data monitoring. For example,
the program that is running in a cell phone involves an infinite loop. In practice, what this
means Is that the loop is running from the time the equipment is turned on until it is turned off
(or power is lost). With any monitoring program, you do not want to use the pause command
or any code that acts like a pause command. This is because during the time of a pause, the
program is not running and any important signal that occurs will be missed. So you might get a
program that works with your given train setup, but will fail when the setup changes or the
performance of the equipment changes. So in your program you will need to find another way
to have actions performed after a specified time has passed. You have been introduced to the
tic and toc commands which allow a program to keep track of elapsed time.
Outline Example: The following example is for a program to calculate the total price and
average price of ten items in a list (the program is written for a user who does not know Matlab
and therefore must enter prices one at a time).
•
•
•
•
•
•
Set the counter to 1
While counter is less than or equal to ten
• Have user input price
• Add price to the total
• Update counter
End of loop
Calculate average price as the total divided by the number of prices
Print total price
Print average price per item
Download