Fall 2000- Exam 1 - Name: Exam #2 <—-- RECORD YOUR...

Info iconThis preview shows pages 1–11. Sign up to view the full content.

View Full Document Right Arrow Icon
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 4
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 6
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 8
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 10
Background image of page 11
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Name: Exam #2 <—-- RECORD YOUR EXAM NUMBER! Section: Lab Time: Your TA: Test grades will be posted by exam number Embedded Control Laboratory First Exam - Fall 2000 Question # Point value SHOW ALL WORK! OPEN BOOKS / OPEN NOTES Embedded Control First Exam - Fall ‘00 SHOW ALL WORK page 1 of 11 Name: 1) (20 points) A). (8 points) Answer the questions below based on the following INTROL C segment. unsigned char a, b, c, d, e, f, i , j, k ,m; a = 0xC8; b = 0x53; c = 7; d = 0x01; e = 0x42; f = 0x22; + c; l6: & f; !(a & c); b a d I. H H i j k In After the code has been executed: i) What is the value of i in hexadecimal? ii) What is the value of j in decimal? iii) What is the logic value (TRUE or FALSE) of k? iv) What is the logic value (TRUE or FALSE) of m? B). (12 points) Answer the questions below based on the following INTROL C segment. unsignedchara=4,b=1,c=1,d=2,e=0; if ( a = 2 ) printf (“Embedded Control is fun!”); else printf(“I’d rather take IED”); for (c=0; c<d; c++) { if (b&c)d+=b; if (b&&c)e++; } After the code is executed: i) What would be printed to the terminal? ii) What is the value of c ? iii) What is the value of d ? iv) What is the value of e ? Embedded Control First Exam - Fall ‘00 SHOW ALL WORK page 2 of 11 Name: 2) (16 points) Use the following schematic to complete this problem. r740?‘ LI O H U Q 1: c: 5 m > II H = 12 (PCS) U a 11 (PC2) Slide \5 Switch Answer the following questions based on the schematic shown above. a). (4 points) The program, currently running, executes the command _H11PORTB = 0x59. Which LED (if any) will have the least current passing through it? i) LEDl ii) LED2 iii) LED3 iv) LED4 v) They will all have the same current passing through them b). (2 points) If LED3 is lit, what value will the logic probe indicate when placed at pin 6 of the inverter chip? i) High ii) Low iii) Float Embedded Control First Exam — Fall ‘00 SHOW ALL WORK page 3 of 11 Name: 2) (continued) 0). (3 points) Assume a logic probe is placed at PC3, what will the logic probe read before and while the button connected to PC3 is pressed? i) High (before), Low (while) ii) Low (before), High (while) iii) Low (before), Low (while) iv) High (before), High (while) v) Float (before), High (while) vi) Float (before), Low (while) (1). (3 points) Assume a logic probe is placed at PCO, what will the logic probe read while the slide switch is in the “on” and “off” positions? i) High (on), Low (off) ii) Low (on), High (off) iii) Low (on), Low (off) iv) High (on), High (off) v) Float (on), High (off) vi) Float (on), Low (off) e). (4 points) Which of the following commands will correctly configure Port C for input and output (for the schematic shown above)? i) _H11DDRC = _HllPORTC & OXOD; ii) _H11DDRC = _HllPORTC & 0x02; iii) _H11DDRC=0x02; iv) _H11DDRC=0xOD; v) _H11DDRC=0xFF; vi) _H11DDRC=Ox00; vii) None of the above Embedded Control First Exam - Fall ‘00 SHOW ALL WORK page 4 of 11 Name: 3) (28 points) Use the following schematic to answer the questions below about A/D conversion. 44 (PE4) '— 7A’Et-Inve_rter_l 40 (P32) 39 (P83) 3' 46 (PE5) l 10m l Potentiometer I 10m _, (Voltage Ref. High) I Potentiometer J (Voltage Ref. Low) 68HC1 1 EVB Connector You have recently been introduced to the idea of Analog—to-Digital conversion, and have started using it in your projects. The above schematic displays a small circuit you have built to test the Analog—to-Digital converter within the 68HC11 microcontroller. Given the following conditions, fill in the missing information on the table provided below. Assume that all circuitry is correct and both power and ground have been supplied to all necessary components. * A11 voltage answers should be given to two decimal points. * All answers should include units. * Assume each A/D result to be taken after a multiple conversion on pins PE4-PE7, give results as integers. Value VRH written to Voltage (Voltage _H11PORTB at pin 44 ' Ref. High) e) For line a) above, what value of R1 would result in the given voltage at pin 44? R1 = f) For line d) above, what value of R2 would result in the given voltage at pin 46? R2: Embedded Control First Exam - Fall ‘00 SHOW ALL WORK page 5 of 11 Name: 3) (continued) g) (2 points) What value should be written to _H11ADCTL to read PE4 & PES continuously? _H11ADCTL = _; h) (2 points) What value should be written to _H11ADCTL to read only PE5 non-continuously? _H11ADCTL = ; i) (2 points) What value should be written to _H11ADCTL to read only PE4 continuously? _H11ADCTL = ._; Embedded Control First Exam - Fall ‘00 SHOW ALL WORK page 6 of 11 Name: 4) (36 points) Your team has been requested to build an Embedded Control Reflex Tester. This device will test the speed at which you can respond to a random request. To operate it, the user will start by pressing and holding down a pushbutton when a red LED is lit. Then after a random amount of time, the red LED will turn off and the green LED will light. The user will then quickly release the pushbutton and press the second pushbutton. The device will then display on the monitor the amount of time it took for the user to respond. It will repeat this test a total of ten times. Your team has already built the hardware using the schematic shown below. Your assignment is to complete the code to operate the Reflex Tester. tau" 1 Inverter | Red LED +5V 22 PDZ 1 > . 2 ‘ 270 S2 23 (PD3) 3 ’ . 4 ‘ 270 9 Green LED l Potentiometer 1k§2 24 (PD4) 68HC11 EVB Connector .1 EJ Pushbutton 1 IkQ 25 (PD5) j E Pushbutton 2 Lin The program for the tester should perform as follows: 0 Light the red LED and wait for the user to press and hold Pushbutton 1. 0 Delay for a random amount of time that is a function of a random number and the potentiometer setting. The red LED will then be turned off and the green LED turned on. 0 Wait for the user to release Pushbutton 1 and wait for the user to press Pushbutton 2. 0 Record the amount of time that it took between lighting the green LED and the user pressing Pushbutton 2. The difference between these two times will be the user’s reflex score. - The user's reflexes should be tested 10 times after which a completion message is printed. 0 If the user releases Pushbutton 1 before the green LED is lit, an error message is printed. Note that some functions, and part of the main() program are provided for you. Also, note that the logical status of pins not shown on the schematic are unknown (could be high or low). Embedded Control First Exam — Fall ‘00 SHOW ALL WORK page 7 of 11 Name: 4) (continued)Read each of the function descriptions carefully before writing your code. You will be required to write the functions which are in italic font. Note that two global variables, green_light_time and press_button2_time, are given for the recorded times. Note that you do not need to write the function get_time( ) or reset_time_counter( ). You should include comments that are relevant. You will lose points for: 0 Code that is not entirely complete 0 Any extraneous, irrelevant, or erroneous code 0 Code that fails to operate as requested - Incorrect Syntax - Extremely inefficient code 0 Lack of appropriate comments - Severely improper indentation Code Comments/Pseudocode #include <EVB.h> #include <stdio.h> #include <stdlib.h> unsigned char rcad_AD_input(void); int check_pushbutton_l(void); int check_pushbutton_2(void)i /* perform A/D conversion & return result */ /* checks if pushbutton l is pressed */ /* checks if pushbutton 2 is pressed and may assign a value to global variable press_button2_time */ /* calculates a random delay and checks to see if pushbutton 1 remains pressed during delay */ /* return random value between 0 and 32767 */ int wait_a_whilc(int AD_resu1t)I float random(void); void reset_time_counter(void); long int get_time(void); /* Initializes the time—counter to 0 */ /* returns the time from the counter in milliseconds */ /* global variables */ int green_1ight_time=0; int press_button2_time=0; void main(void) /* fill in this code on the next page */ Embedded Control First Exam - Fall ‘00 SHOW ALL WORK page 8 of 11 Name: 4a)(16 points) Complete the main() program by filling in the blanks - make sure to refer to the comments. Code Comments/Pseudocode void main(void) ( int i; unsigned char PE3_result; int reflex_time; /* Set data direction for Port D */ for (i=0;i<10;i++) { PE3_result = read_AD_input(); /* Get A/D value as set by potentiometer */ /* Light Red LED */ /* Wait until pushbutton 1 is pressed */ reset_time_counter(); /* Initialize time counter to O */ if(wait_a_while(PE3_result)) { /* Wait a random amount of time */ /* Light Green LED */ green_1ight_time = get_time(); /* Wait until pushbutton 1 is NOT pressed */ /* Wait until pushbutton 2 is pressed */ reflex_time = : /* Calculate time elapsed between lighting green LED and pressing button 2 */ /* Turn off both LEDs */ I printf(“Your reflex time was %d milliseconds\n", reflex_time); ) } printf(“Test completed”); Embedded Control First Exam — Fall ‘00 SHOW ALL WORK page 9 of 11 Name: 4b)(4 points) Write the function read_AD_input - this function should perform an A/D conversion on the voltage on pin PE3, and return the result. Code Comments/Pseudocode uns igned char read_AD_input (void) ( } 4c)(6 points) Write the function check _pushbutt0n_ - this function should check pushbutton 2, and return a “1” if it is pressed, and “0” if it is not. It should also call the get_time function to store the time at which button 2 is pressed in global variable press_button2_time. Code Comments/Pseudocode int check_pushbutton_2 (void) ( Embedded Control First Exam - Fall ‘00 SHOW ALL WORK page 10 of 11 Name: 4d)(10 points) Write the function wait_a_while - this function should cause a delay to occur. The delay should be a function of the A/D value returned by the read_AD_input function, and a random value (note that the random function is already written for you). In general, a higher A/D reading should cause the delay to be longer, and a smaller A/D reading should cause the delay to be shorter, but there should also be a random element to the delay, so that the exact length of the delay is unpredictable. This function should also check to make sure that Pushbutton 1 is held down during the entire delay. If the button is released before the end of the delay, an error message should be displayed, and a “0” should be returned. If the delay completes without error, the function should return a ‘61,,- Comments/Pseudocode int wai t:_a_whi 16 (int AD_resul t) { Embedded Control First Exam - Fall ‘00 SHOW ALL WORK page 11 of 11 ...
View Full Document

This note was uploaded on 09/01/2008 for the course ENGR 2350 taught by Professor Fukanari during the Spring '08 term at Rensselaer Polytechnic Institute.

Page1 / 11

Fall 2000- Exam 1 - Name: Exam #2 <—-- RECORD YOUR...

This preview shows document pages 1 - 11. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online