• 沒有找到結果。

[2014-Fall] WNFA lab1 -

N/A
N/A
Protected

Academic year: 2022

Share "[2014-Fall] WNFA lab1 -"

Copied!
18
0
0

加載中.... (立即查看全文)

全文

(1)

Camera Communication 2014/3/5

[2014-Fall] WNFA lab1 -

CamCom

(2)

Visible Light Communication

 Use visible light instead of electromagnetic wave for communications.

 Use cameras or light sensors as receivers.

 Low sampling rate : typically 30 fps

(3)

Rolling Shutter

1 1

Time Row 1

Row 2 Row 3 Row 4 1 1

1 1

1 1

1 1

2 2

2 2

2 2

2 2

3 3

3 3

3 3

3 3

(4)

 Frequency-shift on-off keying

 Each frequency represents a bit string.

width in pixels, w

Time

1 2 3 4 5 6 7 8

LED ON

LED OFF

1

Read Out Time of Row 1

Rolling Shutter

(5)

Another method – ufsook

 Only use 2 frequencies, 30*n and 30*(n - 0.5)

 What’s the frame difference ?

 30*n : 0, since same phase

 30*(n-0.5) : 255 * #pixels

4 3.5 4 3.5

http://w.csie.org/~r01922104/hw1.3gp

(6)

Our Tx, Rx hardware

Transmitter : Zigduino + LED

Receiver : Camera

Zigduino = Arduino + Zigbee 3 color

LED

(7)

Tx part : Zigduino + LEDs

http://www.csie.ntu.edu.tw/~hsinmu/courses/lib/exe/fetch.php?media=arduino_ins.pdf GND

pins reset

Notice : there must be resistors (電阻) in the circuit

(8)

First program – Blink.ino

// Pin 13 has an LED connected on most Arduino boards.

// give it a name:

int led = 13;

// the setup routine runs once when you press reset:

void setup() {

// initialize the digital pin as an output.

pinMode(led, OUTPUT);

}

// the loop routine runs over and over again forever:

void loop() {

digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second

digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second

} /* note: you can use analogWrite(led, value) instead */

(9)

Tx part

 message => bytes => behavior of LEDs

 You can use anything to represent bits:

 color, frequency, luminance, waveform, duplication, ……

 Don’t forget the low sampling rate of camera (30fps)

 Get extra score if people cannot notice the behavior of LEDs

 Range your score with data rate

human or Zigduino Zigduino

(10)

Clear Timer on Compare (timer == OCRnA)

Generate accurate square waves

all done by hardware, won’t affected by interrupt

Can simultaneously use all 3 timers easily.

Set the corresponding bits in TCCRnX(n=1,2,3 X=A,B) registers for mode selection and timer prescaler

Set OCRnX for “frequency”(OCRnA) or “delay”(OCRnB,OCRnC)

Frequency = 16M / prescaler / OCRnA / 2

Additional support : interrupt handler (see document)

CTC mode

(11)

CTC mode – sample code

void setup() {

// use Timer1, set control registers here pinMode(11, OUTPUT);

pinMode(10, OUTPUT);

pinMode(9, OUTPUT);

TCCR1A = _BV(COM1A0) | _BV(COM1B0) | _BV(COM1C0);

TCCR1B = _BV(WGM12) | _BV(CS12) | _BV(CS10);

OCR1A = 32767;

OCR1B = 16383;

OCR1C = 8191;

}

void loop(){

// change OCRnX values to manipulate frequency OCR1A = 32767, OCR1B = 16383, OCR1C = 8191;

delay(10000); // this may not be so accurate

OCR1A = 16383,OCR1B = 8191,OCR1C = 4095;

delay(10000);

}

(12)

CTC mode

 For more details

http://www.atmel.com/Images/doc8266.pdf (register definition)

https://static.squarespace.com/static/511f4f0de4b09463c7605f13/t/5275c478e4b 07e72f74c7442/1383449720133/zigduino-v6c-schematic.pdf

Timer name sizeof registers

Control value (fill TCCRnX)

Prescaler Output pin name

<-> pin in Zigduino

Timer1 16-bit WGM = 4

COM1A/B/C = 1 CS = 1/2/3/4/5

1 / 8 / 64/

256 / 1024

OC1A <-> pin11 OC1B <-> pin10 OC1C <-> pin9

(pin11 need a jumper)

Timer3 16-bit WGM = 4

COM3A/B/C = 1 CS = 1/2/3/4/5

1 / 8 / 64/

256 / 1024

OC3A <-> pin5 OC3B <-> pin6 OC3C <-> pin3

Timer2 8-bit WGM = 2

COM2A = 1 CS = 1~7

1/8/32/64 /128/256/

1024

OC2A <-> pin8

(13)

Fast PWM (with OCRnA top)

 Pulse-width modulation

 Can be used to control duty cycle

 http://arduino.cc/en/Tutorial/SecretsOfArduinoPWM ( pins are different )

 Differences in luminance and ratio of light/dark stripe width

pinMode(6, OUTPUT);

TCCR3A = _BV(COM3B1) | _BV(WGM31) | _BV(WGM30);

TCCR3B = _BV(WGM32) | _BV(WGM31) | _BV(CS32) | _BV(CS30); // TOP=0xFFFF OCR3A = 8191;

OCR3B = 2047; // 25% duty cycle

(14)

serial port monitor – text I/O

 see Examples 08. Strings

 Use the serial monitor to communicate

(15)

Rx part : video processing

 video ( -> image ) -> get LEDs behavior-> bytes -> message

 Video to image:

 ffmpeg –i input.avi ouput%d.jpg

 supported by windows, linux, and OS X

 Counting Stripes : need some DIP

 find LED position, image diff, color histogram, edge detection, Fourier transform, auto-correlation, ……

 3 basic ways : DIP, FFT, auto-correlation

(16)

Rx part : an example pseduo code

for all images {

read image;

find bounding box // where are the stripes calculate row power

count stripes to get freq // through DIP or FFT get output bit by freq

}

(17)

Demo – 3/27 (Thu.)

 Please register the demo slot. And come to CSIE R424 at that time.

https://docs.google.com/spreadsheet/ccc?key=0AgYjnPH1HzgydFA3VmJxcDVncEtQY jQySk9sRF9sa0E&usp=drive_web#gid=0

 All you should do are :

1. Transmit the character string given by TA 2. Record the videos

3. Decode and get the message

 grade :

Tx (20% + 10% for not noticed by human eyes + 10% data rate)

Rx : Video Decode (30% + 10% for accuracy)

Report : describe what you have done, and problems encountered (20%)

We will choose 2 groups to demo in the next class, and their grade will be 100%.

(18)

Any questions ?

 Contact to TAs :

 facebook https://www.facebook.com/groups/wn14spring/

 Email : [email protected]

 Office hour : Mon 14:00 ~ 16:00 @ CSIE R424

參考文獻

相關文件

• raw scores 80, 60 with term scores F, B: impossible from the principle: no individual score

(2) (20%) If your program can perform the add and print operations (but not move operations) correctly within the time limit, you get the score of this subtask. (3) (20%) If

Your job is to compute a score for each student given these two files, sort record by name, id, or grade, compute average score and standard deviation, and do some profile such

– Set the corresponding bits in TCCRnX(n=1,2,3 X=A,B) re gisters for mode selection and timer prescaler. – Set OCRnX for “frequency”(OCRnA) or

Suppose you get S points and your i-th opponent gets s i points, then your score is given by std::pair(S, ∑. s

– “USA” displayed on the top right corner of the clock  recei ving WWVB signal. – Full instructions are given in

EXTENDED GAMES. SCORE

1) The research assistant employed by public or certified private colleges (or above) or academic institutions to undertake projects, whose monthly salary is above the bachelor