University of Western Australia Electrical Engineering Questions

User Generated

znqunggre_

Engineering

Description

Unformatted Attachment Preview

Digital and Embedded Systems Prof. Thomas Bräunl PAGE 1 Midterm 2 The University of Western Australia School of Electrical, Electronic and Computer Engineering MIDTERM 2, 2022 ELEC3020 / ENSC3020 Digital Embedded Systems FAMILY NAME: __________________________ STUDENT ID: This Paper contains: Time: GIVEN NAMES: ________________________ SIGNATURE: ________________________ 7 pages (including title page) 1 hour, 30 min. No calculators are allowed. If you choose to use a pencil, then no remarking will be possible. All questions are to be answered. Answers are to be inserted in the space provided. Question 1: 10 points Question 2: 10 points Question 3: 10 points TOTAL: 30 points Digital and Embedded Systems Prof. Thomas Bräunl PAGE 2 Midterm 2 QUESTION 1 External Device (2+1+7 = 10 points) A text-LCD is connected to an Arduino Nano and requires a serial bit-wise data transfer. The CPU must send each character as a sequence of 8 bits (least significant bit first) and at the same time generate a clock signal. The LCD copies each bit at the clock’s falling edge. • Each clock cycle should be 2ms (1ms up and 1ms down) • Assume that no further synchronization is required. • Use port D, bit-0 (D0), for data output • Use port B, bit-0 (B0), for clock output. • Assume both ports are already initialized. • Use function usleep(1000) for sleeping 1ms. (a) Connect the sensor to the Atmel controller in the figure below (left) (b) In the diagram below, what is the sensor value in HEX ? clock t data t 0x__________ Digital and Embedded Systems Prof. Thomas Bräunl PAGE 3 Midterm 2 (c) Complete the program code for writing a single character in C or Python int print_one_character(BYTE c) { // Assume ports B and D are already initialized } PORTB = 1; //set clock to high PORTB = 0; // set clock to low Digital and Embedded Systems Prof. Thomas Bräunl PAGE 4 Midterm 2 QUESTION 2 Image Processing Find a MOVING object in the left and right image half. (3+7 = 10 points) (a) For this given example, calculate the absolute difference image and the average motion value per pixel for the left and right image half. (Resolution is 4 lines by 6 columns) img_old 100 100 100 100 100 100 10 10 100 100 100 100 10 10 100 100 100 100 100 100 100 100 100 100 img_new 105 95 95 105 100 90 90 5 10 100 100 110 95 10 5 95 105 90 105 110 105 115 100 95 abs_diff image motion average per pixel ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ L = ______________ R = ______________ ___ ___ ___ ___ ___ ___ (b) Write subroutine motion in C or Python that checks for motion in the left and right image half, then performs a rotation accordingly. • Function motion gets old and new image as parameters • Camera resolution is 60 x 80 grayscale pixels (height * width) • Function motion should only do a single analysis (and motion), not a loop. • Threshold is an average grayscale change value of 10 per pixel. • If there is motion above threshold in the left area, rotate the robot 10 deg. to the left at speed 5: VWTurn(10,5); VWWait(); • If there is motion above threshold in the right area, rotate the robot 10 deg. to the right at speed 5: VWTurn(–10,5); VWWait(); • If there is motion above threshold in both areas, rotate towards the side with higher motion. • Otherwise, do not move the robot Digital and Embedded Systems Prof. Thomas Bräunl PAGE 5 Midterm 2 void motion(BYTE img_old[60*80], BYTE img_new[60*80]) { int L=0,R=0; // motion averages for left and right image halves if _______________________________ { VWTurn(10,5); VWWait(); } // rotate left if _______________________________ { VWTurn(–10,5); VWWait(); } } // rotate right Digital and Embedded Systems Prof. Thomas Bräunl QUESTION 3 PAGE 6 Midterm 2 Motors and Encoders (10 points) Implement a velocity and position controller. Your task is to write code to control a lift cabin. The attached graphs from the lecture notes should help you in implementing this problem. • • The cabin starts at rest with encoder counter at 0. You only need to consider the cabin moving up by one floor. • From the start, maintain a constant cabin speed of 1,000 encoder ticks per second using an on-off controller (bang-bang controller) in subroutine control in C or Python. When reaching the position 9,000 encoder ticks (t brake in diagram), start slowing down the cabin speed linearly until it comes to a full stop at 10,000 encoder ticks (tatop in diagram). • • • • Assume that function control is being called by a background timer 50 times per second. Use function ENCODERRead(1) to read the encoder value. Use function MOTORDrive(1, percentage) to set the motor output in range [0, 100] (the value ‘1’ refers to the number of the motor and encoder) a t s1 v t p p1 s0 p0 tbrake tstop t Digital and Embedded Systems Prof. Thomas Bräunl PAGE 7 Midterm 2 void control() // this function is being called 50 times per second { int enc, mot, v; static int old; // old encoder value enc = ENCODERRead(1); v // read encoder #1 = _______________________ // calc velocity if ( _______________________ ) // if in constant speed phase { } else { // in braking phase } if ( ______________________________ ) MOTORDrive(1, mot); // set output for motor #1 old = enc; // remember encoder value } mot = 0; // check for stop
Purchase answer to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Explanation & Answer

View attached explanation and answer. Let me know if you have any questions.

Question 2
Answer a

The average motion value per pixel for the left image half is 0.21 and for the right image half is 0.16. The
moving object is the white square in the center of the image. The top left corner of the object is at (2, 3)
in the left image half and at (1, 1) in the right image half. The bottom right corner of the object is at (5,
6) in the left image half and at (4, 5) in the right image half. The absolute difference between these
coordinates is 1.16 pixels. Therefo...


Anonymous
Really great stuff, couldn't ask for more.

Studypool
4.7
Indeed
4.5
Sitejabber
4.4

Similar Content

Related Tags