Difference between revisions of "CSC270 Final Exam 2016"

From dftwiki3
Jump to: navigation, search
(Scheduling Lab Time)
(Expected Output)
 
(23 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
--[[User:Thiebaut|D. Thiebaut]] ([[User talk:Thiebaut|talk]]) 10:09, 16 April 2016 (EDT)
 
--[[User:Thiebaut|D. Thiebaut]] ([[User talk:Thiebaut|talk]]) 10:09, 16 April 2016 (EDT)
  
<onlydft>
 
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.
 
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 to Piazza.  The exam is given under the rules of the [http://www.smith.edu/sao/handbook/socialconduct/honorcode.php Smith College Honor Code].
 
Make an appointment with your instructor to demonstrate your design.
 
</onlydft>
 
  
 +
<br /><br /><br />
 +
<bluebox>
 +
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.
 +
<br />
 +
All work has to be done individually.
 +
<br />
 +
Any reference you use should be cited (this includes class material).
 +
<br />
 +
All problems are worth the same amount of points.
 +
<br />
 +
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. 
 +
<br />
 +
The exam is given under the rules of the [http://www.smith.edu/sao/handbook/socialconduct/honorcode.php 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.
 +
</bluebox>
 +
<br />
 +
<br />
 +
=Problem 0=
 +
<br />
 +
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.
 +
<br />
 +
=Problem 1=
 +
<br />
 +
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.
 +
<br />
 +
::<source lang="C" highlight="40,41">
 +
#include <stdio.h>
 +
#include <stdlib.h>
  
=Problem 1=
+
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;
 +
}
 +
 
 +
</source>
 +
<br />
 +
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:
 +
<br />
 +
::<source lang="C">
 +
  int*  table = table2;  // array                                                                                 
 +
  int  N    = N2;      // dimension of array                                                                     
 +
</source>
 +
<br />
 +
* (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. 
 +
<br />
 +
==Your Assignment==
 +
<br />
 +
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
 +
<br />
 +
::<source lang="text">
 +
List = (11, 9) (7, 35) (5, 15) (2, 20) (1, 10)
 +
</source>
 +
<br />
 +
Then after calling the function '''removePair()''', the list should display as:
 +
::<source lang="text">
 +
List =  (7, 35) (5, 15) (2, 20) (1, 10)
 +
</source>
 +
<br />
 +
'''RemovePair()''' will have removed (11, 9) from the list since 11 is larger than 9.
 +
<br />
 +
If several pairs exist that have the first item larger than the second one, then '''removePair()''' will remove all of them.
 +
<br />
 +
==Expected Output==
 +
<br />
 +
Your program should output the original linked list.
 +
<br />
 +
<br />
 +
Example:
 +
<br />
 +
:<source lang="text">
 +
 
 +
List = (11, 9) (7, 35) (5, 15) (2, 20) (1, 10)
 +
List = (7, 35) (5, 15) (2, 20) (1, 10)
 +
</source>
 +
<br />
 +
 
 +
==Submission==
 +
<br />
 +
* Submit a text file (not pdf, not RTF, not doc, or docx, just plain ASCII) to Moodle, in the Final Exam, Problem 1 section.
 +
<br />
 +
<!-- ============================================================== -->
 +
<!--
 +
=Problem 2=
 
<br />
 
<br />
Your assignment is to connect the Arduino to the 6811 kit, and have them communicate with each other.
+
Your assignment is to connect the Arduino to the 6811 kit, and have them communicate with each other.  You should devise a design, draw it, code it, implement it, debug it, and demonstrate it.
 
<br />
 
<br />
 
==Option 1==
 
==Option 1==
Line 48: Line 171:
 
::* Upgraded to A for a successful demonstration of your project.
 
::* Upgraded to A for a successful demonstration of your project.
 
<br />
 
<br />
 +
-->
 +
<!-- =========================================================== -->
 +
<br />
 +
=Problem 2=
 +
<br />
 +
==Your Assignment==
 +
<br />
 +
# 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.
 +
# Connect the output signal of the 6811  to an Arduino that has 3 signals connected to 3 different LEDs.
 +
# 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. 
 +
# 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.
 +
# 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. 
 +
<br />
 +
==Submission==
 +
<br />
 +
* 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.
 +
<br />
 +
<br />
 +
 
=Scheduling Lab Time=
 
=Scheduling Lab Time=
 
<br />
 
<br />
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 only 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.
+
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.
 
<br />
 
<br />
 
Use this Doodle page to reserve a 4-hour block.  Only 1 block at a time, please!
 
Use this Doodle page to reserve a 4-hour block.  Only 1 block at a time, please!
 +
<br />
 +
[http://doodle.com/poll/ptpy8sgdkuisp8pp http://doodle.com/poll/ptpy8sgdkuisp8pp]
 +
<br />
 +
  
</onlydft>
 
 
<br />
 
<br />
 
<br />
 
<br />

Latest revision as of 14:29, 28 April 2016

--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