120 likes | 291 Views
Wireless sensor Laboratory . Tomonori Nagayama Assistant Professor University of Tokyo 07/10/2009. Download and extract to tinyos/cygwin/opt/. Blink. Application using LED and Timer. Type in the following and make the application. cd $TOSDIR/apps/Blink make imote2 usb-install
E N D
Wireless sensor Laboratory Tomonori Nagayama Assistant Professor University of Tokyo 07/10/2009
Blink Application using LED and Timer. Type in the following and make the application. cd $TOSDIR/apps/Blink make imote2 usb-install See that red LED is Toggled every 1 second. You can change the code. For example, the following line: return call Timer.start(TIMER_REPEAT, 1000); change “1000” to other values. Also, you can change call Leds.redToggle();to call Leds.yellowToggle(); etc. • Read Blink.nc and Blink.nc. Understand wiring and execution flow.
BlinkTask Task example. Type in the following and make the application. cd $TOSROOT/apps/BlinkTask make imote2 usb-install See that red LED is Toggled every 1 second. You can change the code. For example, the following line: if (state) call Leds.redOn(); else call Leds.redOff(); Change call Leds.redOn();and call Leds.redOff();to call Leds.set(0); and call Leds.set(7) etc. • Read BlinkTask.nc and BlinkTaskM.nc. Understand wiring and execution flow.
UartTest Application using LED, Timer, and UART (serial communication) Change directory to UartTest make imote2 usb-install Check the outputs through Uart • Connect Imote2 to the IIB2400 interface board. • Open another cygwin window • imote2comm –b 115200 COMx You can change the line to print message to sprintf(Buffer, “Data %d %d %f !\n“, 1, 0.02, 0.02); to see the data
UartTest2 Application using LED, Timer, and UART (serial communication). Uart communication is in both directions. Change directory to UartTest2 make imote2 usb-install Check the outputs through Uart • Connect Imote2 to the IIB2400 interface board. • Open another cygwin window • imote2comm –b 115200 COMx • Type in any text on the cygwin. You can try imote2comm –i input.txt –b 115200 COMx to see how input file data is passed to the Imote2
You can send a packet periodically. The receiver attached to interface board displays a message Change RF frequency. CC2420Control.TunePreset(11);//11-26 Install the receiver Open makefile and comment out as “#CFLAGS += -DSENDER” Change directory to TestRF make imote2 usb-install Install the sender Open makefile and uncomment as “CFLAGS += -DSENDER” make imote2 usb-install Mount the sender on a battery board. Connect the receiver to the interface board. Check the outputs through Uart Connect Imote2 to the IIB2400 interface board. Open another cygwin window Imote2comm –d COMx Hit return until you see “BluSH” Turn on the sender You’ll see “Received a packet” comment. Read TestRFM.nc to see how SendMsg.send() and ReceiveMsg.receive() are implemented. Try Change TOS_BCAST_ADDRESS in SendMsg.send() to the receiver’s node ID and other node ID. Change transmission power by call CC2420Control.SetRFPower(1); TestRF *trace(DBG_USR1, “string",arg); prints out “string” through the debug port. To use “trace” write down “includes trace:” at the begging of the module file
You can send a packet periodically. Sender’s node ID is transferred on the packet. Change RF frequency. CC2420Control.TunePreset(11);//11-26 Install the receiver Open makefile and comment out as “#CFLAGS += -DSENDER” Change directory to TestRF2 make imote2 usb-install Install the sender Open makefile and uncomment as “CFLAGS += -DSENDER” make imote2 usb-install Mount the sender on a battery board. Connect the receiver to the interface board. Check the outputs through Uart Connect Imote2 to the IIB2400 interface board. Open another cygwin window Imote2comm –d COMx Hit return until you see “BluSH” Turn on the sender You’ll see “Received a packet from node xx” comment. Read TestRF2M.nc to see how data is packed into a packet and how a packet is interpreted on reception. Try Send an array of data and receive it. TestRF2
TestBluSH2 Through debug port, you can send commands and arguments. Change directory to TestBluSH2 make imote2 usb-install Check the outputs through Uart • Connect Imote2 to the IIB2400 interface board. • Open another cygwin window • imote2comm –d COMx (second COM port) • Hit return until you see “BluSH” and type the following:LedSet x (x is a value between 1-7) PrintArgs 1 3 5 3 10 Read TestBluSH2M.nc to see how BluSH components are implemented. • BluSH_AppI needs to be provided. 2 commands: getName and callApp Try • Change the number of arguments to 7 • Print out the sum of all the arguments instead of the original arguments. • Compile TestBluSH and read TestBluSHM.ncand PrintArgs 1 3.4 2.3 23 12.3 23.4 • Other BluSH commands are listed when you type “ls”. Try them.
You can write data to Flash memory. Data on Flash won’t be erased after reboot. Change directory to TestFlash make imote2 usb-install Check the outputs through Uart Connect Imote2 to the IIB2400 interface board. Open another cygwin window imote2comm –d COMx Hit return until you see “BluSH”FlashRead FlashWrite 1 3 5 3 10 FlashRead Reboot Imote2 FlashRead Read TestFlashM.nc to see how Flash write/read are implemented. Flash.erase: All bits are set to 1. Flash.write: corresponding bits are set to 0 Try Change the number of arguments to 7 Print out the sum of all the arguments instead of the original arguments. Compile TestBluSH and read TestBluSHM.ncand PrintArgs 1 3.4 2.3 23 12.3 23.4 NEVER write to or erase the FLASH regions 0x0 – 0x300000 and 0x1E00000 – 0x1F00000 as these contain vital boot loader code TestFlash
You can read local time. cd TestLocalTime make imote2 usb-install Check the outputs through Uart Connect Imote2 to the IIB2400 interface board. Open another cygwin window Imote2comm –d COMx Hit return until you see “BluSH”GetLocalTime You’ll see Local time. Repeat typing GetLocalTime The clock ticks at 3.25MHz Read TestLocalTimeM.nc to see how Time.get() is implemented. Ref. $SHMROOT/lib/Time64 Try Check whether clock reading is reasonable as compared to your watch. TestLocalTime
You can read local time periodically. cd TestLocalTime2 make imote2 usb-install Check the outputs through Uart Connect Imote2 to the IIB2400 interface board. Open another cygwin window Imote2comm –d COMx Hit return until you see “BluSH”GetLocalTime You’ll see Local time repeatedly. To stop, type GetLocalTime again. Read TestLocalTime2M.nc to see how Time.get() and Timer.start() are implemented. Ref. $SHMROOT/lib/Time64 Try Check whether clock reading is reasonable as compared to your watch. TestLocalTime2