17
ECE Department: University of Massachusetts, Amherst ECE 354 Lab 4: Remote Control of a Digital Camera

ECE Department: University of Massachusetts, Amherst ECE 354 Lab 4: Remote Control of a Digital Camera

Embed Size (px)

Citation preview

Page 1: ECE Department: University of Massachusetts, Amherst ECE 354 Lab 4: Remote Control of a Digital Camera

ECE Department: University of Massachusetts, Amherst

ECE 354

Lab 4: Remote Control of a Digital Camera

Page 2: ECE Department: University of Massachusetts, Amherst ECE 354 Lab 4: Remote Control of a Digital Camera

2ECE 354

Big Picture Introduction

Transmit and Receive Ethernet packets between two DE2 boards

Use the 5-layer Internet model you implemented in lab 3 to communicate picture data between two DE2 boards

Use serial protocol developed in lab 2 to acquire picture data and perform image processing

Use a preexisting SOPC system from the DE2_NET project.

Page 3: ECE Department: University of Massachusetts, Amherst ECE 354 Lab 4: Remote Control of a Digital Camera

3ECE 354

Skills to learn

Re-use previously written code Understand simple network handshaking Conform to a protocol specified by a third party Inter-group communication Implement a half-duplex Data-Link layer with

error control

Page 4: ECE Department: University of Massachusetts, Amherst ECE 354 Lab 4: Remote Control of a Digital Camera

4ECE 354

Additional Hardware

Two DE2 boards Ethernet cable Digital camera used in Lab 2 Extra VGA monitor

Page 5: ECE Department: University of Massachusetts, Amherst ECE 354 Lab 4: Remote Control of a Digital Camera

5ECE 354

Overview of Lab

Similar procedure to lab 3 Request a snapshot (640x480 1-bit grey-scale) to

be taken by a remotely located DE2 board Also have the option of having the remote device

do image processing before transmitting (as in lab 2 but now relayed over a network interface)

Page 6: ECE Department: University of Massachusetts, Amherst ECE 354 Lab 4: Remote Control of a Digital Camera

6ECE 354

Modes of Operation

Device will run in 1 of 2 modes: • Master

• Sends commands/requests to the slave, to take pictures or get pictures.

• Will use switches to select command codes. And a button will transmit command.

• Display images from the Slave on a VGA monitor.• Slave

• Process commands/requests from the master.• Be able to take pictures from the camera used in

lab2 You are required to support both modes of

operation in your code.

Page 7: ECE Department: University of Massachusetts, Amherst ECE 354 Lab 4: Remote Control of a Digital Camera

7ECE 354

Handshaking Protocol

Slave mode is required to support 8 commands. These can be specified by the 3 least-significant switches on the master device. The command is sent by pressing a key of your choice.

Commands include: take snapshot, get image, and various forms of image processing

You are only required to implement 2 forms of image processing. Ambitious groups can do more.

A slave, on receiving an unsupported command, must reply to the master with a NAK (no acknowledge)

Page 8: ECE Department: University of Massachusetts, Amherst ECE 354 Lab 4: Remote Control of a Digital Camera

8ECE 354

Commands / Requests (Layer 5)Bit#

Switch position

Command Name

7 6 5 4 3 2 1 0

xxx ACK 1 0 1 0 1 0 1 0

xxx NAK 1 1 1 1 1 1 1 1

000 Take snapshot

0 0 0 0 0 0 0 0

001 Get raw image

0 0 0 0 0 0 0 1

010 Image Processing 1

0 0 0 0 0 0 1 0

011 Image Processing 2

0 0 0 0 0 0 1 1

100 Image Processing 3

0 0 0 0 0 1 0 0

101 Image Processing 4

0 0 0 0 0 1 0 1

110 Image Processing 5

0 0 0 0 0 1 1 0

111 Image Processing 6

0 0 0 0 0 1 1 1

Page 9: ECE Department: University of Massachusetts, Amherst ECE 354 Lab 4: Remote Control of a Digital Camera

9ECE 354

Handshaking Protocol

The master and slave device will indicate an ACK or NAK by lighting all of the green or red LEDs respectively.

The commands specified on the previous slide will be the payload of a 64 byte UDP-packet. Please see lab 3 for packet format information.

Page 10: ECE Department: University of Massachusetts, Amherst ECE 354 Lab 4: Remote Control of a Digital Camera

10ECE 354

Example session of Handshaking Protocol

Master Slave

Time

Key:

1: Take snapshot

2: Get Data

3: Data

4: ACK

5: NAK or ACK

1

2

3

5

5

Page 11: ECE Department: University of Massachusetts, Amherst ECE 354 Lab 4: Remote Control of a Digital Camera

11ECE 354

Data-link Layer Error Control

You will implement layer 2 error-control by acknowledging individual packets

Transmission may take place over multiple packets; each individual packet must be acknowledged

Set the payload of an ACK frame to:0b11110000 (0xF0)

IMPORTANT: The ACK specified above is for layer 2 error control and has nothing to do with the handshaking protocol described earlier

Page 12: ECE Department: University of Massachusetts, Amherst ECE 354 Lab 4: Remote Control of a Digital Camera

12ECE 354

Handshaking - Detailed View

Master Slave

Time

Key:

1: Take snapshot

2: Get Data

3: Data

4: ACK

5: NAK or ACK

6: Layer2 ACK

1

2

3

6

4

5

6

6

6*

6

Page 13: ECE Department: University of Massachusetts, Amherst ECE 354 Lab 4: Remote Control of a Digital Camera

13ECE 354

Data-link Layer Error Control

After sending a packet, the master/slave will u_sleep for a fixed amount of time and then look for an ACK packet in their receive buffer.

If an ACK is not found, the frame recipient assumes data was corrupted.

This is similar to a busy-wait protocol with a fixed timeout.

Please calculate a suitable time-out value based on transmission size and link speed.

This process occurs within a receive or transmitfunction, and the handshaking protocol will never be aware of data-loss.

Page 14: ECE Department: University of Massachusetts, Amherst ECE 354 Lab 4: Remote Control of a Digital Camera

14ECE 354

Error Control

Master Slave

Time

Key:

1: Take snapshot

2: Get Data

3: Data

4: ACK

5: NAK or ACK

6: Layer2 ACK

1

6

1

Page 15: ECE Department: University of Massachusetts, Amherst ECE 354 Lab 4: Remote Control of a Digital Camera

15ECE 354

Gotchas

Image transmitted over network must follow a specific format to minimize network transmission time and avoid confusion

Format required is a 640x480 1-bit grey scale image, where each pixel is represented by 1-bit• One byte contains 8 pixels.• 640x480 Image is of size 38400 bytes. (76800 / 2)

Carefully adhere to the protocol defined by these slides 38400 bytes is too large for one packet. Sending an image

will require more then one packet. Make sure to read headers to get size of data when reading an image off the network.

Page 16: ECE Department: University of Massachusetts, Amherst ECE 354 Lab 4: Remote Control of a Digital Camera

16ECE 354

Image Display

The image sent to the master by the slave will be displayed on the VGA monitor attached to each device.

This is accomplished using the code from lab 2. REMEMBER: The image you send across the data

link must conform to the standard specified previously.

Page 17: ECE Department: University of Massachusetts, Amherst ECE 354 Lab 4: Remote Control of a Digital Camera

17ECE 354

Comments and/or Questions