CSC270 Final Exam 2016

From dftwiki3
Revision as of 13:29, 28 April 2016 by Thiebaut (talk | contribs) (Expected Output)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

--D. Thiebaut (talk) 10:09, 16 April 2016 (EDT)





This final exam is take-home. It is open-books, open-notes, and open-Web. It is due a week after it is made available to you.
All work has to be done individually.
Any reference you use should be cited (this includes class material).
All problems are worth the same amount of points.
You cannot discuss the details of this exam with anyone except your instructor. No question will be answered in person after you receive the exam. No debugging help will be available. If you have questions regarding the exam, you should post them confidentially on Piazza, visible to your instructor only. If the question is found not to reveal any information that could be used as solution, it will be shared with the class, along with the answer.
The exam is given under the rules of the Smith College Honor Code. You have until the last day of exams at 4:00 p.m. to submit your files to Moodle. Make an appointment with your instructor to demonstrate your design (or film your demonstration). The last possible date to submit and demonstrate your project is the official last day of exams, Friday 5/6/16, at 4:00 p.m.



Problem 0


What is the maximum frequency at which the Arduino can activate one of its digital output pins (not the PWM pins). Explain how you get your answer.

Problem 1


The program below implements a linked-list of pairs of ints. Study it, run it, play with it, and make sure you are comfortable with the code.

#include <stdio.h>
#include <stdlib.h>

int table1[] = { 1, 10, 2, 20, 5, 15, 7, 35, 11, 9 };
int N1       = 10;
int table2[] = { 10, 1, 20, 2, 50, 15, 35, 7, 11, 9, 22, 21 };
int N2       = 12;
int table3[] = { };
int N3       = 0;


typedef struct node {
  int  item1;
  int  item2;
  struct node *next;
} Node;

Node* addNode( int x, int y, Node* List ) {
  Node *p = (Node *) malloc( sizeof( Node ) );
  p->item1 = x;
  p->item2 = y;
  p->next = List;
  return p;
}

void display( Node* List ) {
  Node *p = List;
  printf( "List = " );
  while (  p!= NULL ) {
    printf( "(%d, %d) ", p->item1, p->item2 );
    p = p->next;
  }
  printf( "\n\n" );
}


int main() {
  Node *List = NULL;
  //--- define an array (equal to table1, or table2, or table3)---
  int*  table = table1;  // array
  int   N     = N1;      // dimension of array


  //--- create a linked-list of pairs of ints taken ---
  //--- from table.                                 ---
  for ( int i=0; i<N; i += 2 ) 
    List = addNode( table[i], table[i+1], List );
  
  //--- display the list ---
  display( List );

  return 0;
}


As you should have observed, the program creates a linked list and then displays it. The list list is composed of numbers originally found in an array of ints. The program can use 3 different arrays of ints, defined at table1, table2, and table3. In its implementation above, it uses table1. If you wanted to use table2 instead, you could change the highlighted lines as illustrated below:

  int*  table = table2;  // array                                                                                   
  int   N     = N2;      // dimension of array


  • (I will test your program with all 3 arrays.)
  • Compile and run the program for all 3 arrays, and verify that it correctly displays the list of pairs.


Your Assignment


Add a function called removePair() to the program. This function will remove all pairs/nodes from the linked list where the first element of the pair is larger than the second element of the pair. For example, if the list is initially displayed as

List = (11, 9) (7, 35) (5, 15) (2, 20) (1, 10)


Then after calling the function removePair(), the list should display as:

List =  (7, 35) (5, 15) (2, 20) (1, 10)


RemovePair() will have removed (11, 9) from the list since 11 is larger than 9.
If several pairs exist that have the first item larger than the second one, then removePair() will remove all of them.

Expected Output


Your program should output the original linked list.

Example:

List = (11, 9) (7, 35) (5, 15) (2, 20) (1, 10) 
List = (7, 35) (5, 15) (2, 20) (1, 10)


Submission


  • Submit a text file (not pdf, not RTF, not doc, or docx, just plain ASCII) to Moodle, in the Final Exam, Problem 1 section.



Problem 2


Your Assignment


  1. Program the 6811 to generate an output signal that can be made to oscillate at 3 different frequencies. To switch frequency, you will simply stop the 6811, enter a different program (or constants) in memory, and restart it. You are free to pick the 3 different frequencies that best fit your design.
  2. Connect the output signal of the 6811 to an Arduino that has 3 signals connected to 3 different LEDs.
  3. Program the Arduino to recognize the different frequencies. When the Arduino recognizes the slowest of the 3 frequencies, it activates one LED. When it recognizes the fastest frequency, it activates another LED. Finally, it activates the last of the 3 LEDs when it recognizes the medium-range frequency.
  4. All LEDs should be off when the 6811 is not activating its output signal. For example, assume that you have picked 1Hz, 10Hz and 100Hz as your 3 frequencies. Your Arduino is connected to 3 LEDs, one green, one yellow, and one red. When the 6811 is not running your program, all LEDs are OFF. When the 6811 generates a 1Hz output, the Arduino will activate the green LED, which will stay ON as long as the 1 Hz signal is active. When you stop the 6811 program, the green LED will automatically turn OFF. All LEDs will be OFF. When you program the 6811 to generate a 10Hz signal, the Arduino will measure this signal and activate the yellow LED, which will stay ON as long as the 10Hz signal is active. And similarly for the 100Hz and red LED.
  5. Demonstrate the correct behavior of your setup to your instructor for credit. If your instructor is not around, take a detailed movie of your experiment, with explanations of what happens.


Submission


  • Write up a lab report of your setup, including the diagrams of your hardware setup, and the code (assembly and C).
  • Submit the lab report to Moodle, in the Final Exam Problem 2 section.



Scheduling Lab Time


There are only 7 6811 Kits available, so you will need to schedule 4-hour blocks ahead of time. You are not allowed to reserve two consecutive 4-hour blocks, unless there are fewer than 7 students left working on their exam. If you haven't finished your design at the end of a 4-hour block, you must remove all the wires and chips and put the kit back in the cabinet. You'll have to rewire your kit when you start a new 4-hour block.
Use this Doodle page to reserve a 4-hour block. Only 1 block at a time, please!
http://doodle.com/poll/ptpy8sgdkuisp8pp