Transcript
Page 1: HANBACK ELECTRONICS CO., LTD. 저자권 보호됨 Lab1: LED Control ZigbeX mote has Red, Yellow, Green LED. This lab using LED control component provided by TinyOS

HANBACKELECTRONICS CO., LTD.

저자권 보호됨

Lab1: LED Control

ZigbeX mote has Red, Yellow, Green LED. This lab using LED control component provided by TinyOS exercises LED device control.

Page 2: HANBACK ELECTRONICS CO., LTD. 저자권 보호됨 Lab1: LED Control ZigbeX mote has Red, Yellow, Green LED. This lab using LED control component provided by TinyOS

HANBACKELECTRONICS CO., LTD.

저자권 보호됨23年 5月 5日 2

ZigbeX LED

Page 3: HANBACK ELECTRONICS CO., LTD. 저자권 보호됨 Lab1: LED Control ZigbeX mote has Red, Yellow, Green LED. This lab using LED control component provided by TinyOS

HANBACKELECTRONICS CO., LTD.

저자권 보호됨23年 5月 5日 3

LED in ZigbeX • Use of LED

– In order to check whether certain device’s operation is performed successfully or not.

• LedsC Component– LedsC is component to control the LED device.

Page 4: HANBACK ELECTRONICS CO., LTD. 저자권 보호됨 Lab1: LED Control ZigbeX mote has Red, Yellow, Green LED. This lab using LED control component provided by TinyOS

HANBACKELECTRONICS CO., LTD.

저자권 보호됨23年 5月 5日 4

Leds functions  functions

Initialization  result_t Leds.init() – 3 LED lamp is initialized.

Red LED result_t Leds.redOn() - Red LED On. result_t Leds.redOff() - Red LED OFF. result_t Leds.redToggle() - Red LED toggling

Green LED result_t Leds.greenOn() - Green LED On. result_t Leds.greenOff() - Green LED OFF. result_t Leds.greenToggle() - Green LED toggling.

Yellow LED result_t Leds.yellowOn() - Yellow LED On. result_t Leds.yellowOff() - Yellow LED OFF. result_t Leds.yellowToggle() - Yellow LED toggling.

Page 5: HANBACK ELECTRONICS CO., LTD. 저자권 보호됨 Lab1: LED Control ZigbeX mote has Red, Yellow, Green LED. This lab using LED control component provided by TinyOS

HANBACKELECTRONICS CO., LTD.

저자권 보호됨23年 5月 5日 5

LED sample progam

Page 6: HANBACK ELECTRONICS CO., LTD. 저자권 보호됨 Lab1: LED Control ZigbeX mote has Red, Yellow, Green LED. This lab using LED control component provided by TinyOS

HANBACKELECTRONICS CO., LTD.

저자권 보호됨23年 5月 5日 6

Blink program • Blink program

– An instant component named “Blink”. For configuration and module, two files Blink.nc & BlinkM.nc are required.

– Blink.nc is for configuration which uses many other components used in Blink program

– BlinkM.nc is a implemented module for Blink program.

• Directory of Blink program– c:\Programfiles\UCB\cygwin\opt\tinyos‐1.x\contrib\zigbex\

Blink\ – Bink.nc & BlinkM.nc

Page 7: HANBACK ELECTRONICS CO., LTD. 저자권 보호됨 Lab1: LED Control ZigbeX mote has Red, Yellow, Green LED. This lab using LED control component provided by TinyOS

HANBACKELECTRONICS CO., LTD.

저자권 보호됨23年 5月 5日 7

Blink.nc • Blink.nc .

– Main, LedSc, BlinkM are used and shows how they are wired.

configuration Blink { } implementation {     components Main, BlinkM, LedsC;     Main.StdControl ‐> BlinkM.StdControl;      BlinkM.Leds ‐> LedsC;                 }

Page 8: HANBACK ELECTRONICS CO., LTD. 저자권 보호됨 Lab1: LED Control ZigbeX mote has Red, Yellow, Green LED. This lab using LED control component provided by TinyOS

HANBACKELECTRONICS CO., LTD.

저자권 보호됨23年 5月 5日 8

BlinkM.nc • BlinkM.nc (1)module BlinkM {   provides {     interface StdControl;   }   uses {   interface Leds;   } } implementation {   task void led_task();

  command result_t StdControl.init() {      call Leds.init();      return SUCCESS;   }   

- declared by “provide” interface and “uses” interface

- In implementation block is for user programming- task (function w/o parameter) : declaration- StdControl init(), start(), stop() sequence.

- StdControl.init() calls Leds.init() to initialize LedsC.

Page 9: HANBACK ELECTRONICS CO., LTD. 저자권 보호됨 Lab1: LED Control ZigbeX mote has Red, Yellow, Green LED. This lab using LED control component provided by TinyOS

HANBACKELECTRONICS CO., LTD.

저자권 보호됨23年 5月 5日 9

BlinkM.nc • BlinkM.nc (2)command result_t StdControl.start() {      post led_task();        return SUCCESS;   }

  command result_t StdControl.stop() {      return SUCCESS;   }

  task void led_task() {      int i;      for(i=0; i<10; i++) {        call Leds.yellowOn();        TOSH_uwait(30000);         call Leds.greenToggle();       }   } }

-After StdControl.init(), StdControl.start() is executed automatically - In StdControl.start(), defined by “task” led_task() is called by “post” header.

- No specific implemetation in StdControl.stop().

- Here your algorithm to control LED

Page 10: HANBACK ELECTRONICS CO., LTD. 저자권 보호됨 Lab1: LED Control ZigbeX mote has Red, Yellow, Green LED. This lab using LED control component provided by TinyOS

HANBACKELECTRONICS CO., LTD.

저자권 보호됨23年 5月 5日 10

LED Lab

Item:host PC(labtop), 1 mote , ISP(AVR), cable

Page 11: HANBACK ELECTRONICS CO., LTD. 저자권 보호됨 Lab1: LED Control ZigbeX mote has Red, Yellow, Green LED. This lab using LED control component provided by TinyOS

HANBACKELECTRONICS CO., LTD.

저자권 보호됨23年 5月 5日 11

LED lab -1• Start cygwin• Goto target directory

• Compile - make zigbex

cd /opt/tinyos‐1.x/contrib/zigbex cd Blink

Page 12: HANBACK ELECTRONICS CO., LTD. 저자권 보호됨 Lab1: LED Control ZigbeX mote has Red, Yellow, Green LED. This lab using LED control component provided by TinyOS

HANBACKELECTRONICS CO., LTD.

저자권 보호됨23年 5月 5日 12

LED lab -2• Download binary code to ZigbeX using

ISP tool– After compile, folder, build/zigbex is created and main.hex

is the binary. – Run AVR studio

Page 13: HANBACK ELECTRONICS CO., LTD. 저자권 보호됨 Lab1: LED Control ZigbeX mote has Red, Yellow, Green LED. This lab using LED control component provided by TinyOS

HANBACKELECTRONICS CO., LTD.

저자권 보호됨

Lab -3• Run AVR Studio4

• Select ‘cancel’

Page 14: HANBACK ELECTRONICS CO., LTD. 저자권 보호됨 Lab1: LED Control ZigbeX mote has Red, Yellow, Green LED. This lab using LED control component provided by TinyOS

HANBACKELECTRONICS CO., LTD.

저자권 보호됨

Lab -4 • Select

– Tool Program AVRAuto Connect

Page 15: HANBACK ELECTRONICS CO., LTD. 저자권 보호됨 Lab1: LED Control ZigbeX mote has Red, Yellow, Green LED. This lab using LED control component provided by TinyOS

HANBACKELECTRONICS CO., LTD.

저자권 보호됨

Lab -5• Find ‘main.hex’ file

Page 16: HANBACK ELECTRONICS CO., LTD. 저자권 보호됨 Lab1: LED Control ZigbeX mote has Red, Yellow, Green LED. This lab using LED control component provided by TinyOS

HANBACKELECTRONICS CO., LTD.

저자권 보호됨

Lab - 6• Select ‘Program’

Page 17: HANBACK ELECTRONICS CO., LTD. 저자권 보호됨 Lab1: LED Control ZigbeX mote has Red, Yellow, Green LED. This lab using LED control component provided by TinyOS

HANBACKELECTRONICS CO., LTD.

저자권 보호됨

Lab - 5• Check the message and graph

Page 18: HANBACK ELECTRONICS CO., LTD. 저자권 보호됨 Lab1: LED Control ZigbeX mote has Red, Yellow, Green LED. This lab using LED control component provided by TinyOS

HANBACKELECTRONICS CO., LTD.

저자권 보호됨23年 5月 5日 18

LED lab result• Output

– Yellow LED is con, every 30ms Green LED is toggling

– Please change source code to test RED.


Recommended