12
School of Electrical, Computer and Telecommunications Engineering University of Wollongong Australia ECTE333 Lecture 12 – Revision 2018 2/55 ECTE333 Lam Phung ECTE333’s schedule Week Lecture (2h) Tutorial (1h) Lab (2h) 1 L7: C programming for the Atmel AVR 2 L8: Serial communication (8.1) Tutorial 7 Lab 7 3 Serial communication (8.2, 8.3) Tutorial 8 4 L9: Interrupts and Timers Lab 8 5 No lecture 6 Tutorial 9 Lab 9 7 L10: Pulse width modulator 8 Tutorial 10 Lab 10 9 L11: Analogue-to-digital converter 10 Tutorial 11 Lab 11 11 L12: Revision lecture 12 Lab 12 13 No lecture (L13: Self-study guide) Final exam (25%), Practical exam (19%), Labs (6%) 3/55 ECTE333 Lam Phung Lecture 12’s sequence 12.1 Review of key lecture contents 12.2 Practical Exam 12.3 Final Exam 4/55 ECTE333 Lam Phung ECTE333 Spring 2018 Learning activities L7: C programming L8: Serial communication L9: Interrupts and Timers L10: Pulse-width modulator L11: Analogue-to-digital converters Lab 7 Lab 9 Lab 8 Lab 10 Lab 11 Lab 12 (all) Tutorial 7 Tutorial 8 Tutorial 9 Tutorial 10 Tutorial 11 N13: Creating PCB (self-study guide)

ECTE333 - uow.edu.auphung/teach/ecte333/ECTE333-Lecture-12... · ADC. Lam Phung ECTE333 38/55 Practical exam: Advice Equipment for practice can be borrowed from: ... Exam appendix:

  • Upload
    lamkien

  • View
    271

  • Download
    2

Embed Size (px)

Citation preview

Page 1: ECTE333 - uow.edu.auphung/teach/ecte333/ECTE333-Lecture-12... · ADC. Lam Phung ECTE333 38/55 Practical exam: Advice Equipment for practice can be borrowed from: ... Exam appendix:

School of Electrical, Computer and Telecommunications EngineeringUniversity of Wollongong

Australia

ECTE333Lecture 12 – Revision

2018

2/55ECTE333Lam Phung

ECTE333’s scheduleWeek Lecture (2h) Tutorial (1h) Lab (2h)

1 L7: C programming for the Atmel AVR

2 L8: Serial communication (8.1) Tutorial 7 Lab 7

3 Serial communication (8.2, 8.3) Tutorial 8

4 L9: Interrupts and Timers Lab 8

5 No lecture

6 Tutorial 9 Lab 9

7 L10: Pulse width modulator

8 Tutorial 10 Lab 10

9 L11: Analogue-to-digital converter

10 Tutorial 11 Lab 11

11 L12: Revision lecture

12 Lab 12

13 No lecture (L13: Self-study guide)

Final exam (25%), Practical exam (19%), Labs (6%)

3/55ECTE333Lam Phung

Lecture 12’s sequence

12.1 Review of key lecture contents

12.2 Practical Exam

12.3 Final Exam

4/55ECTE333Lam Phung

ECTE333 Spring 2018 ─ Learning activities

L7: C programming

L8: Serial communication

L9: Interrupts and Timers

L10: Pulse-width modulator

L11: Analogue-to-digital converters

Lab 7

Lab 9

Lab 8

Lab 10

Lab 11

Lab 12 (all)

Tutorial 7

Tutorial 8

Tutorial 9

Tutorial 10

Tutorial 11

N13: Creating PCB (self-study guide)

Page 2: ECTE333 - uow.edu.auphung/teach/ecte333/ECTE333-Lecture-12... · ADC. Lam Phung ECTE333 38/55 Practical exam: Advice Equipment for practice can be borrowed from: ... Exam appendix:

5/55ECTE333Lam Phung

Lecture 7: C programming for the ATMEL AVR

Overview of the major components in ATmega16

The C development environment for ATMEL AVRWinAVR and AVR Studio. Steps to use these tools.

Practice: Tutorial 7 and Lab 7.

Programming digital IO ports of ATmega 16 How to read and write to digital ports of ATmega16.

Review of C programming Program structure, data types, operators, flow-control, function.

6/55ECTE333Lam Phung

Lecture 7: Example 1

Turning on LED by pressing a switch (Lab 7.3).

7/55ECTE333Lam Phung

Lecture 7: Example 2

Using Digital IO ports for 4x3 keypad and 7-segment display (Lab 7.4)

8/55ECTE333Lam Phung

Lecture 8: Serial Communications

Basics of serial communications Differentiate asynchronous versus synchronous. Baud rate, start bit, stop bit, parity bit. The RS232 standard. The null-modem connection.

Practice: Tutorial 8 and Lab 8.

Using serial port in ATmega16 How to initialise serial port. How to send/receive a character (video demo). How to send/receive formatted strings with stdio.h. How to use serial IO interrupts.

Page 3: ECTE333 - uow.edu.auphung/teach/ecte333/ECTE333-Lecture-12... · ADC. Lam Phung ECTE333 38/55 Practical exam: Advice Equipment for practice can be borrowed from: ... Exam appendix:

9/55ECTE333Lam Phung

Lecture 8: Example 1

Bluetooth transmitter

ultrasound distance sensor

This device measures distance to the nearest obstacle, and transmits it via Bluetooth (serial communication).

10/55ECTE333Lam Phung

Lecture 8: Example 2

Sending a character via serial port (Lab 8 – Task 1)

11/55ECTE333Lam Phung

Lecture 8: Example 3

Receiving a character via serial port (Lab 8 – Task 2)

12/55ECTE333Lam Phung

Lecture 8: Example 4

Sending serial commands to pan-tilt camera

Page 4: ECTE333 - uow.edu.auphung/teach/ecte333/ECTE333-Lecture-12... · ADC. Lam Phung ECTE333 38/55 Practical exam: Advice Equipment for practice can be borrowed from: ... Exam appendix:

13/55ECTE333Lam Phung

Lecture 8: Example 5

3-D accelerometer Ultrasound distance sensor

GPS receiverZigBee TXATmega16

ZigBee interface to PC

A wireless sensor board, ECTE458 Thesis, Georges Alam, UOW.

14/55ECTE333Lam Phung

Lecture 9: Interrupts and TimersInterrupt programming in C

Aware of available interrupts in ATmega16.

Describe five parts in a C interrupt-driven program.

Write programs for external interrupt and serial interrupt.

Practice: Tutorial 9 and Lab 9.

Timers in ATmega16

Overview of Timer 1.

Using timer overflow interrupt to measure time, create a delay?

Using input capture interrupt to measure period, pulse width?

Using timer’s external clock pin to count events?

15/55ECTE333Lam Phung

Lecture 9: Example 1

Write a C interrupt-driven program to toggle port B whenever a switchon the STK500 board is pressed. The program should use an externalinterrupt.

Serial RXD interrupt16/55ECTE333Lam Phung

Lecture 9: Example 2

Write a C interrupt-driven program to toggle port B whenever a switchon the STK500 board is pressed. The program should use an externalinterrupt.

External interrupts

Page 5: ECTE333 - uow.edu.auphung/teach/ecte333/ECTE333-Lecture-12... · ADC. Lam Phung ECTE333 38/55 Practical exam: Advice Equipment for practice can be borrowed from: ... Exam appendix:

17/55ECTE333Lam Phung

Lecture 9: Example 3

Timer 1 Overflow Interrupt: Turn on/off LEDs every 4 seconds18/55ECTE333Lam Phung

Lecture 9: Example 4

Timer 1 Input Capture Interrupt: Measuring period of a rectangular signal

19/55ECTE333Lam Phung

Lecture 10: Pulse Width ModulatorGeneral introduction to output compareWhat is output compare for a typical microcontroller? For what tasks can output compare be used?

Practice: Tutorial 10 and Lab 10.

Output compare unit in ATmega16 Block diagram: relevant registers and output pins.What changes can be made to output compare pins?What are the differences between operation modes of Timer 1? Steps to use output compare to produce a custom waveform?

PWM signal Definitions related to PWM signal: period, frequency, duty cycle. How to create a PWM signal using output compare of ATmega16.

20/55ECTE333Lam Phung

Lecture 10: Example 1

Generating music with PWM

Page 6: ECTE333 - uow.edu.auphung/teach/ecte333/ECTE333-Lecture-12... · ADC. Lam Phung ECTE333 38/55 Practical exam: Advice Equipment for practice can be borrowed from: ... Exam appendix:

21/55ECTE333Lam Phung

Lecture 10: Example 2

Servo motor control using PWM signal22/55ECTE333Lam Phung

Lecture 10: Example 3

Bluetooth transmitterBluetooth transmitter

ATmega16ATmega16 Glove with 16 motors

Glove with 16 motors

This device is created by Phill Ogden (ECTE458) for assistive navigation.It receives commands from PC via Bluetooth, and controls vibrating motors.The PC analyses a 3-D scene using a Kinect camera.

23/55ECTE333Lam Phung

Lecture 10: Example 4

Motors in a through-wall radar imaging system (UOW CSIP Research)24/55ECTE333Lam Phung

Lecture 10: Example 4

A scene behind a wall Output image with 2 targets

Motors in a through-wall radar imaging system (UOW CSIP Research)

Page 7: ECTE333 - uow.edu.auphung/teach/ecte333/ECTE333-Lecture-12... · ADC. Lam Phung ECTE333 38/55 Practical exam: Advice Equipment for practice can be borrowed from: ... Exam appendix:

25/55ECTE333Lam Phung

Lecture 11: Analogue-to-Digital ConverterBasics about ADC Differentiate sampling/quantization, sampling theorem, minimum

sampling rate for a signal. Define reference voltage, step size, quantization error, sampling

time, conversion time, flash and successive-approximation ADC. Relation b/t digital output and analogue input of ADC (T11.5).

Practice: Tutorial 11 and Lab 11.

Using ADC unit in ATmega16 Relevant registers and input pins, How to configure ADC unit? How to start an ADC conversion? How to extract ADC digital output? How to use ADC interrupt? How to trigger ADC at regular intervals?

26/55ECTE333Lam Phung

Lecture 11: Example 1

Joystick and pan-tilt camera

27/55ECTE333Lam Phung

Lecture 11: Example 2

Using ADC to measure the lighting level (Lab 11.2)29/55ECTE333Lam Phung

Lecture 12’s sequence

12.1 Review of key lecture contents

12.2 Practical Exam

12.3 Final Exam

Page 8: ECTE333 - uow.edu.auphung/teach/ecte333/ECTE333-Lecture-12... · ADC. Lam Phung ECTE333 38/55 Practical exam: Advice Equipment for practice can be borrowed from: ... Exam appendix:

30/55ECTE333Lam Phung

12.2 Practical exam

Worth: 19% of the annual subject.

Duration: 60 minutes.

Date: Check SOLS (tentatively Tuesday, 06/11/2018).

You will be required to complete an experimental task that involves setting up the circuit/equipment, writing a C program, testing the program.

Impromptu coding/designing is sometimes used in technical recruitment.

31/55ECTE333Lam Phung

Practical exam

Allocated time slot:

You must attend the allocated time slot (Check SOLS).

ECTE333 Practical A: 09:30am - 10:30am.

ECTE333 Practical B: 11:30pm - 12:30pm.

ECTE333 Practical C: 13:30pm - 14:30pm.

ECTE333 Practical D: 15:30pm - 16:30pm.

32/55ECTE333Lam Phung

Practical exam: Format

33/55ECTE333Lam Phung

Practical exam: Instructions

Create your project files and C programs in folder ‘C:\VMShare’.

All files in this folder will be automatically collected at the end of the

exam for marking.

Name the Atmel Studio solution and C program using your student ID.

For example, for student number 01234567,

the main solution file is: 01234567.atsln,

the C program is: 01234567.c.

Page 9: ECTE333 - uow.edu.auphung/teach/ecte333/ECTE333-Lecture-12... · ADC. Lam Phung ECTE333 38/55 Practical exam: Advice Equipment for practice can be borrowed from: ... Exam appendix:

34/55ECTE333Lam Phung

Practical exam: Marking

The practical exam will be marked out of 19, based on two criteria:

The C program works as required.

The C program is well documented (formatted and commented).

At the top of the program, add three C comments:

Comment 1: Explain circuit setup.

Comment 2: Summarise your test result.

Comment 3: If your program does not work, explain yourdebugging steps and possible sources of errors.

35/55ECTE333Lam Phung

Practical exam: Permitted resources

Calculator, pen.

Spring Lab logbook – will be collected at the end of practical exam.

Online references, usually found at http://www.elec.uow.edu.au/avr/,

are available in folder ‘C:\ECTE333_Spring’.

This folder also includes:

lecture notes,

example code from lectures,

read_keypad.c

36/55ECTE333Lam Phung

Practical exam: Permitted resources

http://www.elec.uow.edu.au/avr

37/55ECTE333Lam Phung

Practical exam: Advice

To prepare well for the practical exam: Revise labs 7, 8, 9, 10, 11, and 12. Study example programs given in the lectures and tutorials. Attempt practice problems.

The practical exam will cover: Digital IO (keypad, 7-segment display, switches, LEDs), Serial port, Interrupts, Timer 1 overflow, input capture, Timer 1 output compare, PWM, ADC.

Page 10: ECTE333 - uow.edu.auphung/teach/ecte333/ECTE333-Lecture-12... · ADC. Lam Phung ECTE333 38/55 Practical exam: Advice Equipment for practice can be borrowed from: ... Exam appendix:

38/55ECTE333Lam Phung

Practical exam: Advice

Equipment for practice can be borrowed from: SECTE Store Officer (Brian), between 9:30am-2:30pm (Week 12).

To write code correctly and rapidly (within 1-hour limit). Start with a working program (from labs or lectures) that is most

relevant to the test task. Modify the code as necessary. Enter, compile, edit, and debug your code

part by part (a few lines at a time).

39/55ECTE333Lam Phung

Consultation time for exams

2:30-4:30pm on Tuesday 30/10 or Wednesday 31/10/2018.

or send enquiries by e-mail,

or make appointment by e-mail.

46/55ECTE333Lam Phung

Lecture 12’s sequence

12.1 Review of key lecture contents

12.2 Practical Exam

12.3 Final Exam

47/55ECTE333Lam Phung

12.3 Final exam

Duration: 2 hours

Worth: 25% of the annual subject.

Number of questions: between 50 and 60.

Total marks: 50.

Contents: All lectures 7 to 11; all tutorials 7 to 11.

Exam appendix: Available in Moodle General Resources [PDF].

Date: Check SOLS (tentatively Saturday, 03/11/2018).

Page 11: ECTE333 - uow.edu.auphung/teach/ecte333/ECTE333-Lecture-12... · ADC. Lam Phung ECTE333 38/55 Practical exam: Advice Equipment for practice can be borrowed from: ... Exam appendix:

48/55ECTE333Lam Phung

Final exam

Type 1: Multiple-choice questions, each worth 1 mark. Calculation, theory, and C programming.Write answer on the Computer Marking Sheet.

Type 2: Each question consists of 2-3 smaller questions. Include calculation, theory, and C programming.Write answer on the Examination Booklet (blank booklet).

49/55ECTE333Lam Phung

Final exam

For theory & C programming questions: Understand the steps to use ATmega16 to perform a task.Write C code for a task. Revise the lecture notes. Study the examples and the summary of each lecture.

For calculation questions: Practice all tutorial questions, and pre-lab quizzes. Learn to determine register values. Attempt the example test papers (Test 1, Test 2, Test 3). The example test papers have a similar difficulty as the final exam.

51/55ECTE333Lam Phung

Final exam

Keep track of time in final exam: You will be required to be fast.

Show steps in your answer.

Start the answer to each 1B, 2B, 3B, … on a new page (short-answers).

Write answers neatly.

If a question is not clear to you, make the necessary assumption, and state it in your answer.

Use bulleted points.

Read the question carefully.

52/55ECTE333Lam Phung

Advice based on student experience

Don’t just write 8-bit register value. Show how each bit is determined.

Learn to use the Exam Appendix well.

Not so good:UCSRB = 0b00011000; // How quickly can you recheck?

00011000Register UCSRB RXCIE TXCIE UDRIE RXEN TXEN UCSZ2 RXB8 TXB8

Good:

(Table from Exam Appendix)

Page 12: ECTE333 - uow.edu.auphung/teach/ecte333/ECTE333-Lecture-12... · ADC. Lam Phung ECTE333 38/55 Practical exam: Advice Equipment for practice can be borrowed from: ... Exam appendix:

53/55ECTE333Lam Phung

Advice based on student experience

RX and TX pins of serial port must be explicitly enabled.

Differentiate sending and receiving a character via serial port.

Use a correct register name for digital IO: DDRx, PINx, PORTx.

Set baud rate correctly by writing to UBRRH and UBRRL.

Configure pins correctly for input or output.

54/55ECTE333Lam Phung

Advice based on student experience

Use prescaler if values are too large for 16-bit register ICR1, OCR1A.

The PWM mode must be correctly selected (use the table).

Clock source must be explicitly specified.

Select ADC channel by writing ADMUX correctly.

Determine TCCR1A, TCCR1B, ICR1 correctly.

Get the 10-bit digital output from ADCL/ADCH depending on alignment.

Write correct C code to check if an ADC operation is completed.

55/55ECTE333Lam Phung

Good luck for your revision and exam.Looking forward to seeing you in the fourth year.