Docsity

Final exam Solution Set - 2008 | AME 3623, Exams of Aerospace Engineering

Partial preview of the text

Download Final exam Solution Set - 2008 | AME 3623 and more Exams Aerospace Engineering in PDF only on Docsity!

(2 pts) Name:

AME 3623: Embedded Real-Time Systems: Final Exam

Solution Set

May 5, 2008

Problem Topic Max Grade 0 Name 2 1 Interrupts and I/O 51 2 Finite State Machines 20 3 Sequential Logic 27 4 Analog Processing 25 5 Microprocessor Design 32 6 Device Control 25 7 Logic 20 Total 202

  1. Interrupts and I/O (51 pts)

(a) (15 pts) Below is an interrupt service routine that is supposed to produce a signal of a fixed frequency but a variable duty cycle on port C, pin 4 (counting from 0). However, there exist several bugs (errors). Make the necessary changes to this code to remove these bugs. The number of counts for which the output signal should be “1” is specified by the variable duration. You may assume that the I/O hardware has been initialized correctly.

volatile uint8_t counter; volatile uint8_t duration;

ISR(TIMER0_OVF_vect) {

++counter;

if(counter <= duration) {

PORTC &= ~4;

}else if(counter == 0){

PORTC ^= 4;

The repaired code is as follows:

ISR(TIMER0_OVF_vect) { ++counter;

if(counter >= duration) { // Reversed inequality PORTC &= ~0x10; // Bit 4 -> 16 }else if(counter == 0){ PORTC |= 0x10; // Bit 4 -> 16; Add OR } }

Key changes: use XOR instead of OR; bit 4 mask is 16 (or 0x10); counter ¿= duration.

Consider a circular buffer of size N = 8 memory elements (values shown below) and state variables f ront = 5 and nchars = 3.

index value 0 ’t’ 1 ’i’ 2 ’c’ 3 ’k’ 4 ’z’ 5 ’c’ 6 ’o’ 7 ’m’

(e) (8 pts) Assume that four more characters arrive on the serial port: ’p’, ’a’, ’s’, ’s’. Show the state of the buffer and the associated variables after these four characters have been added to the buffer.

index value 0 ’p’ 1 ’a’ 2 ’s’ 3 ’s’ 4 ’z’ 5 ’c’ 6 ’o’ 7 ’m’

f ront = 5 (still) nchars = 3 + 4 = 7

(f) (8 pts) Assume that four characters are read from the buffer. What are the characters (in order)? Also - show the state of the buffer and the associated variables after these four characters have been read from the buffer.

Characters: ’c’, ’o’, ’m’, ’p’

index value 0 ’p’ 1 ’a’ 2 ’s’ 3 ’s’ 4 ’z’ 5 ’c’ 6 ’o’ 7 ’m’

(there is no change to the buffer state)

f ront = 1 nchars = 3

(g) (5 pts) In asynchronous serial communication (the type of serial communication that we studied in class), how do the sender and receiver agree on when the first bit is being transmitted? (be brief)

The sender and receiver must synchronize their internal clocks before transmission of data begins. This is accomplished by the sender sending a start bit.

(b) (5 pts) What are the FSM actions?

  • Forward (F)
  • Left (L)
  • Right (R)
  • Grasp (G)
  • Stop (S)

(c) (10 pts) Draw the finite state machine diagram that will control the robot through this sequence. Note that your FSM should perform properly whether the ball is present or not.

BW/R

x/F

TC/F

BW/S

GC/F

BB/G

BW/L

done

S0 S1 S2 S

S5 S

TC/F

  1. Sequential Logic (27 pts)

Consider the following circuit:

A

CLK

B0 B

Q’

D Q

Q’

D Q

(a) (6 pts) Assume that the initial state is B1 = 1 and B0 = 1, and that A = 1. Fill in the following timing diagram:

B

B

CLK

(b) (5 pts) What mathematical operation does this circuit perform on the binary number B1, B0 when A = 1?

Bit-wise NOT

  1. Analog Processing (25 pts)

Consider the following circuit:

16R C

C

C

C

C

R

2R

4R

8R

V

Vin

  • B −

(a) (15 pts) Derive the expression for V in terms of binary digits C0 to C4. Note that when Ci = 0, the voltage on the line is 0 Volts and when Ci = 1, the voltage is + Volts.

Assume: current flows from left to right. The fundamental equations (given by Ohm’s law and Kirkoff ’s current law): 5 Ci − V = 24 −iRIi ∑ Ii = 0

Therefore:

5 Ci − V 24 −iR

= Ii ∑ (^5) Ci − V 24 −iR

∑ 2 i^ (5Ci − V ) = 0 5

∑ 2 iCi =

∑ 2 iV

V =

∑ 2 iCi ∑ 2 i

=

(C 0 + 2C 1 + 4C 2 + 8C 3 + 16C 4 )

Assume that the operational amplifier is configured such that if V > Vin, then B = 1; otherwise, B = 0.

(b) (10 pts) Given that Vin = 63/31 Volts, show each step in the successive approximation algorithm (in particular, show the C’s, V , and B).

C 4 C 3 C 2 C 1 C 0 V B

The values are shown below:

bar & 0x91; = 0x

baz = foo | 0x11; = 0x

  1. Device Control (25 pts)

Given the following H-bridge circuit: +5V

D (direction)

M (magnitude)

C

C

C

C

D is a directional input that is intended to specify the direction of motor torque. M is a Pulse Width Modulated signal that is intended to specify the magnitude of the torque signal (the higher the duty cycle, the higher the torque).

(a) (10 pts) For the given circuit, what is the truth table for C 0 , C 1 , C 2 , and C 3 as a function of D and M?

D M C 0 C 1 C 2 C 3

(b) (5 pts) Briefly describe what happens to the circuit when D = 1 and M = 1.

The top two transistors turn on. Consequently, no current flows through the motor (which is what we wanted with M = 1).

  1. Logic (20 pts)

Given the following truth table:

A B C f 0 0 0 1 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 1 1 1

(a) (5 pts) Give the “minterm” form of the corresponding algebraic expression.

f = A¯ B¯ C¯ + A B¯ C¯ + AB C¯ + ABC

(b) (10 pts) Derive a simplified algebraic description for f. Justify each step (provide the name of the rule that you are using).

A¯ B¯ C¯ + A B¯ C¯ + AB C¯ + ABC

( A¯ + A) B¯ C¯ + AB( C¯ + C) Distributive (1) B¯ C¯ + AB(1) X + X¯ = 1 B¯ C¯ + AB X ∗ 1 X

(c) (5 pts) Draw the corresponding circuit.

A

B

C

f