Modeling, Design and Implementation Project
Cyclometer

Introduction

Your team is responsible for modeling, designing and implementing a cyclometer, also called a bicycle computer. Pictured below is a typical cyclometer. For this project, you will design and implement a cyclometer with the features listed below.

Cyclometer Features

The cyclometer uses a magnetic sensor on one of the bicycle's wheels to generate a pulse once per wheel revolution. These pulses are counted to compute the current speed of the bicycle and several trip values that can be reset to 0 at the start of each trip. This cyclometer computes the following values:

The cyclometer uses either kilometers or miles to compute speeds and distances. The cyclometer has automatic and manual starting modes. In manual mode, the user manually turns the calculation of trip values on and off. In automatic mode, the cyclometer computes trip values when the bicycle is moving, i.e. the wheel is rotating.

The cyclometer displays numeric output of various quantities on a 4 digit 7-segment display. Three LEDs indicate wheel rotation, Auto start/stop mode, and the measurement units in use. The cyclometer has pushbutton inputs for: Mode, Start/Stop, and Set.

Cyclometer Requirements and Functional Specifications

The following is a list of requirements statements and functional specifications for the cyclometer that you will implement. When a distinction is made between the two, and there are arguments for the benefits of that, the requirements statements state what the system is required to do, but do not give any indication of implementation details, particularly interface details. Timing details may be given in the requirements, if those timing specifications must be met for correct operation. The functional specification starts describing implementation details particularly for the user interface, and describing operating scenarios. In the section below, for the most part, the top two levels (1., 2.B, etc.) are requirements statements, and the third and fourth levels are functional specifications.

  1. The cyclometer shall allow the user to fully reset the system.
    1. The cyclometer shall do a full reset when initially started, i.e. the cyclometer is powered on. Note: the cyclometer has no on/off feature.
    2. The cyclometer shall do a full reset when all three pushbuttons are simultaneously depressed for at least 2 seconds.
      1. The cyclometer shall respond to a full reset request in all operating modes including configuration after reset.
    3. The cyclometer shall initialize its stored data and operations.
      1. The cyclometer shall enter Manual mode with trip calculations turned off.
      2. The cyclometer shall reset the trip values to 0.
    4. The cyclometer shall allow the user to select miles or kilometers.
      1. The display shall initially show a 1 (three blanks displays and 1 in the rightmost display) to indicate kilometers.
      2. Pressing Mode once shall display a 2 to indicate miles.
      3. Repeated pressing of the Mode button shall toggle between kilometers and miles.
      4. The measurement unit is set by pressing the Set button.
    5. The cyclometer shall allow the user to set the tire circumference.
      1. The display shall initially show 210 (leftmost display blank) which represents the tire circumference in centimeters. Tire circumference is always entered in centimeters.
      2. Pressing Mode increases the circumference by 1 cm up to a maximum of 220 cm.
      3. Pressing Mode when the maximum circumference is displayed shall display the minimum circumference of 190 cm.
      4. If Mode is held down continuously for 2 seconds, the circumference shall increase at a rate of 1cm/sec. The circumference shall wrap to the minimum circumference if the user continues to depress Mode when the maximum circumference is reached. The circumference shall stop changing and remain at the circumference currently displayed when the user releases the Mode button.
      5. The tire circumference shall be stored by pressing the Set button.
    6. The cyclometer shall perform the full reset operations in the order: 1.C, 1.D, 1.E.
    7. After setting of the tire circumference, the cyclometer shall display current speed and average speed as specified in 3.C.i, and begin performing current speed calculation and display.
  2. The cyclometer shall calculate the current speed, and the trip values-average speed, distance, and elapsed time.
    1. The cyclometer shall allow the user to modify the tire circumference after cyclometer initialization.
      1. The cyclometer shall allow setting of the wheel circumference when the user presses the Set button while the display shows the distance.
      2. After pressing the Set button, the display shall initially show the current wheel circumference.
      3. Adjustment of the wheel circumference shall be as described in 1.E.
      4. The cyclometer shall store the new wheel circumference when the user presses the Set button. The display shall show the distance after setting the wheel circumference.
      5. The cyclometer shall continue performing trip calculations while the user adjusts the wheel circumference. The cyclometer shall use the previously set circumference until a new circumference is stored. Previous distance and average speed calculations shall remain as computed when a new wheel circumference is entered. Calculations shall begin using the new wheel circumference after it is set and accumulate on the values computed using the old wheel circumference.
      6. The cyclometer shall continue displaying wheel rotations while setting a new wheel circumference.
    2. The cyclometer shall allow the user to manually and automatically start and stop the calculations.
      1. The cyclometer shall toggle between Manual and Auto mode each time the user presses the Set button while the display shows elapsed time or speed.
      2. In Manual mode, the Start/Stop button controls when trip calculations are performed. Pressing the Start/Stop button toggles calculation on and off.
      3. In Auto mode, the cyclometer shall perform trip calculations only when it detects wheel rotation. In Manual mode, the cyclometer shall perform trip calculations when trip calculations are turned on.
      4. In Auto mode, the cyclometer shall light the Auto LED steady on when trip calculations are not being performed. In Manual mode, the cyclometer shall turn the Auto LED off when trip calculations are turned off.
      5. The cyclometer shall blink the Auto LED when performing trip calculations in either Auto or Manual mode. The Auto LED shall blink with a 1Hz rate (0.5 second on, 0.5 second off).
      6. The cyclometer shall compute the bicycle's current speed even when trip calculations are stopped.
  3. The cyclometer shall display all numeric values: current speed, average speed, distance, and elapsed time.
    1. The cyclometer shall use a 4 digit 7-segment display to show numeric values.
    2. The cyclometer shall update the display so that the current numbers are presented as bright, non-flashing, readable digits.
    3. The cyclometer shall allow the user to see all numeric values.
      1. The cyclometer shall display current speed and average speed together, with the current speed in the left two digits of the 4 digit display and average speed in the right two digits. The cyclometer shall display speeds that are greater than or equal to 10 measurement units per hour to the nearest integer measurement unit per hour. The cyclometer shall display speeds that are less than 10 measurement units per hour to the nearest tenth of a mesurement unit per hour with a decimal point between the units and tenths displays.
      2. The cyclometer shall display distance to the nearest tenth of a measurement unit using all four displays with a decimal point separating the tenths and units digits. Distance shall display with leading zeros suppressed except that a 0 shall be displayed when the distance is less than one measurement unit. The tenths digit shall always be displayed when displaying distance.
      3. The cyclometer shall display elapsed time in minutes and seconds with both always displayed as two digits with leading zeroes shown. A decimal point separates the minutes and seconds display.
      4. Pressing Mode shall cause the next value to display.
        1. The cyclometer shall cycle between displays in the order: current speed/average speed, distance, elapsed time.
        2. When the last value is displayed, pressing Mode shall cause the first value to display.
      5. The cyclometer shall display the last value available for all numeric values. The cyclometer shall update the display if a numeric value is updated while it is currently a displayed value.
    4. The cyclometer shall allow the user to reset the trip values.
      1. The cyclometer shall reset the trip values to 0 when the Mode and Start/stop buttons are simultaneously depressed for at least 2 seconds.
      2. The cyclometer shall respond to a trip values reset request when it is in an operating displaying normal numeric values. The cyclometer shall ignore the request during reset configuration and setting of tire size from the distance display.
  4. The cyclometer shall display wheel activity.
    1. The cyclometer blinks the wheel LED to indicate that the wheel is rotating. The cyclometer shall blink the wheel LED at a 1 Hz rate (on 0.5 seconds, off 0.5 seconds) whenever wheel rotation is detected.
    2. The cyclometer shall turn the wheel LED off when the wheel is stopped.
  5. The cyclometer shall indicate the measurement unit by turning the units LED on steady for miles, and off for kilometers.
  6. The cyclometer shall detect user depression of the pushbuttons.
    1. The cyclometer shall perform operations on button depression, with a suitable delay for debouncing or other delay as specified in these requirements.
    2. The cyclometer shall recognize the simultaneous depression of multiple buttons if the multiple buttons are depressed within a 200 msec time window started when the cyclometer detects the first button depression. If this timing window requirement is met, the cyclometer shall give preference to operations initiated by multiple button depressions over a single button depression.

Non-functional Requirements

  1. You will implement the system in C++ under QNX running on the purplebox target systems.
  2. The implementation will be multi-threaded.
  3. You will create a statechart to define the behavior of the cyclometer. This statechart will drive your implementation using one of the three state patterns detailed in the textbook's Mechanistic Design chapter. The design documentation will describe the state pattern used.
  4. The system will use an event mechanism. The design documentation will describe the event mechanism used.
  5. You will use the pushbuttons, 7-segment LED display, and individual LEDs on an FPGA board as your user interface. The FPGA hardware interface is defined here. Use the following functional assignment for the hardware: Led 0 - Auto LED, Led 1 - wheel LED, Led 2 - units LED, Button 0 - Set, Button 1 - Start/stop, Button 2 - Mode.
  6. You will use a function generator to create wheel rotation pulses.
  7. There is a spreadsheet to compute speeds from pulses and the other way around.

Demonstrations

All teams will demonstrate their implementation to the instructor on the day that the project is due during finals week.

Submission Instructions

The overall project has three submissions: 1) requirements analysis, 2) design, and 3) implementation artifacts and test plan. You have already submitted your requirements analysis.

The Design submission will be a single Word or PDF file that contains the following information:

  1. An overview of the software architecture for your cyclometer. Via discussion and diagrams, the overview should cover:
    1. Description of the design's software architecture above the individual class level
    2. Description of the tasks in your design with the inter-task relationships and approaches for synchronization
    3. Deployment view including connections of FPGA board and pulse generator to the system
  2. Description of how calculations are performed in your design. This description should include:
    1. Discussion of the calculation of current speed, average speed, and distance.
    2. Specification of the range of speeds your design can handle and the constraints this places on the design
    3. Discussion of the processing of wheel rotations signals.
    4. A sequence diagram triggered by wheel rotation pulses and ending with the calculations of current speed and average speed.
    5. A sequence diagram showing the stopping of calculations in Auto mode when the bicycle comes to a stop.
  3. Discussion of your design including the class-level design including identifying the object discovery strategies used to find each class in the system, and the statechart behavioral design.

Before the date specified for the Design submission in the course schedule, depost this design document into the myCourses dropbox for the project's Design submission. The grading rubric for this assignment is here.

The Implementation Artifacts and Test Plan submission will be a zip file containing:

  1. A Test Plan to determine if your implementation is correct. Design a reasonable test plan with test sequences that adequately cover the items below without requiring testing of all combinations. The testing must include travel scenarios with controlled changes in speed, and stops. The Test Plan should indicate expected results.
    1. Two different settings for wheel circumference
    2. At least three wheel speeds across the range that your design can handle
    3. Measurements in both metric and English units
    4. Correct processing of manual start/stop with correct calculation of average speed, elapsed time, and distance.
    5. Correct processing of auto start/stop with correct calculation of average speed, elapsed time, and distance.
  2. Results of testing your implementation against your test plan.
  3. As part of the Test Plan document, include a section that describes either: 1) changes in the design that you made during the last phases, i.e. since the design submission of the project, along with the reasons you made those changes, 2) changes you would make in the design if you did the project over along with why you think this would make a better design.
  4. A directory named code that holds your project's source code tree.

Before the date specified for the final submission, deposit this zip file into the myCourses dropbox for the project's Implementation Artifacts submission. The grading rubric for this assignment is here.

Advice from the Trenches


$Id: Cyclometer-implementation.html 179 2013-01-23 21:23:21Z jrv $