430 likes | 571 Vues
Tutorial How to use sensors. Reporter : Jensen Vinson. Outline. Equipment Install TinyOS Programming Concept Install Sensor Create A Sensor Network Example--Light Example--Accelerometer. Equipment. OS : Linux/Windows (cygwin), TinyOS 2.x PC : USB serial port
E N D
TutorialHow to use sensors Reporter:Jensen Vinson
Outline • Equipment • Install TinyOS • Programming Concept • Install Sensor • Create A Sensor Network • Example--Light • Example--Accelerometer
Equipment • OS:Linux/Windows (cygwin), TinyOS 2.x • PC:USB serial port • Sensor:TAROKO
Install TinyOS • http://tinyos.net/ Step1:Install a Java 1.5 (Java 5) JDK
Install TinyOS Step2:Windows only. Install Cygwin --download cygwin-files.zip and unzip it under some local folder say c:/cygwin-files and start the setup http://www.cygwin.com/
Install TinyOS Step2:Windows only. Install Cygwin
Install TinyOS Step2:Windows only. Install Cygwin then, complete the rest of installation process
Install TinyOS Step3:Install native compilers Command: rpm –ivh –ignoress <file name>
Install TinyOS Step4:Install the nesC compiler & TinyOS toolchain
Install TinyOS Step5:Install the TinyOS source tree
Install TinyOS Step5:Install the TinyOS source tree --Configure the environment in the end of the file C:\cygwin\home\Administrator\.bash_profile
Install TinyOS Step6:Install the Graphviz visualization tool --download and install from the website below : http://webs.cs.berkeley.edu/tos/dist-1.1.0/tools/windows/graphviz-1.10.exe
Install TinyOS • Check if setup is correct using this command • # tos-check-env
Programming Concept • xx.h • Header file • xxAppC.nc • Configuration file • xxC.nc • Module file
Install Sensor Step1: motelist
Install Sensor Step2: install sensor ● go to the directory of the file you want to install ● # make telosb install,<logic_ID> bsl,<COM port-1> PS: In linux, the COM port needn’t minus 1
Create a sensor network • One is the BaseStation (logic_ID=0) which collects data and transmits to PC • Others are for sensing data with IEEE 802.15.4 N_2 N_1 data data data N_0
Example– Sensing light Step1:Base on Oscilloscope in tinyos2.x Step2:Some main files below Oscilloscope.h
Example (Cont.) OscilloscopeAppC.nc // configure components // creates connection between components and modules
Example (Cont.) OscilloscopeC.nc // define the interfaces it needs
// red light // yellow light // green light
Sensing data collection C:\cygwin\opt\tinyos-2.x\tos\chips\msp430\sensors
Example—Light (Cont.) Step3:Install BaseStation (N_0) • # cd /opt/tinyos-2.x/apps/BaseStation • # make telosb install,0 bsl,<COM port-1> Step4: Enable forwarder on BaseStation • # java net.tinyos.sf.SerialForwarder –comm serial@<COM port>:telosb&
Example—Light (Cont.) Step5:Install Oscilloscope (N_1, N_2) • # cd /opt/tinyos-2.x/apps/Oscilloscope • # make telosb install,<logic_ID> bsl,<COM port-1> Step6: Sensing data with GUI on BaseStation • # cd /opt/tinyos-2.x/apps/Oscilloscope/java • # make • # ./run
Example--Accelerometer Step1:Base on Oscilloscope in tinyos2.x Step2:Enable X,Y,Z axes • Create TarokoAccel0C.nc、TarokoAccel0P.nc for X axis • Create TarokoAccel1C.nc、TarokoAccel1P.nc for Y axis • Create TarokoAccel2C.nc、TarokoAccel2P.nc for Z axis
Example--Accelerometer Step3: Modify the critical codes
Example--Accelerometer Step3: Modify the critical codes
Example--Accelerometer Step3: Modify the critical codes
Example—Accelerometer (Cont.) Step4:Design GUI Step5: Install BaseStation • # cd /opt/tinyos-2.x/apps/BaseStation • # make telosb install,0 bsl,<COM port-1> Step6:Open the SerialForwarder function • # java net.tinyos.sf.SerialForwarder –comm serial@<COM port>:telosb&
Example—Accelerometer (Cont.) Step7:Install Oscilloscope • # cd /opt/tinyos-2.x/apps/Oscilloscope • # make telosb install,<logic_ID> bsl,<COM port-1> Step8: Sensing data with GUI • # cd /opt/tinyos-2.x/apps/Oscilloscope/java • # make • # ./run
Example—Accelerometer (Cont.) Step9: Physical meaning of sensor reading ● The output depends on value g (-1~1) • when g=-1, the output is around 1,650 • when g=0, the output is around 2,048 • when g=1, the output is around 2,500 ● There are 6 main orientations (more details as following pages)
Physical meaning of sensor reading(cont.) (1) X-out(red)=1g Y-out(white)=0g Z-out(green)=0g
Physical meaning of sensor reading(cont.) (2) X-out(red)=0g Y-out(white)=1g Z-out(green)=0g
Physical meaning of sensor reading(cont.) (3) X-out(red)=-1g Y-out(white)=0g Z-out(green)=0g
Physical meaning of sensor reading(cont.) (4) X-out(red)=0g Y-out(white)=-1g Z-out(green)=0g
Physical meaning of sensor reading(cont.) (5) X-out(red)=0g Y-out(white)=0g Z-out(green)=1g
Physical meaning of sensor reading(cont.) (6) X-out(red)=0g Y-out(white)=0g Z-out(green)=-1g