Home
Project Final Report by Zengxu Yang and Wayne Sun
Contents
1. 11 Sets source file searching path vpath Two pattern rules set every target two prerequisits at the end of this file Makefile include Cancel the predefined implict rule for compiling and linking a single C source into a binary to force GNU make to consider the match anything rule below instead ke hG Match anything pattern rule to allow the project makefiles to abstract from the actual binary name It needs to contain some command in order to be a rule not just a prerequisite TARGET The first pattern rule does not have a recipe The purpose is to cancel the implicit rule The second pattern rule has an empty recipe The purpose here seems to not generate the real target but to make sure the prerequisit z1 websense z1 being generated As CUSTOM_RULE_LINK is defined near the end of Makefile so the rules for target z1 websense z1 on line 253 is defined and executed because CUSTOM_RULE_LINK has not been defined here yet TARGET co PROJECT_OBJECTFILES PROJECT_LIBRARIES contiki TARGET a TRACE_LD Q LD LDFLAGS TARGET_STARTFILES filter out a 7 filter a 7 TARGET_LIBFILES o 0 The target z1 websense z1 is the final target so the recipe in this rule is for linking object files Note that it places archives to the last of all prerequisites when linking This rule has several dependencies We explain each one First one is co This is a pa
2. Its very important that you recognize the limited scope in which automatic variable values are available they only have values within the recipe In particular you cannot use them anywhere within the target list of a rule they have no value there and will expand to the empty string Also they cannot be accessed directly within the prerequisite list of a rule A common mistake is attempting to use 0 within the prerequisites list this will not work However there is a special feature of GNU make secondary expansion which will allow automatic variable values to be used in prerequisite lists 3 3 4 Special variables Some special variables are used MAKEFILE_LIST Contains the name of each makefile that is parsed by make in the order in which 3 3 5 Source code path The general search path VPATH is used to specify the paths that make searches when looking for source code We can also use vpath to be more fine grained and efficient vpath pattern directory list 3 3 6 Pattern rules If you write multiple pattern rules with exactly the same target and prerequisites not necessarily the same recipe then only the last one will be executed But make does not report any errors in such situations If only the target is the same then only the first one that can be executed e g the prerequisites exist is executed 3 3 7 Implicit rules Implicit rules tell make how to use customary techniques so that you do not have to specify them in
3. Test Accel process PROCESS status_process Status handling process AUTOSTART_PROCESSES web_sense_process amp accel_process amp status_process The definition of web_sense_process process thread is PROCESS_THREAD web_sense_process ev data static struct etimer timer PROCESS_BEGIN cc2420_set_txpower 31 sensors_pos 0 process_start kwebserver_nogui_process NULL etimer_set timer CLOCK_SECOND 2 SENSORS_ACTIVATE battery_sensor SENSORS_ACTIVATE temperature_sensor while 1 4 PROCESS_WAIT_EVENT_UNTIL etimer_expired amp timer etimer_reset amp timer batteryl1 sensors_pos get_mybatt 1000 temperature sensors_pos get_mytemp 22 179 180 181 182 370 371 372 373 374 375 376 377 378 379 380 sensors_pos sensors_pos 1 HISTORY PROCESS_END This process 1 calls cc2420_set_txpower to set the radio transmission power 2 starts another process webserver_nogui_process that sets up the web server 3 activates the battery and temperature sensors 4 gets the values of the battery and temperature sensors every 2 seconds The main function mainly 1 Initializes the MSP430 CPU and all peripheral devices 2 Starts all autostart processes by calling autostart_start It further calls process_start for each autostart process 3 Starts the scheduler loop 4 4 ADXL345 sensor pro
4. CONTIKI_SOURCEFILES framer nullmac c framer 802154 c csma c contikimac c phase c In core net rpl1 Makefile rpl CONTIKI_SOURCEFILES rpl c rpl dag c rpl icmp6 c rpl timers c rpl mrhof c rpl ext header c In Makefile include CONTIKIFILES SYSTEM LIBS NET THREADS DHCP DEV CONTIKI_SOURCEFILES CONTIKIFILES CONTIKI_SOURCEFILES APP_SOURCES DSC_SOURCES 16 In cpu msp430 Makefile msp430 CONTIKI_SOURCEFILES CONTIKI_TARGET_SOURCEFILES So contiki z1 a is the system library and contains most of the system files of Contiki The final process for the target is msp430 gcc Wl defsym W1 __P1SEL2 0x0041 W1 defsym W1 __P5SEL2 0x0045 A mmcu msp430f2617 W1 Map contiki z1l map W1l gc sections undefined _reset_vectar__ undef ined InterruptVectors undefined _copy_data_init__ undefined _clear_bss_init__ undefined _end_of_init__ zi websense co obj_z1 httpd simple o obj_zi contiki zi main o e o 94 95 96 97 187 188 contiki z1 a o zi websense zl The linker deletes intermediate files after successfully linking We can keep those files for debugging purposes Just use those files as prerequisites for the special target SECONDARY Both obj_z1 httpd simple o and obj_z1 httpd o contain the function symbol httpd_init but because the latter is archived in the file contiki z1 a this symbol is
5. make hello world upload If you see the lights in your mote flash then the image should be successfully burned into the Z1 mote 5 Web server This is for installing web service on the Contiki virtual machine which runs Ubuntu Linux 12 04 The following steps provide a working environment As this is the simplest way of making sure everything works smoothly without worrying about different operating systems and configurations compiling priviledges problems etc 5 1 Install Tomcat To install Tomcat make sure your computer is connected to the Internet then open a terminal and run sudo apt get update sudo apt get remove openjdk 6x sudo apt get install openjdk 7 jdk sudo apt get install tomcat tomcat7 admin tomcat7 examples Edit the Tomcat user configuration file with sudo nano etc tomcat7 tomcat users xml and add the following before the last line lt role rolename manager gui gt lt user username twl password twl roles manager gui gt Then run sudo service tomcat7 restart to restart the Tomcat 7 service Launch the firefox browser and enter localhost 8080 If everything is OK you will see the welcome page of Tomcat Then you can click the link manager webapp under tomcat 7 admin in this page When asked about user name and password type twl and twl In the manager page you can deploy your program by using WAR file to deploy 28 5 2 1 PostgreSQL database Install
6. used for debugging 3 4 Z1 websense makefile 3 4 1 Generating target ELF file We take the examples z1 ipv6 z1 websense Makefile as an example This is the makefile we will use for our movement detection We use the default rule all to compile link and generate the final ELF file zi websense z1 Its prerequisite is z1 websense all zi websense CONTIKI WITH_UIP6 1 UIP_CONF_IPV6 1 SMALL 1 APPS webserver webbrowser CFLAGS DPROJECT_CONF_H project conf h CONTIKI_SOURCEFILES wget c PROJECTDIRS ipv6 rpl border router PROJECT_SOURCEFILES httpd simple c include CONTIKI Makefile include 12 18 19 20 21 22 23 24 25 26 CONTIKI tools tunslip6 CONTIKI tools tunslip6 c connect router CONTIKI tools tunslip6 connect router cooja CONTIK1 too1s tunslip6 cd CONTIKI tools amp amp MAKE tunslip6 sudo CONTIKI tools tunslip6 aaaa 1 64 sudo CONTIKI tools tunslip6 a 127 0 0 1 aaaa 1 64 It sets UIP_CONF_IPV6 1 which includes IPv6 support in uIP protocol stack This file includes other makefiles The included makefile list MAKEFILE_LIST Makefile sada Makefile include Makefile target sii fea NA A A A A No NN A AN A A XX T core net rime Makefile rime core net mac Makefile mac core net Makefile uip core net rpl Makefile rpl A apps webserver Makefile w
7. bedroom l room will also be able to send back the location of Y a kitchen Y dining room 5 a F the user which might provide more help to 36 0 handle the emergencies Figure 10 from DESAIN RUMAH UNIK 6 5 3 The sensor is not enough Combine with other sensors Blood pressure heart rate steps walking and running distance When a fall happened the blood pressure and the heart rate will raise extremely Even though running also raise the heart rate and blood pressure but if we combine with the step sensor we can easily tell it is a fall or running For example when we get high heart rate and high blood pressure but the step sensor counted 7 step it probably be running 5 4 Barrier of our fall detector The user must wear the sensor properly or the sensor will give a terrible work The sensor is designed to put into the pants pocket and must be vertical If the user hold it on the hand or put it in the bag the sensor is not able to detect right To solve this problem the sensor might be designed rotatable it will automatically change its algorithm to detect the activities Reference 1 Ning Jia Detecting human falls with a 3 axis digital accelerometer Analog Dialogue 43 7 43 50 2009 2 Contiki website The Open Source OS for the Internet of Things http www contiki os org 3 A smart sensor to detect the falls of the elderly http search proquest com docview 1019694417
8. part is called a substitution reference to variables which is actually an abbreviation for use of the patsubst expansion function CONTIKI_TARGET_MAIN is defined in platform z1 Makefile common as CONTIKI_TARGET_MAIN contiki z1 main c File contiki zi main c is under platform z1 So PROJECTFILES actually has two files httpd simple o and contiki zi main o They will be put in directory obj_z1 The third one is PROJECT_LIBRARIES This cannot be found anywhere So it is empty The fourth one is contiki z1 a This is an archive file with its own rule contiki TARGET a CONTIKI_OBJECTFILES TRACE_AR Q AR AROPTS 0 7 15 87 13 19 20 21 22 23 24 25 26 73 78 104 where CONTIKI_OBJECTFILES is defined as CONTIKI_OBJECTFILES addprefix OBJECTDIR call oname CONTIKI_SOURCEFILES gt gt The variable CONTIKI_SOURCEFILES is defined and appended in multiple files We list the definitions in the order they appear In example z1 ipv6 z1 websense Makefile CONTIKI_SOURCEFILES wget c In core net rime Makefile rime CONTIKI_SOURCEFILES RIME_BASE RIME_SINGLEHOP RIME_MULTIHOP RIME_MESH RIME_COLLECT RIME_RUDOLPH RIME_CHAMELEON RIME_UIP6 In core net mac Makefile mac CONTIKI_SOURCEFILES cxmac c xmac c nullmac c 1pp c frame802154 c sicslowmac c nullrdc c nullrdc n
9. resolved to the object file httpd simple o Also because the latter is an archive file the linker won t report a multiple definition error like when detecting identical symbols in multiple object files 3 4 2 Uploading to a Z1 mote The rule for uploading to a Z1 mote is 4 upload It is defined in platform z1 Makefile common as upload ihex cp lt IHEXFILE echo MOTES MAKE zi reset z1 upload The prerequisite is defined in cpu msp430 Makefile msp430 as ihex TARGET OBJCOPY 0 ihex 0 Intel HEX ihex is a file format that conveys binary information in ASCII text form It is commonly used for programming microcontrollers EPROMs and other types of programmable logic devices In a typical application a compiler or assembler converts a program s source code such as in C or assembly language to machine code and outputs it into a HEX file The HEX file is then imported by a programmer to burn the machine code into a ROM or is transferred to the target system for loading and execution 4 17 23 186 187 188 189 190 191 192 These rules show that the z1 websense ihex file is generated using msp430 objcopy and this file is copied to tmpimage ihex for flashing The variable MOTES is the device name for the mote We can specify it when operating a specific mote for example make z1 websense upload MOTES dev ttyUSBO 3 43 TUNSLIP6 The tool tuns1 i
10. the sensor might detect it as a running or walking If the impact of the jump is too small the result will be walking Moreover If we jump forward sometimes it will consider it a fall Jumping is the hardest activity to be defined The solution is to tune the sensitivity of the sensor by machine learning The result of falling is not good as we expected Probably the way we test it is wrong We did not actually fall down however we threw the Moto G on the ground The acceleration during the experiment might not close to the real fall sometimes Therefore sometimes it consider the situation as a jump or running 5 Improvement In the Future 5 1 The activities are different from people to people The solutions is to embed Machine Learning system to tune the sensitivity personally Because there is no best solution the thresholds should be changed on different users and so does the other values Therefore the machine learning is necessary 5 2 The environment will change The solution is to define dangerous areas and automatically change the sensitivity of the detector For example if the sensor detect the user get into the bathroom it raise the sensitivity because the chance to fall in a bathroom is relatively high To achieve this technology we must add a detector to figure out user s location in order 12 0 window e AL to change the sensitivity E o Moreover if the user fall the sensor living
11. 3 8 Debugging Z1 websense makefile 3 4 1 Generating target ELF file 3 4 2 Uploading to a Z1 mote 3 43 TUNSLIP6 4 Movement detection on Z1 motes 4 1 ADXL345 accelerometer 4 2 Main architecture 4 3 Code implementation 4 4 ADXL345 sensor processing 4 5 Web communication 4 6 Memory Map 4 7 Compile and running 4 8 Falling detection patterns 4 9 Virtual machine settings for USB 4 10 Flash the Z1 mote through USB 5 Web server 5 1 Install Tomcat 5 2 PostgreSQL database 5 3 Deploy Ruiling s program 6 CoAP 7 Problems and planned improvement 18 18 21 22 23 25 25 25 26 26 27 28 28 29 29 30 30 Acknowledgement 30 1 Introduction 1 1 Falling detection Falling is a major hazard for body injury or death if not treated timely Elderly people are vulnerable for falling because of the weakness of their body As the MEMS technology progresses rapidly the low power inexpensive and high precision accelerom eters have become more and more popular and is widely used for vehicles smartphones Some of the newly developed accelerometers have 3 axis detections and can be used to detect different pattern of movement on wearable devices For example the ADXL345 accelerometer developed by Analog Devices 1 1 2 6LOWPAN Internet has profoundly changed the way pe
12. 6 197 198 199 200 201 202 203 204 205 206 207 208 209 210 63 define ADXL345_THRESH_TAP 0x1D define ADXL345_OFSX On1E define ADXL345_OFSY Ox1F define ADXL345_OFSZ 0220 define ADXL345_DUR 0x21 define ADXL345_LATENT 0122 define ADXL345_ WINDOW 0123 define ADXL345_ THRESH_ACT 0124 define ADXL345_ THRESH_ INACT 0125 define ADXL345_TIME_ INACT 0126 define ADXL345_ACT_ INACT_CTL 0127 define ADXL345_THRESH_FF 0128 define ADXL345_TIME_FF 0129 define ADXL345_TAP_AXES 022A define ADXL345_ACT_TAP_STATUS 0x2B read only define ADXL345_BW_RATE 0x2C define ADXL345_POWER_ CTL Ox2D define ADXL345_ INT_ENABLE O22E define ADXL345_INT_MAP 0x2F define ADXL345_ INT_SOURCE 0230 read only define ADXL345_DATA_FORMAT 0x31 define ADXL345_DATAXO 0232 read only LSByte X two s complement define ADXL345_DATAX1 0133 read only MSByte X define ADXL345_DATAYO 0234 read only LSByte Y define ADXL345_DATAY1 0135 read only MSByte X define ADXL345_DATAZO 0236 read only LSByte Z define ADXL345_DATAZ1 0137 read only MSByte X define ADXL345_FIFO_CTL 0138 define ADXL345_FIFO_STATUS 0139 read only ADXL345 interrupts define ADXL345_INT_DISABLE 0X00 used for disabling interrupts define ADXL345_INT_OVERRUN 0X01 define ADXL345_INT_WATERMARK 0X02 define ADXL345_INT_FREEFALL OXO4 define ADXL345_INT_INACTIVITY 0X08 define ADXL345_INT_ACTIV
13. 87 188 189 190 191 192 193 194 195 196 197 198 199 200 inti6_t x y Z serial_shell_init shell_ps_init shell_file_initQ for printing out files shell_text_initO for binprint Register the event used for lighting up an LED when interrupt strikes ledOff_event process_alloc_event Start and setup the accelerometer with default values eg no interrupts enabled accm_init Register the callback functions for each interrupt ACCM_REGISTER_INT1_CB accm_ff_cb ACCM_REGISTER_INT2_CB accm_tap_cb Set what strikes the corresponding interrupts Several interrupts per pin is possible For the eight possible interrupts see adzl345 h and adzl345 datasheet accm_set_irq ADXL345_INT_FREEFALL ADXL345_INT_TAP ADXL345_INT_DOUBLETAP while 1 4 x accm_read_axis X_AXIS y accm_read_axis Y_AXIS z accm_read_axis Z_AXIS printf x Xd y d z 4dWn x y 2 etimer_set et ACCM_READ_INTERVAL PROCESS_WAIT_EVENT_UNTIL etimer_expired et PROCESS_END 1 Initialize the accelerometer by calling accm_init 2 Register the interrupt callback functions 3 Call accm_set_irq to enable free fall tap and double tap interrupts in ADXL345 4 Read the X Y Z axis readings each second continuously We need to send the free falling events to the Internet by 6LoWPAN 4 2 For the movement detection we decide to impleme
14. AP With Contiki s ContikiMAC and sleepy routers even wireless routers can be battery operated Contiki runs on a range of low power wireless devices many of which can be easily purchased online 2 For this project we use the Zolertia Z1 motes which are supported by Contiki IP Protocol Stack 6LOWPAN Protocol Stack RTP Application Application protocols LoWPAN Ethernet MAC Data Link IEEE 802 15 4 MAC Ethernet PHY Physical IEEE 802 15 4 PHY Figure 1 IP and 6LoWPAN protocol stacks 1 4 Z1 motes The Zolertia Z1 is a low power wireless sensor network mote It features a second generation MSP430F 2617 low power microcontroller with 3 e a 16 bit RISC CPU 16 MHz clock speed e built in clock factory calibration e 8 KB RAM e 92 KB Flash memory e IEEE 802 15 4 compliant CC2420 transceiver operates at 2 4 GHz with an effective data rate of 250 Kbps e a digital programmable accelerometer ADXL345 e a digital temperature sensor TMP 102 Although Z1 has 92kB Flash memory only the addresses below 64kB can be used now because of the limitations of compiler or boot loader 2 Project network configuration 2 1 Basic configuration We need to access the Z1 motes on the Internet in order to let them communicate with the web server computer border router VirtualBox Z1 mote Figure 2 Project configuration The basic configuration is shown in Figure 2 The whole system includes 1 One compute
15. Constrained Application Protocol CoAP is a software protocol intended to be used in very simple electronics devices that allows them to communicate interactively over the Internet It is particularly targeted for small low power sensors switches valves and similar components that need to be controlled or supervised remotely through standard Internet networks CoAP is an application layer protocol that is intended for use in resource constrained internet devices such as WSN nodes CoAP is designed to easily translate to HTTP for simplified integration with the web while also meeting specialized requirements such as multicast support very low overhead and simplicity 6 The CoRE group has designed CoAP with the following features in mind e RESTful protocol design minimizing the complexity of mapping with HTTP e Low header overhead and parsing complexity e URI and content type support e Support for the discovery of resources provided by known CoAP services Simple subscription for a resource and resulting push notifications e Simple caching based on max age The mapping of CoAP with HTTP is also defined allowing proxies to be built providing access to CoAP resources via HTTP in a uniform way 7 Problems and planned improvement e The IMG hack we use is awkward and slow The delay can be 5 to 6 seconds and the new sensor information could be lost while waiting for the page refreshment We plan to use direct HTTP requests instead o
16. ITY 0X10 define ADXL345_INT_DOUBLETAP 0X20 define ADXL345_INT_TAP OX40 define ADXL345_INT_DATAREADY 0X80 While checking the map file we find that the ADXL345 interrupts use vector addresses OxFFE4 The interrupt service routine ISR is defined as cpu msp430 isr_compat h define ISR a b interrupt a _VECTOR b void After macro expansion it becomes interrupt PORT1_VECTOR port1_isr void 19 168 181 182 183 130 131 132 133 134 165 This is an MSPGCC extension The macro PORT1_VECTOR is defined in file msp430 2617 h provided by msp430 libc define PORT1_ VECTOR 020024 OXFFEJ Port 1 There are two paramters for the free fall detection minimal time threshold and maximal acceleration threshold When at rest the accelerometer measures 1g acceleration towards the ground and in a free falling the acceleration is 0 The FREE_FALL bit is set when acceleration of less than the value stored in the THRESH_FF register Address 0x28 is experienced for more time than is specified in the TIME_FF register Address 0x29 on all axes logical AND The FREE_FALL interrupt differs from the inactivity interrupt as follows all axes always participate and are logically ANDed the timer period is much smaller 1 28 sec maximum and the mode of operation is always dc coupled The default free fall time in Contiki 2 7 is 160 ms The default free fall threshol
17. Intel hex http en wikipedia org wiki Intel_HEX 2014 5 Contiki OS Wiki Contiki processes https github com contiki os contiki wiki Processes 2014 6 Wikipedia Constrained application protocol http en wikipedia org wiki Constrained_ Application_Protocol 2014 31 Movement Detection using Contiki and Android EE193 Project 1 Final Report Part Il Wei Tse Sun Content O E E d MEE DES ile i WAG Hees a A dncongi a SAND android Emulator nal AE aA eaten De Project Neon Cont Euratom 8028 deni freir erat 2 THe Fall Deractor Alcan ais Tesco meter cmo ea na eann atin soste TEE IAG el Stance baie bs Puce asa Mdeanael areata A MOMS Weiehtot Th DI Rie et te ee er ro EE sA the Wee to Anele sisieepilloma ice ote eee cepieraseconblesauepeiionce sas ME eo ACM ib A Face O tnala E improvement inthe Fltir n a rd ed tea ties 5 1 The activities are different from people to people rttrrrttrttetsns 5 2 The environment will change eos ciane rta Thesis movenduEh eps EA Barrier of Our fall detector a Reference NE 1 Introduction 1 1 Eclipse IDE The Eclipse IDE is the software required to coding JAVA language It includes android tools shown below Android studio IDE Android SDK tools Android 5 0 Lollipop Platform Android 5 0 emulator system image with Google APIs At the core of Android Studio is an intelligent code editor capable of advanced code analysis We are able to bui
18. PostgreSQL and JDBC driver sudo apt get install postgresql libpostgresql java jdbc Create a password for the PostgreSQL database sudo u postgres psql Xpassword Log into the PostgreSQL database using the password just created psql U postgres h localhost After logging into PostgreSQL create a table CREATE TABLE devices device_id integer NOT NULL UNIQUE device_id user_name varchar 40 protocol varchar 80 If your created table is not what you want you can drop it DROP TABLE devices Do not forget putting a semicolon after each command 5 3 Deploy Ruiling s program After installing Tomcat and PostgreSQL database you can start deploying Ruiling s program and registering your new devices Download Ruiling s program named my_web_app war which is a compressed Java web archive to a directory and extract it Edit the file dbcheck jsp and change the password to the one that you just created connection DriverManager getConnection jdbc postgresql localhost 5432 postgres postgres password Still in the extracted directory copy the installed JDBC driver to the web app by running cp usr lib java postgresql jdbc4 9 1 jar WEB INF lib Delete and repackage the WAR file rm my_web_app war jar cvf my_web_app war In your browser go to localhost 8080 manager and deploy the newly generated WAR file You will then be able to add devices to the database from your browser 29 6 CoAP
19. TAP status RUNNING printf u DoubleTap detected 0x 02X uint16_t clock_time 128 else if reg amp ADXL345_INT_TAP status WALKING printf u Tap detected 0x402X uint16_t clock_time 128 reg else status MOVING print_int reg printf u Move detected 0x 02X uint16_t clock_time 128 reg We also use y axis values to detect sitting and standing We think the user is standing if y lt 200 sitting if y gt 100 The 3 axes values are read constantly every second examples z1 ipv6 z1 websense c while 1 x accm_read_axis X_AXIS y accm_read_axis Y_AXIS z accm_read_axis Z_AXIS printf z fd y hd 2 din x y 2 if strncmp status 1 0 if y lt 200 process_post amp status_process status_event NULL status STANDING if y gt 100 process_post kstatus_process status_event NULL status SITTING etimer_set et ACCM_READ_INTERVAL PROCESS_WAIT_EVENT_UNTIL etimer_expired ket 24 printf u Freefall detected 0x 02X uint16_t clock_time 128 reg print_int reg JAZZ reg 91 100 101 102 103 104 106 107 109 4 5 Web communication A mote connects to the Internet through the border router The ideal way to communicate with the web server on the Internet is to send an HTTP request packet w
20. Tufts University School of Engineering Department of Electrical and Computer Engineering EE193 Project Final Report Movement Detection using Contiki and Android Name Zengxu Yang amp Wei Tse Sun Submitted to Prof Chang Movement Detection using Contiki and Android Part I Contiki Zengxu Yang December 18 2014 Contents 1 Introduction 1 1 Falling detection ps m olathe dusk SA hoya ee Gb at Goede he doh at Hate bode 1 25 GLOW PAN ch 3 es tee oy eee oe eta I ee ies eee A PS e a A 2 Contiki 23 atta ee Ek Sed AS Ae By Bae a eS ee ee ee ee TA ZY motes sab ei Pi eee A A ee ee oe A AS Pa ee a Project network configuration 2 1 Basic configurations di Oe ee EA AA A A DEA A 2 2 Configure the virtual machine network o e e e 2 3 Setting up virtual machine guest OS e 2 4 Setting up remote computer OB 2 5 Analyze packets using Wireshark o o Compiling a Contiki program 3 1 Contiki Version toa ais m ehga e Gide dde Ae Ae e dd de da la 32 GCC compiler s a 24s iew a e ke ES a e e Pe o e a ES a 3 39 GNU make hna bo 44 eee aa a ee ee he a a eah Sik R les daei ie ee eS Abe eS ee doe He AR a E ET EA 3 39 20 YVALIADES A A es Sy A eae Se oe ted ae ee ae 33 5 Automatic variables ad ee Ne e AE SUA bo ae a a 3 4 3 3 4 Special variables 3 3 5 Source code path 3 3 6 Pattern rules 3 3 7 Implicit rules 3
21. accountid 14434 4 PhoneMore Motorola Moto G 4G XT1045 http www phonemore com phone motorola moto 9 49 xt 1045 1536 5 Android developers http developer android com index html 6 DESAIN RUMAH UNIK http desainrumahunik info interior design blueprints
22. as a jump Otherwise it is a fall The code is shown in figure 8 else if weight_sum gt 100 ifCangle gt 110 curr_state jumping else curr_state fall Figure 8 It will be easier to understand the algorithm by overlooking the structure shown in figure 9 Sitting Static lt Standing Walking DATA Dynamic lt Running Jumping Extremely Dynamic Fall Figure 9 4 Test and Result On practical experiments we test each statuses for 50 times The result is shown below Correct Wrong Sitting 45 5 Standing 44 6 Walking 37 13 Running 34 16 Jumping 21 39 Fall 32 18 Ratio 0 9 0 88 0 74 0 68 0 42 0 64 The way we test the sitting and standing is by alternating standing and sitting The result is quit good However sometimes when we stood up the sensor detect it a jump because we stand up too fast Also when we are sitting down if we sit too fast the sensor will detect it a fall We also test the walking and running alternatively During the walking there is an acceleration when we turned our direction which might let the sensor think we are running or jumping Moreover when we give it a heavy step the sensor will consider it as a jump this both happened on running and walking test Besides when we are testing running sometimes it considered we are walking because we did not run fast enough Jumping is the most unstable status during the experiment If we jump too frequently
23. b Run sbin ifconfig eth0 and write down the IPv6 address with prefix bbbb Mine is bbbb a00 27ff fe8d 4867 2 4 Setting up remote computer OS Next we set up the remote computer OS As our virtual machine network is in bridged mode our host computer is considered a remote computer on LAN We cannot directly access the motes because we do not have the routing information yet We plan to add a new route on one computer in the LAN First we check if our computer has received the advertised address Check the network interface card by sbin ifconfig eth0 and get zengxu desktop1 sbin ifconfig eth0 eth0 Link encap Ethernet HWaddr d4 3d 7e 97 22 90 inet addr 192 168 0 104 Bcast 192 168 0 255 Mask 255 255 255 0 inet6 addr 2601 6 7e80 aa9 d63d 7eff fe97 2290 64 Scope Global inet6 addr fd5c 3ea0 7a43 6ed 128 Scope Global inet6 addr fe80 d63d 7eff fe97 2290 64 Scope Link inet6 addr fd5c 3ea0 7a43 0 d63d 7eff fe97 2290 64 Scope Global inet6 addr bbbb d63d 7eff fe97 2290 64 Scope Global UP BROADCAST RUNNING MULTICAST MTU 1500 Metric 1 RX packets 327 errors 0 dropped 0 overruns 0 frame 0 TX packets 337 errors 0 dropped 0 overruns 0 carrier 0 collisions 0 txqueuelen 1000 RX bytes 68258 66 6 KiB TX bytes 48365 47 2 KiB So we get the new address which is bbbb d63d 7eff fe97 2290 64 As we need a route to access the aaaa 64 network and that can only be forwarded by the bridged eth0 interface in our virtual machine We ma
24. cessing Use interrupts to detect falling moving ADXL345 calculates the vector sum of all 3 axes and compares the vector sum with predefined thresholds We use 313mg for the maximal acceleration and 160ms for the minimal duration The function process_pol1 is used to set the flag needspo11 in the PCB Polling is the way to make a process run from an interrupt The process_pol11 function is the only function in the process module that is safe to call from preemptive mode 5 core sys process c void process_poll struct process p if p NULL if p gt state PROCESS_STATE_RUNNING p gt state PROCESS_STATE_CALLED p gt needspoll 1 poll_requested 1 To send the status information to the web server we modify the callback functions of the interrupts to add status information 23 230 231 232 233 234 235 236 237 238 239 240 241 242 243 245 246 247 248 250 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 examples z1 ipv6 z1 websense c accelerometer free fall detection callback void accm_ff_cb uint8_t reg status FALL process_post xstatus_process status_event NULL accelerometer tap and double tap detection callback void accm_tap_cb uint8_t reg process_post amp status_process status_event NULL if reg amp ADXL345_INT_DOUBLE
25. d is 563 mg also defined in platform dev adx1345 h define ADXL345_THRESH_FF_DEFAULT 0x09 563 mg define ADXL345_TIME_FF_DEFAULT 0220 160 ms The free fall interrupt service routine is called accm_ff_cb This is a callback function It will be called after a free fall interrupt Before using them we need to first register them For example in examples z1 test adx1345 c Register the callback functions for each interrupt ACCM_REGISTER_INT1_CB accm_ff_cb ACCM_REGISTER_INT2_CB accm_tap_cb The macro ACCM_REGISTER_INT1_CB actually points the function pointer accm_int1_cb to the function accm_ff_cb platform z1 dev adx1345 h Macros for setting the pointers to callback functions from the interrupts The function will be called with an uint8_t as parameter containing the interrupt flag register from the ADXL345 That way several interrupts can be mapped to the same pin and be read from the define ACCM_REGISTER_INT1_CB ptr accm_inti1_cb ptr define ACCM_REGISTER_INT2_CB ptr accm_int2_cb ptr The function pointer accm_int1_cb is defined in the accelerometer driver file platform dev adx1345 c The basic process of accelerometer in examples z1 test adx1345 c in the process accel_process PROCESS_THREAD accel_process ev data PROCESS_BEGIN 20 168 169 171 172 173 174 175 176 178 179 180 181 182 183 184 185 186 1
26. detail when you want to use them For example there is an implicit rule for C compilation File names determine which implicit rules are run For example C compilation typically takes a c file and makes a o file So make applies the implicit rule for C compilation when it sees this combination of file name endings To allow make to find a customary method for updating a target file all you have to do is refrain from specifying recipes yourself Either write a rule with no recipe or dont write a rule at all Then make 11 it was parsed 10 11 12 13 14 15 16 17 will figure out which implicit rule to use based on which kind of source file exists or can be made In general make searches for an implicit rule for each target and for each double colon rule that has no recipe A file that is mentioned only as a prerequisite is considered a target whose rule specifies nothing so implicit rule search happens for it Some of the mostly commonly used implicit rules Linking a single object file n is made automatically from n o by running the linker via the C compiler as CC LDFLAGS n o LOADLIBES LDLIBS Compiling C programs n o is made automatically from n c with CC CPPFLAGS CFLAGS c 3 3 8 Debugging Invoke make with n argument to just print out the commands without actually executing them The p argument dumps the internal database including all the variables The debug option can also be
27. e information 4 9 Virtual machine settings for USB Below is my configuration under Linux If you use Windows or Mac OS X host operating systems the configuration of VirtualBox will be slightly different Please consult the VirtualBox user manual on their website You need to be in the vboxusers group to be able to auto detect USB devices in VirtualBox Run 26 1024 1 WEIGHTLESSNESS 2 VECTOR SUM 3 MOTIONLESS 768 4 INITIAL STATUS 512 256 VALUE 256 g 51 101 151 201 SAMPLES 50 s Figure 3 Falling Detection sudo adduser yourname vboxusers Log out and log in again If you need USB 2 0 support you need to install Oracle VM VirtualBox Extension Pack Start VirtualBox in Settings USB enable USB by checking Enable USB controller Then click the icon with a small plus sign and then choose the Silicon Labs Zolertia Z1 0107 This is the USB device for the Z1 motes VirtualBox can use it after it is in the USB filter list 4 10 Flash the Z1 mote through USB Start your Contiki virtual machine with Z1 mote connected by a USB cord The Z1 mote USB port is a simulated serial port with device file named usually dev ttyUSBO Open a terminal and add yourself to the dialout group to have writable access to the USB serial device Run sudo adduser user dialout Then log out and log in to make it effect Open a terminal in Contiki virtual machine run cd contiki examples hello world 27
28. ease note that for the MSP430 targets the vanilla GCC only supports it in version 4 9 or higher There is an MSPGCC project that provides MSP430 target support for old versions like 4 6 3 or 4 7 0 Also only MSPGCC 4 7 0 or higher supports large memory space above 64 kB Also compiling with MSPGCC 4 6 3 does not get the correct serial port output 33 GNU make The Contiki project uses GNU make to manage the compiling process Usually the makefile is called Makefile One makefile can include other makefiles by using include filenames 3 3 1 Rules The basic structure of a makefile is one or multiple rules like the following target prerequisites recipe Each recipe must begin with a tab character This syntax tells make that the characters that follow the tab are to be passed to a subshell for execution The recipe of a rule consists of one or more shell command lines to be executed one at a time in the order they appear There are several different kinds of rules Explicit rules indicate a specific target to be updated if it is out of date with respect to any of its prerequisites Pattern rules uses wildcards instead of explicit filenames Implicit rules are either pattern rules or suffix rules found in the rules database built in to make Static rules are like regular pattern rules except they apply only to a specific list of target files Suffix rules were make s original means for writing general rules They are considered obsol
29. ebserver apps webbrowser Makefile webbrowser platform zi Makefile z1 platform z1 Makefile common cpu msp430 Makefile msp430 AN AN AN O ONS ONS One major makefile is Makefile include It sets several variables ee et Os e 10 Checks if saved target file Makefile target exists If it exists then uses the variable TARGET defined in it The variables TARGET z1 as we set in the target makefile Checks if saved custom file Makefile z1 defines exists If it exists then uses the definitions there Checks whether the OS is Windows or Mac OS X Linux UNIX and set the variable HOST_OS accordingly Sets OBJECTDIR 0bj_z1 Includes core net rime Makefile rime Includes core net mac Makefile mac Includes core net Makefile uip Includes core net rpl1 Makefile rpl Sets target_makefile to platform z1 Makefile zi and includes it It then includes platform z1 Makefile comm further includes cpu msp430 Makefile msp430 In cpu msp430 Makefile msp430 because we do not use IAR it defaults to GCC It then sets the compiling toolchain to the gcc msp430 cross compiler As 13 269 270 271 272 274 275 277 278 253 254 255 256 235 236 237 cpu msp430 Makefile msp430 114 GCC 1 115 CC msp430 gcc 16 LD msp430 gcc 117 AS msp430 as 18 AR msp430 ar 119 NM msp430 nm 120 OBJCOPY msp430 objcopy 121 STRIP msp430 strip 122 BSL msp430 bs1
30. ed by user 130 64 194 8 December 15 2014 at 17 55 08 EST Figure 3 The activity history This is built by Tolga Zeybek 3 The Fall Detector Algorithm 3 1 The accelerometer sensor Accelerations on x y and z axis are detected by the accelerometer sensor These three value will be used for analysing the status of the user Moreover we are going to sum of these three dimension vector by the formula shown below sum of the vector Vx y 22 3 2 The Thresholds We set up 3 thresholds to define the weight of the acceleration values The first threshold value is 5m sec the second one is 16m secand the last one is 22m sec The threshold value is changeable because the effect of the detector on each person will be different The reason why we set 5 16 and 22 is that it gives the best result from the experimental subject 3 3 The Weight of The Data In order to recognise the current human status we give each value a weight The value mentioned here is the sum of the vector Sum of the vector in other word is the detected acceleration on the sensor The code we use to define weight is shown in figure 4 weight define loop private double weight_def Cdouble window int count 0 forCint i 1 i lt BUFF_SIZE 1 i ifCwindow i gt th1 amp amp window i lt th2 count count 1 else ifCwindow i gt th2 88 window i lt th3 count count 3 else ifC window i gt th3 count count 100 else coun
31. ete in GNU make The order of rules is not significant except for determining the default goal the target for make to consider if you do not otherwise specify one The default goal is the target of the first rule in the first makefile If the first rule has multiple targets only the first target is taken as the default GNU make does its work in two distinct phases During the first phase it reads all the makefiles included makefiles etc and internalizes all the variables and their values implicit and explicit rules and constructs a dependency graph of all the targets and their prerequisites During the second phase make uses these internal structures to determine what targets will need to be rebuilt and to invoke the rules necessary to do so When invoking make you usually specify a target as an argument If you do not specify an argument then make will use the default target as the argument The default is the first target that is not started with a dot By convention we use all target although it could be anything 3 3 2 Variables You can define your own variables in your makefile Variables are all global and they can only be used after definition 10 3 3 3 Automatic variables Automatic variables are set by make after a rule is matched Some of the common automatic variables lt The name of the first prerequisite e The file name of target of the rule 7 The name of all the prerequisites with spaces between them
32. f the IMG hack This requires us to write HTTP requests using TCP communication The IMG hack is awkward and slow e There is an interrupt sharing problem prevents us from using more interrupts other than the 3 interrupts provided in the test code Debug and solve the interrupt sharing problem e The falling detection is simple and could be confused with other movements Improve the detec tion algorithm to make it more accurate The falling analysis in section 4 8 is a good direction e The web communication method used in our project is still crude There are standards for more scalable and future proof ways We plan to investigate CoAP method for RESTful web sensor management Acknowledgement We want to thank Prof Chang for his creative idea of movement detection on the 6LoWPAN and Android from which the project was born Tolga Zeybek for his help in web server setting up and Android code study Ruiling Gao for her work on the web server setting up and communication skills And all the classmates of EE193 for their hard work for improving this project and making it a solid platform for future works 30 References 1 Ning Jia Detecting human falls with a 3 axis digital accelerometer Analog Dialogue 43 7 43 50 2009 2 Contiki OS Website Contiki introduction http www contiki os org 2014 3 Zolertia Z1 Website Z1 platform brochure http zolertia com sites default files Zolertia Z1 Brochure pdf 2014 4 Wikipedia
33. hnever a certain movement is detected But as sending HTTP request has not be fully implemented we resort to a hack courtesy to Tolga that exploits the lt img gt tag We use Tolga s web server for this purpose lt img src http tolgazeybek ddns net 8083 devicename Zengxukstatus STATUS gt The implementation is to modify the html header to let it refresh every 3 seconds to auto reload the new sensor status examples z1 ipv6 z1 websense c and the generate_chart function to point to our web server examples z1 ipv6 z1 websense c static void generate_chart void blen 0 ADD lt img src http tolgazeybek ddns net 8083 devicename Zengxuk status s status ADD gt 4 6 Memory map For MSP430 MCUs the addressable memory space is 128 KB As per the hardware manual all MSP430 devices with more than 64 KB memory has a MSP430X core A rough map of MSP430F 2617 RAM 0x1100 0x30FF Flash 0x3100 0x19FFF The interrupt vector space is OxFFCO OxFFFF The reset vector is OxFFFE Because the limited memory in Z1 motes be sure to check your code not to exceed the memory limit Your code can sometimes be optimized if it is too large The website of Contiki introduces several methods for code optimization 4 7 Compile and running We need to first flash the MAC addresses of our motes For example 25 static const char TOP lt html gt lt head gt lt meta http eq
34. ind the SDK manager in Eclipse at Windows gt Android SDK manager 1 3 ANDY Android Emulator ANDY Android Emulator is a software which breaks down the barrier between desktop and mobile computing which means this software lets apps run on the computer We use ANDY to run a sever APK file Here we did not actually build the sever on our computer but use another one built by Tolga Zeybek All of our data is sent to his server 2 Project Network Configuration I J ls Moto G SERVER Figure 1 In figure 1 the Moto G is able to talk to the server directly and the server will save the data sent from Moto G The whole system includes 1 A computer runs the android sever application on ANDY Android Emulator 2 A Moto G runs the fall detector application P S All the devices must connect to the internet The computer is installed the ANDY Android Emulator to run a sever APK which are able to receive massages through the internet from any devices The code of the package sent from Moto G is shown in figure 2 String sendHttpRequest String url String devicename String status 1 StringBuilder returnstring new StringBuilder StringBuilder design_url new StringBuilder try design_url append url append devicename append devicename append amp status append status HttpURLConnection con HttpURLConnection new URLCdesign_url toString openConnection con setRequestMethod POST gt c
35. ld apps for Android phones tablet Android Wear Android TV Android Auto and Google Glass The Virtual Device Manager provides pre defined device profiles for common Android SDK Tools includes the complete set of development and debugging tools for the Android SDK 1 2 Motorola Moto G XT1045 The Motorola Moto G XT1045 Tech specs is shown Motorola Moto G XT1045 Tech specs NETWORK LAUNCH PLATFORM MEMORY FEATURES BATTERY Technology Announced OS Chipset CPU GPU Internal Sensors Messaging Browser Jave Standby GSM HSPA EDGE UMTS HSDPA HSUPA LTE 2014 MAY Android OS v4 4 2 KitKat upgradable to v4 4 4 KitKat Qualcomm MSM8226 Snapdragon 400 Quad core 1 2 GHz Cortex A7 Adreno 305 8 GB 1 GB RAM Accelerometer Proximity Compass and Ambient Light SMS threaded view MMS Email Push Email IM HTML 5 Yes via Java MIDP emulator Li lon 2070 mAh battery 12600 minutes 210 hours 8 8 days Motorola Moto G features a powerful accelerometer sensor a long life battery and a powerful quad core processor The accelerometer sensor provides the acceleration on x y and z axis which are necessary values for analysing human behaviours Plus the 1 2 GHz quad core CPU is able to compute the algorithm vary fast In order to simulating the fall detector on Moto G XT1045 the programer should download Android 4 4 2 API 19 packages from the Android SDK manager You can f
36. n the end the loop will return the total weight of the angle 3 5 Define Human Activities By checking the weight values we are able to define the activities of a person The weight equals to zero we defines the current activity a static activity which includes sitting and standing The way we distinguish sitting and standing is by checking the gravity sensor For example if the gravity sensor says that the device is vertical we are able to say that the user is standing The code is shown in figure 6 if Cweight_sum 0 if Math abs y lt 9 8 curr_state sitting else curr_state standing Figure 6 In addition to the static activity dynamic activity is another state Running and walking are the two statuses in this state The way we distinguish running and walking is by comparing the weight If the weight is bigger than 19 we define the current status is running If the weight is between 19 and 1 we define the current states is walking The code is shown in figure 7 else if weight_sum gt 0 amp amp weight_sum lt 100 if weight_sum gt 19 88 weight_sum lt 100 curr_state running else curr_state walking Figure 7 Last if the weight is over 100 we define the current activity as an extremely dynamic activity which includes jumping and falling The method we used to distinguish jumping and falling is by checking the weight of angle If the weight of angle is bigger than 110 we define it
37. nt it based on the Z1 websense code and ADXL345 test code The Z1 websense is a simple web server running on top of the IPv6 contiki stack on Z1 Main architecture 21 57 58 59 60 61 159 160 161 162 motes to provide sensor values and with a RPL border router to bridge the sensor network to Internet The C source file is examples z1 ipv6 z1 websense c The ADXL345 test code is used for testing the functionality of ADXL345 under Contiki We thus take out the ADXL345 test code and add it to the Z1 websense file to make the accelerometer reading can be visited on the web server We remove the serial shell from the ADXL345 test code as it is too big to fit in the ROM after combining two modules We do not need to change the makefile After compiling and linking a MSP430 ELF file called z1 websense z1 will be generated Let s first analyze this file There are some initialization code at first mostly provided by the compiler then it jumps to the main function provided by platform z1 contiki z1 platform c From the main function all the processes and kernel functions are scheduled and device drivers loaded 4 3 Code implementation There are 3 processes in the movement detection code They are web_sense_process accel_process and status_process They are automatically started after booting the motes examples z1 ipv6 z1 websense c PROCESS web_sense_process Sense Web Demo PROCESS accel_process
38. nually add the routing to the network aaaa 64 used by the 6LOWPAN network sudo sbin route A inet6 add aaaa 64 gw bbbb a00 27ff fe8d 4867 which means we use the eth0 interface in the virtual machine as our gateway to aaaa 64 network Do a ping6 to test it zengxu desktop1 ping6 aaaa 212 7401 1 101 PING aaaa 212 7401 1 101 aaaa 212 7401 1 101 56 data bytes 64 bytes from aaaa 212 7401 1 101 icmp_seq 1 tt1 63 time 8 63 ms 64 bytes from aaaa 212 7401 1 101 icmp_seq 2 tt1 63 time 8 54 ms 64 bytes from aaaa 212 7401 1 101 icmp_seg 3 tt1 63 time 8 23 ms 64 bytes from aaaa 212 7401 1 101 icmp_seq 4 tt1 63 time 7 89 ms 2 5 Analyze packets using Wireshark In Cooja click Tools Radio Messages Analyzer choose 6LOWPAN Analyzer with PCAP This will generate a PCAP file which is the traffic log of all the packets After finishing running your simulation open Wireshark then open the PCAP file under the directory home user contiki tools build We can then use Wireshark to check every packet with detailed information on all layers For the neighbor discovery and RPL protocols Wireshark can be used to analyze the ICMPv6 RPL Control packets for example DIS DIO DAO packets 3 Compiling a Contiki program 3 1 Contiki version There are 2 Contiki versions in the Instant Contiki virtual machine 2 6 in home user contiki and 2 7 in home user contiki 2 7 3 2 GCC compiler We use GCC to compile Contiki Pl
39. on setDoInput true con setDo0utput true con connect InputStream is con getInputStream byte b new byte 2 while C is read b 1 returnstring append new String b Log wC inputstream returnstring toString con disconnect Jcatch Exception e t return returnstring toString Figure 2 The code of the sending package The code is provided by Tolga Zeybek The package includes the device name status of the user client IP and the uploaded time When the sever received the package it will update it s data base The data is shown in figure 3 and at http tolgazeybek ddns net 8083 item less motorola_XT1045_Tolga_Zeybek sitting 130 64 22 2 December 15 2014 at 18 02 14 EST motorola __XT1045_Tolga _Zeybek small motion 130 64 22 2 December 15 2014 at 18 02 09 EST motorola_XT1045_Tolga_Zeybek walking 130 64 22 2 December 15 2014 at 18 02 09 EST motorola_XT1045_Tolga_Zeybek small motion 130 64 22 2 December 15 2014 at 18 02 08 EST motorola_XT1045_Tolga_Zeybek walking 130 64 22 2 December 15 2014 at 18 02 06 EST motorola_XT1045 Tolga_Zeybek small motion 130 64 22 2 December 15 2014 at 18 02 03 EST OnePlus_A0001_Tolga_Zeybek standing 130 64 194 8 December 15 2014 at 17 56 08 EST OnePlus_A0001_Tolga_Zeybek sitting 130 64 194 8 December 15 2014 at 17 55 17 EST OnePlus_A0001_Tolga_Zeybek User requested help 130 64 194 8 December 15 2014 at 17 55 16 EST OnePlus_A0001_Tolga_Zeybek Fall verifi
40. ople communicate Internet is based on the TCP IP protocol suite With TCP IP protocol suite a lot of heterogeneous networks can talk with each other IPv6 is the next generation of Internet that greatly expands the current IPv4 based protocols As IPv4 has only 32 bit addresses it cannot deal with the exponential expansion of Internet especially the demand of Internet of Things of connecting a large number of nodes IPv6 has 128 bit addresses and can support nearly infinite number of connected nodes The TCP IP protocol is also demanding for the embedded systems It often requires an operating system to run the full protocol suite and it needs more resources than most of the inexpensive low power embedded systems Nonetheless the benefit of running TCP IP protocol suite on those systems is great as it is the most widely supported and expandable network protocol The 6LoWPAN is an IETF standard that tries to resolve this conflict It is well suited to resource limited embedded systems that can be used for Internet of Things 6LoWPAN has a similar layered structure as the TCP IP protocol suite as shown in Figure 1 1 3 Contiki Contiki is open source software Contiki can be freely used both in commercial and non commercial systems and the full source code is available Contiki provides powerful low power Internet communication Contiki supports fully standard IPv6 and IPv4 along with the recent low power wireless standards 6LoWPAN RPL Co
41. p6 is used to connect the border router to the outside world As we run make connect router it actually executes sudo CONTIKI tools tunslip6 aaaa 1 64 The tunslip6 is compiled from tools tunslip6 c Let s analyze this file It does such things 1 Sets default parameters baud rate as 115200 no flow control 2 Parses command line options and set parameters accordingly Like baud rate host name device file etc 3 As we do not provide host address here unlike in Cooja it tries to open dev ttyUSBO by calling devopen 4 Calls stty_telos to set parameters for the opened serial device 4 Movement detection on Z1 motes 4 1 ADXL345 accelerometer The ADXL345 accelerometer is produced by Analog Devices It is a small thin ultralow power 3 axis accelerometer with high resolution 13 bit measurement at up to 16 g ADXL345 has several interrupts that look interesting There are single tap and double tap interrupts and a free fall interrupt that is generated when there is a free fall detected also activity and inactivity interrupts for detecting moving and non moving The registers and interrupts are defined as platform z1 dev adx1345 h Reference definitions should not be changed adzl345 slave address define ADXL345_ADDR 0253 ADXL345 registers define ADXL345_DEVID 0x00 read only registers Ox01 to 0x1C are reserved do not access 18 193 194 195 19
42. r that runs Linux operating system 2 An Oracle VirtualBox virtual machine runs on the Linux computer 3 One Z1 mote that is connected to the computer using a USB cord It is used as a border router 4 One Z1 mote wirelessly connected to the border router We install a Oracle VirtualBox virtual machine that runs Instant Contiki on the Linux computer The Instant Contiki is a Contiki development environment that consists of 1 32 bit Ubuntu 12 04 Linux operating system 2 MSPGCC 4 7 0 toolchain for compiling system library and linking 3 OpenJDK for compiling and running Cooja simulator 4 Python for running Contiki tools 5 GNU make for project management 6 Contiki 2 6 and 2 7 source code 7 Cooja simulator 2 2 Configure the virtual machine network The best way to access the virtual machine remotely is configuring the virtual machine network to bridged mode We use VirtualBox as our virtual machine The default network configuration is NAT mode Go to Devices Network Network Settings Adapter 1 beside Attached to choose Bridged Adapter Beside Name choose the interface that you use to get online for your computer Normally it is wlan0 for wireless and eth0 for wired Also check the Cable Connected This should be done before running the Ubuntu 12 04 guest OS 2 3 Setting up virtual machine guest OS Z1 motes are accessed through the border router In Cooja we use the SLIP pro
43. t 0 return count Figure 4 The weight code Window is an array which saves 50 values of sum of the vector The parameters thl th2 and th3 are the thresholds 5 16 22 sequentially By comparing the data with thresholds we are able to give each data a weight In the code if the data is less than 5 we do not add weight to the data If the data is bigger than 5 but less than 16 we add 1 to its weight Moreover if the data is between 16 and 22 we add 3 Last if the data is over 22 we add 100 to the weight 3 4 The Weight of Angle If the angle between the Moto G and the ground is between 60 and 90 degrees we add 3 to the angle s weight otherwise we add 1 This means the Moto G is currently at a vertical status The formula we sind yl y 1 y 22 use here is the sin formula The range of sin theta is between 0 and 1 because we set the y value as an absolutely value The code of the weight of angle is shown in figure 5 define angle weight private double compute_anglevalue double savedangle2 int acount 0 for Cint i 1 i lt BUFF_SIZE 1 1 4 ifCsavedangle2 i signed_sin gt 0 acount acount 3 else acount acount 1 return acount Figure 5 The code of the weight angle The parameter signed_sin is the value of sin 60 which is 0 866 and the savedangle2 is an array which saves the sin value of the data This loop will compare each data to signed_sin and count the weight I
44. tocol to establish a point to point connection to the Internet by executing cd home user contiki examples ipv6 rpl border router make connect router cooja TARGET sky It adds a virtual network interface called tun0 At the end of this command we are providing a prefix of aaaa 1 64 which enables the device to pick its own IPv6 address using Stateless Address Auto configuration SLAAC It is important to note that this means the prefix needs to use a 64 mask When first connected to a network a host sends a link local router solicitation multicast request for its configuration parameters routers respond to such a request with a router advertisement packet that contains Internet Layer configuration parameters On Ubuntu 12 04 in the virtual machine edit file etc sysctl conf by running sudo nano etc sysctl conf uncomment the line remove the starting net ipv6 conf all forwarding 1 to enable IPv6 packet forwarding Then run sudo sysctl p sudo nano etc radvd conf This creates an empty file Copy interface eth0 4 Send advertisement messages to other hosts AdvSendAdvert on IPv6 subnet prefix prefix bbbb 64 AdvOnLink on AdvAutonomous on to the file and execute sudo etc init d radvd start It then starts normally After radvd is started all computers on the same LAN with our computer that Cooja runs receive the advertised router information and auto configure their IPv6 addresses with prefix bbb
45. ttern and it has its own pattern rule Veta fc TRACE_CC Q CC CFLAGS DAUTOSTART_ENABLE c lt o 0 14 87 83 226 228 162 24 243 244 245 This pattern rule compiles the object files from C source files So in this example it compiles the object file zi websense co from zi websenso c Please note that this rule defines a macro AUTOSTART_ENABLE as its compiling argument This enables the autostart processes in the z1 websense c to be defined as not empty For further explanations please see section 4 3 The second one is PROJECT_OBJECTFILES This is defined as PROJECT_OBJECTFILES addprefix OBJECTDIR call oname PROJECT_SOURCEFILES where oname is a variable defined as oname patsubst c 0 patsubst S 0 1 which means substitute any file n c orn S ton o As we defined PROJECT_SOURCEFILES httpd simple c we then have PROJECT_OBJECTFILES 0bj_z1 httpd simple o Then we use the pattern rule A fee TRACE_CC Q CC CFLAGS c lt o 0 to compile httpd simple c to obj_z1 httpd simple o As httpd simple c is not in the current di rectory make uses the search path defined in vpath to find it Actually it is in examples ipv6 rpl border router But in cpu msp430 Makefile msp430 this variable is appended as PROJECT_OBJECTFILES addprefix OBJECTDIR CONTIKI_TARGET_MAIN c 0 The c o
46. uiv refresh content 3 gt lt tiltle gt Contiki Web make clean make burn nodeid upload nodeid 158 nodemac 158 make zi reset amp amp make login Every mote should have a unique address Then we flash the border router cd examples ipv6 rpl border router make TARGET z1 savetarget make border router upload make connect router A virtual network interface tun0 will be created Then under the contiki virtual machine open a terminal run cd contiki examples z1 ipv6 z1 websense make TARGET z1 savetarget make z1 websense upload make zi reset amp amp make login This flashes the Z1 mote that is used for movement detection and runs the application 4 8 Falling detection patterns A real falling is a movement that has a distinct pattern 1 There are 4 stages in a falling movement as shown in the 4 red boxes in Figure 3 1 Start of the fall The vector sum of acceleration will be significantly less than 1 g 2 Impact After experiencing weightlessness the human body will impact the ground or other objects There will be a large spike of acceleration 3 Aftermath After falling there will generally be a period of motionless 4 Comparing before and after After a fall the individual s body will be in a different orientation than before so the static acceleration in three axes will be different from the initial status before the fall We can get a more accurate falling detection algorithm if we can use all the abov
Download Pdf Manuals
Related Search
Related Contents
STW 5-7 Programmable Mode d'emploi 取扱説明書 設置・運転編 Dynamode Skype Stereo backheld headphone with Mic. CARTE DE VULNÉRABILITÉ CARTE DE - Infoterre American Idol Super Star Service Manual ver 1.70 Ilumipanel™ 24g2 IP User Manual Rev. 2 Vodafone 550 Benutzerhandbuch 取扱説明書(PDF) Viewsonic EP4610 Copyright © All rights reserved.
Failed to retrieve file