HANBACK ELECTRONICS CO LTD Lab 1 LED Control
HANBACK ELECTRONICS CO. , LTD. Lab 1: LED Control Zigbe. X mote has Red, Yellow, Green LED. This lab using LED control component provided by Tiny. OS exercises LED device control. 저자권 보호됨
HANBACK ELECTRONICS CO. , LTD. Zigbe. X LED 2020 -12 -02 저자권 보호됨 2
HANBACK ELECTRONICS CO. , LTD. LED in Zigbe. X • Use of LED – In order to check whether certain device’s operation is performed successfully or not. • Leds. C Component – Leds. C is component to control the LED device. 2020 -12 -02 저자권 보호됨 3
HANBACK ELECTRONICS CO. , LTD. Leds functions Initialization result_t Leds. init() – 3 LED lamp is initialized. Red LED result_t Leds. red. On() - Red LED On. result_t Leds. red. Off() - Red LED OFF. result_t Leds. red. Toggle() - Red LED toggling Green LED result_t Leds. green. On() - Green LED On. result_t Leds. green. Off() - Green LED OFF. result_t Leds. green. Toggle() - Green LED toggling. Yellow LED result_t Leds. yellow. On() - Yellow LED On. result_t Leds. yellow. Off() - Yellow LED OFF. result_t Leds. yellow. Toggle() - Yellow LED toggling. 2020 -12 -02 저자권 보호됨 4
HANBACK ELECTRONICS CO. , LTD. LED sample progam 2020 -12 -02 저자권 보호됨 5
HANBACK ELECTRONICS CO. , LTD. Blink program • Blink program – An instant component named “Blink”. For configuration and module, two files Blink. nc & Blink. M. nc are required. – Blink. nc is for configuration which uses many other components used in Blink program – Blink. M. nc is a implemented module for Blink program. • Directory of Blink program – c: ProgramfilesUCBcygwinopttinyos‐ 1. xcontribzig bexBlink – Bink. nc & Blink. M. nc 2020 -12 -02 저자권 보호됨 6
HANBACK ELECTRONICS CO. , LTD. Blink. nc • Blink. nc . – Main, Led. Sc, Blink. M are used and shows how they are wired. configuration Blink { } implementation { components Main, Blink. M, Leds. C; Main. Std. Control ‐> Blink. M. Std. Control; Blink. M. Leds ‐> Leds. C; } 2020 -12 -02 저자권 보호됨 7
HANBACK ELECTRONICS CO. , LTD. Blink. M. nc • Blink. M. nc (1) module Blink. M { provides { interface Std. Control; } uses { interface Leds; } } implementation { task void led_task(); command result_t Std. Control. init() { call Leds. init(); return SUCCESS; } 2020 -12 -02 - declared by “provide” interface and “uses” interface - In implementation block is for user programming - task (function w/o parameter) : declaration - Std. Control init(), start(), stop() sequence. - Std. Control. init() calls Leds. init() to initialize Leds. C. 저자권 보호됨 8
HANBACK ELECTRONICS CO. , LTD. Blink. M. nc • Blink. M. nc (2) command result_t Std. Control. start() { post led_task(); return SUCCESS; } command result_t Std. Control. stop() { return SUCCESS; } task void led_task() { int i; for(i=0; i<10; i++) { call Leds. yellow. On(); TOSH_uwait(30000); call Leds. green. Toggle(); } } } 2020 -12 -02 -After Std. Control. init(), Std. Control. start() is executed automatically - In Std. Control. start(), defined by “task” led_task() is called by “post” header. - No specific implemetation in Std. Control. stop(). - Here your algorithm to control LED 저자권 보호됨 9
HANBACK ELECTRONICS CO. , LTD. LED Lab Item: host PC(labtop), 1 mote , ISP(AVR), cable 2020 -12 -02 저자권 보호됨 10
HANBACK ELECTRONICS CO. , LTD. LED lab -1 • Start cygwin • Goto target directory cd /opt/tinyos‐ 1. x/contrib/zigbex cd Blink • Compile - make zigbex 2020 -12 -02 저자권 보호됨 11
HANBACK ELECTRONICS CO. , LTD. LED lab -2 • Download binary code to Zigbe. X using ISP tool – After compile, folder, build/zigbex is created and main. hex is the binary. – Run AVR studio 2020 -12 -02 저자권 보호됨 12
HANBACK ELECTRONICS CO. , LTD. Lab -3 • Run AVR Studio 4 • Select ‘cancel’ 저자권 보호됨
HANBACK ELECTRONICS CO. , LTD. Lab -4 • Select – Tool Program AVR Auto Connect 저자권 보호됨
HANBACK ELECTRONICS CO. , LTD. Lab -5 • Find ‘main. hex’ file 저자권 보호됨
HANBACK ELECTRONICS CO. , LTD. Lab - 6 • Select ‘Program’ 저자권 보호됨
HANBACK ELECTRONICS CO. , LTD. Lab - 5 • Check the message and graph 저자권 보호됨
HANBACK ELECTRONICS CO. , LTD. LED lab result • Output – Yellow LED is con, every 30 ms Green LED is toggling – Please change source code to test RED. 2020 -12 -02 저자권 보호됨 18
- Slides: 18