• Like
Introduction To SPOT
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

Introduction To SPOT

  • 5,185 views
Published

Share is good. if youhave any question, feel free to ask me: pdeng -a- pgrad dot unimelb dot edu dot au.

Share is good. if youhave any question, feel free to ask me: pdeng -a- pgrad dot unimelb dot edu dot au.

Published in Business , Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
5,185
On SlideShare
0
From Embeds
0
Number of Embeds
14

Actions

Shares
Downloads
111
Comments
0
Likes
1

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Introduction to SPOT Programming the Real-world Peng Deng pdeng@students.csse.unimelb.edu.au ∑ SUM Lab CSSE University of Melbourne
  • 2. Agenda • Introduction – Sensor Architecture – WSN Characteristics – WSN Applications • SPOT – What is SPOT – Microsoft vs. Sun • Sun SPOT – Applications – Hardware features and code samples • Conclusion • Q&A and Demos • Reference 2
  • 3. Introduction: Sensor Networks • WSN (Wireless Sensor Network) is a wireless network consisting of spatially distributed autonomous devices using sensors to cooperatively monitor physical or environmental conditions. [1] 3
  • 4. Architecture of Sensor [2] Limited Memory Limited Lifetime Sensing Processing Communication Element Element 1 kbps – 1 Mbps, 3 – 100 m, Lossy Transmission S MEMORY P S R E O U A A N W P D D S E P C MICRO I O R L PROCESSOR O R Y S Require ALGORITHMS Supervision Slow Processing REAL TIME OS 4
  • 5. Characteristics of WSN [1] • Small-scale sensor nodes • Limited power they can harvest or store • Harsh environmental conditions • Node failures • Mobility of nodes • Dynamic network topology • Communication failures • Heterogeneity of nodes • Large scale of deployment • Unattended operation 5
  • 6. Application Domain [2] • Environmental monitoring • Security • Defence • Bioinformatics and health • Transportation management • Chemical detection and emergency response Pictures from [3] 6
  • 7. Learn more about WSN… • 433-654 Sensor Networks and Applications • The subject is provided every semester 1 • Lecturer is Dr Egemen Tanin 7
  • 8. SPOT • What is SPOT? Microsoft Version Smart Personal Objects Technology Sun Version Small Programmable Object Technology – According to my understanding, SPOT is a technology that pushes popular desktop application frameworks and programming languages to embedded systems. 8
  • 9. SPOT Cake Applications Microsoft .Net Micro Framework Sun Java Squawk Virtual Machine OS Freescale TI ARM Different hardware … chips chips chips platforms Advantages: Disadvantages: 1. Much more portable 1. Less flexibility code 2. More resource needed 2. Easier to learn • Memory 3. Free to use • CPU • Battery 4. Rapid develop 5. Safer 3. Slower execution speed 9
  • 10. .Net Micro Framework [4] 10
  • 11. .Net Micro Framework [4] Version 2.0 BETA First release Open source Open to partners only http://msdn2.microsoft.com/en-us/embedded/bb404168.aspx Language C# IDE Visual Studio 2005 Express Edition is not available Bootable Yes Work with or without OS User interface WPF Without XAML For Windows Sidebar Real-time Real- No Emulation Yes Not known for sensor environment Executable file Metadata Metadata Processor reduces size of assemblies Platform ARM7 and ARM9 Minimum RAM 300KB Minimum Flash 1MB Communication USB or Serial Security Signed application Public- private key pair XTEA Symmetric key RSA 11
  • 12. Squawk Virtual Machine [5] A Java Virtual Machine written in Java! Extended from J2ME 12
  • 13. Squawk Virtual Machine [6] [7] Version Codename: Orange, Purple Second release (CLDC 1.1-compatible) Open source Source code available in SDK Open source in future Language Java IDE NetBeans 5.0 Companion with NetBeans module Free Bootable Yes Work with or without OS User interface No Real-time Real- No Emulation No Executable file Optimized bytecode Support process migration .suit 35% - 45% size of equivalent J2ME class files Multiple applications run concurrently Platform ARM7 and ARM9 Minimum RAM 80KB Minimum Flash 380KB Communication USB or Serial Security Signed application, RSA 13
  • 14. Sun SPOT [7] [8] Framework Sun Java Squawk VM Programming Language Java IDE NetBeans 5.0 Platform Sun SPOT Battery capacity 720 mAh lithium-ion battery Deep sleep 32 uA CPU 180 MHz 32 bit ARM920T Memory 512K RAM/4M Flash Radio 2.4 GHz IEEE 802.15.4 radio with integrated antenna Embedded sensors • 3-axis accelerometer • Temperature sensor • Light sensor • LEDs • Analog inputs • Switches • General purpose I/O 14
  • 15. Crossbow Imote2 [9] [10] Framework Microsoft .Net Micro Framework Programming Language C# IDE Visual Studio 2005 Platform Imote2 Battery capacity N/A Deep sleep 390 uA CPU PXA271 XScale® Processor at 13–416MHz Memory 256kB SRAM, 32MB FLASH, 32MB SDRAM Radio Integrated 802.15.4 Radio Embedded sensors Daughter board: IIB2400 – Imote2 Interface ITS400 sensor board • 3-Axis Accelerometer • Temperature, Humidity, • and Light Sensors • Analog Input 15
  • 16. Sun SPOT 16
  • 17. Sun SPOT Applications [7] 17
  • 18. Sun SPOT Hardware [7] [11] 2.4 GHz IEEE 802.15.4 Radio Antenna Module 180 MHz 32 bit 512K RAM ARM920T core 4M Flash USB interface with Daughter board mini-B connector connector Power Switch 18
  • 19. Sun SPOT Hardware [7] [11] 8 3-colors LEDs Push Buttons Light Sensor 3-D Accelerometer Analog in 4-5 Temperature sensor and A/D Converter Digital I/O 0-3 Analog in 0-3 Push Buttons Digital I/O 4 quot;Highquot; current output 0-3 Replicated here 19
  • 20. Time Issues [19] [14] • Timer and Counter – Chip: AT91 Timer/Counter * 2 on ARM920T @ Processor Board – 6 Timer Counter Channel = 4 available + 2 system use – 2 modes: Capture & Waveform – Functions: frequency measurement, event counting, interval measurement, pulse generation, delay timing and pulse width modulation. – Interface defined at com.sun.spot.peripheral.TimerCounterBits.java • Time Synchronization – Affect security if the time difference is more than 3 minutes – 3 minutes off after 104 days – Synchronize time when connect SPOT to Host using USB 20
  • 21. Time issues: Example 1 • Measuring a Time Interval import com.sun.spot.peripheral.*; import com.sun.spot.util.*; public class TimerCounterSample implements TimerCounterBits { public double measureInterval() { IAT91_TC timer = Spot.getInstance().getAT91_TC(0); // Get a Timer Counter timer.configure(TC_CAPT | TC_CLKS_MCK32); // Use fast clock speed timer.enableAndReset(); // Start counting ... interval to measure ... int cntr = timer.counter(); // Get number of elapsed clock ticks timer.disable(); // Turn off the counter double interval = cntr * 0.5342; // Convert to time in microseconds return interval; } } 21
  • 22. Time issues: Example 2 • Perform a Periodic Task import com.sun.spot.peripheral.*; import com.sun.spot.util.*; public void periodicTask() { IAT91_TC timer = Spot.getInstance().getAT91_TC(0); // Get a Timer Counter int cnt = (int)(25000 / 0.5342); // number of clock counts for 25 msecs timer.configure(TC_CAPT | TC_CPCTRG | TC_CLKS_MCK32); // enable RC compare timer.setRegC(cnt); timer.enableAndReset(); while (true) { // Start periodic task loop timer.enableIrq(TC_CPCS); // Enable RC Compare interrupt timer.waitForIrq(); // Wait for interrupt timer.status(); // Clear interrupt pending flag doTask(); // Method will be called every 25 msecs } } 22
  • 23. Memory • Spansion S71PL032J40 • 512K RAM – Garbage Collector in VM – 0x20000000 to 0x20080000 • 4M Flash – 0x10000000 to 0x10400000 Start Address Size Use Remarks 0x10010000 256Kb Squawk VM executable Large compare to TinyOS 0x10140000 384Kb Application slot 1 Your application is deployed here. Error throws if application too big. 0x101A0000 384Kb Application slot 2 0x10200000 ≈ 2Mb Available for data storage 23
  • 24. Memory: Access to Flash • Record Management System 1. RecordStore rms = RecordStore.openRecordStore(quot;TESTquot;, true); 2. byte[] inputData = new byte[]{12,13,14,15,16}; 3. int recordId = rms.addRecord(inputData, 0, inputData.length); 4. byte[] outputData = rms.getRecord(recordId); 5. rms.closeRecordStore(); • IFlashMemoryDevice (low level) 1. /* use stream to read and write is safer. */ 2. IFlashMemoryDevice mem = Spot.getInstance().getFlashMemoryDevice(); 3. IFlashMemoryDevice mem = Spot.getInstance().getFlashMemoryDevice(); 4. int startSector = mem.getFirstAvailableSector(); 5. DataOutputStream dos = new DataOutputStream(mem.getOutputStream(startSector, 2)); 6. dos.writeUTF(quot;hello therequot;); 7. dos.flush(); 8. DataInputStream dis = new DataInputStream(mem.getInputStream(startSector, 2)); 9. String s = dis.readUTF(); 24
  • 25. Radio • ChipCon CC2420 • PAN (802.15.4) – ISM band 2.4GHz – Zigbee is not implemented yet, but you can built it by yourself • Address – IEEE extended MAC Address – 64 bit, like 0014.4F01.0000.026A • Ports – 0~255 – 0~31 are reserved for system use 25
  • 26. Radio • Radio Stream – Stream-based – Reliable (acknowledgement) – Buffered – P2P • Radiogram – Datagram-based – No guarantees about delivery or ordering – Broadcast supported – C/S – Stream like but limit in size 26
  • 27. Radio Stream • Radio Stream 1. RadiostreamConnection conn = (RadiostreamConnection) Connector.open(quot;radio://0014.4F01.0000.0006:100quot;); 2. DataInputStream dis = conn.openDataInputStream(); 3. DataOutputStream dos = conn.openDataOutputStream(); 4. try { 5. dos.writeUTF(quot;Hello up therequot;); 6. dos.flush(); // send over the air 7. System.out.println (quot;Answer was: quot; + dis.readUTF()); 8. } catch (NoRouteException e) { 9. System.out.println (quot;No route to 0014.4F01.0000.0006quot;); 10. } finally { 11. dis.close(); 12. dos.close(); 13. conn.close(); 14. } 27
  • 28. Radiogram • Client 1. RadiogramConnection conn = RadiogramConnection)Connector.open(quot;radiogram://0014.4F01.0000.0006:100quot;); 2. Datagram dg = conn.newDatagram(conn.getMaximumLength()); 3. try { 4. dg.writeUTF(quot;Hello up therequot;); 5. conn.send(dg); 6. conn.receive(dg); 7. System.out.println (quot;Received: quot; + dg.readUTF()); 8. } catch (NoRouteException e) { 9. System.out.println (quot;No route to 0014.4F01.0000.0006quot;); 10. } finally { 11. conn.close(); 12. } 28
  • 29. Radiogram • Server 1. RadiogramConnection conn = (RadiogramConnection) Connector.open(quot;radiogram://:100quot;); 2. Datagram dg = conn.newDatagram(conn.getMaximumLength()); 3. Datagram dgreply = conn.newDatagram(conn.getMaximumLength()); 4. try { 5. conn.receive(dg); 6. String question = dg.readUTF(); 7. dgreply.reset(); // reset stream pointer 8. dgreply.setAddress(dg); // copy reply address from input 9. if (question.equals(quot;Hello up therequot;)) { 10. dgreply.writeUTF(quot;Hello down therequot;); 11. } else { 12. dgreply.writeUTF(quot;What???quot;); 13. } 14. conn.send(dgreply); 15. } catch (NoRouteException e) { System.out.println (quot;No route to quot; + dgreply.getAddress()); } finally { 16. conn.close(); 29 17. }
  • 30. Radiogram • Broadcast – Transmitted over two hops by default – Not reliable – Drop duplicated message 1. DatagramConnection conn = DatagramConnection)Connector.open(quot;radiogram://broadcast:<portnum>quot;); 2. ((RadiogramConnection)conn).setMaxBroadcastHops(3); 30
  • 31. Sensors • 2G/6G 3-axis accelerometer • Temperature sensor • Light sensor • 8 tri-color LEDs • 2 momentary switches • 6 analog inputs • 5 general purpose I/O pins and 4 high current output pins 31
  • 32. 3-axis Accelerometer Wii Remote Controller [17] Sun SPOT [18] Chip Analog Devices ADXL330 ST Microsystems LIS3L02AQ Price USD $8.97 USD $10.82 Range & Sensitivity +/- 3 G (300 mv/g) +/- 2G (600 mv/g) +/- 6G (200 mV/g) Power consumption 300 uA @ ~3V 850 uA @ 3.3 V Sleep mode support Acceleration Noise Density 50 µg / Hz 250~300 µg / Hz Purpose Carefully tuned to optimize performance General purpose. in determining hand and arm motion Depends on developers’ implementation 32
  • 33. 3-axis Accelerometer 1. import com.sun.spot.sensorboard.EDemoBoard; 2. import com.sun.spot.sensorboard.peripheral.IAccelerometer3D; 3. private IAccelerometer3D accel = EDemoBoard.getInstance().getAccelerometer(); 4. int tiltX = (int)Math.toDegrees(accel.getTiltX()); // returns [-90, +90] 5. double GForceX = accel.getAccelX(); 33
  • 34. Temperature sensor • Analog Devices ADT7411 • -40℃ to +125 ℃ • Accuracy±0.5 ℃ • Actually, it is reading the temperature of this chip • Warmer when you connect to USB • Connect a external thermistor to A/D to get more accurate reading 34
  • 35. Temperature sensor 1. import com.sun.spot.sensorboard.EDemoBoard; 2. import com.sun.spot.sensorboard.io.ITemperatureInput; 3. private ITemperatureInput tempSensor = EDemoBoard.getInstance().getADCTemperature(); 4. double tempF = tempSensor.getFahrenheit(); // The value converted to Farenheight 5. double tempC = tempSensor.getCelsius(); // The value converted to Celcius • The API will change to getADCTemperature(). () 35
  • 36. Light sensor • Toshiba TPS851 • Peak sensitivity wavelength is 600nm • Too sensitive, flickering • Take off “sun roof” to get more accurate reading 36
  • 37. Light sensor 1. import com.sun.spot.sensorboard.EDemoBoard; 2. import com.sun.spot.sensorboard.peripheral.ILightSensor; 3. private ILightSensor lightSensor = EDemoBoard.getInstance().getLightSensor(); 4. int lightLevel = lightSensor.getValue(); 37
  • 38. 8 tri-color LEDs 1. /* i is the index of each LED, from 0 to 7. */ 2. import com.sun.spot.sensorboard.EDemoBoard; 3. import com.sun.spot.sensorboard.peripheral.ITriColorLED; 4. import com.sun.spot.sensorboard.peripheral.LEDColor; 5. private ITriColorLED [] leds = EDemoBoard.getInstance().getLEDs(); 6. leds[i].setOff(); // turn off LED 7. leds[i].setRGB(int red, int green, int blue ); // set color 8. leds[i].setColor(LEDColor.MAGENTA); 9. leds[i].setOn(); // turn on LED 38
  • 39. 2 Momentary Switches 1. import com.sun.spot.sensorboard.EDemoBoard; 2. import com.sun.spot.sensorboard.peripheral.ISwitch; 3. private ISwitch sw1; 4. sw1 = EDemoBoard.getInstance().getSwitches()[0]; 5. startSW1WatchThread(); 6. public void startSW1WatchThread(){ In next major update, the switch API 7. Runnable r = new Runnable(){ 8. public void run(){ will change to buttonListener like. 9. while(true){ 10. sw1.waitForChange(); 11. if(sw1.isClosed()){ 12. System.out.println(quot;Switch 1 closed.quot;); 13. } else { 14. System.out.println(quot;Switch 1 opened.quot;); 15. } 16. } 17. } 18. }; 19. (new Thread(r)).start(); 20. } 39
  • 40. Networking [11] • Using basestation 802.15.4 radio Sun SPOT Sun SPOT Host USB (“base station mode”) (“target”) Over the Air deploy • Mesh routing – Act as a mesh router, forwarding packets to other SPOTs – Enabled when you start radio connection • Trace route – Act as a trace route server – Participate in route tracing request • Logging – Diagnostic use – Display all network route discovery and route management activity • You can implement algorithms by your hand 40
  • 41. Battery [12] • The most important property in WSN! – Radio communication is very hungry – Multi-hop communication is desired • 3.7V 720 mAh lithium-ion battery Sun SPOT State Battery life estimate Deep sleep 909 days Shallow sleep, no radio 23 hours Shallow sleep, radio on 15 hours CPU busy, no radio 8.5 hours CPU busy, radio on 7 hours Shallow sleep, 8 LEDs on, no radio 3 hours 41
  • 42. Battery [20] 1. IPowerController ipc = Spot.getInstance().getPowerController(); 2. ipc.getVbatt(); // The reply is in millivolts and is nominally inthe range 2700- 4700 3. ipc.getIdischarge(); // current being drawn from the battery in mA 4. ipc.getIcharge(); // charging current in mA 5. ipc.getIMax(); // maximum current drawn from the battery since last time this was called • One solution to short battery: – Attach SUN SPOT to a USB charger on the wall, tradeoff is mobility. 42
  • 43. SDK and develop steps 1. Install JDK, Neteans, Sun SPOT SDK and drivers 2. Create Sun SPOT project or Sun SPOT Host project 3. Compose your application 4. Connect, compile and deploy application to SPOT 5. Working! Get more information on http://www.sunspotworld.com/ 43
  • 44. Conclusion • Suitable: – Rapid prototype development – Experiment – Education • Not ready to commercial solution – Lacks support – Constraints • Future development – Open source – Get support from sensor providers like J2ME supported by mobile phone Companies – … 44
  • 45. Q&A
  • 46. Demos Pictures from [15] [16] 46
  • 47. Appreciate • Dr. Lars Kulik (http://www.csse.unimelb.edu.au/~lars/) • Dr. Egemen Tanin (http://www.csse.unimelb.edu.au/~egemen/) • All members in SUM Research Lab (http://www.sumlab.net/) 47
  • 48. Reference 1. Wireless sensor network. (2007, July 25). In Wikipedia, The Free Encyclopedia. Retrieved 08:10, July 28, 2007, from http://en.wikipedia.org/w/index.php?title=Wireless_sensor_network&oldid=146970785 2. Digest from Egemen’s slides in 433-654, http://www.cs.mu.oz.au/654/, et_week1a.ppt 3. David E. Culler and Hans Mulder (2004, June). Smart Sensor to Network the World. Scientific American, 85-91. 4. Microsoft .NET Micro Framework White Paper. Retrieved 08:30, July 28, 2007, from http://download.microsoft.com/download/a/9/c/a9cb2192- 8429-474a-aa56-534fffb5f0f1/.net%20micro%20framework%20white%20paper.doc 5. SquawkVM, Retrieved 08:40, July 28, 2007, from http://research.sun.com/projects/squawk/figures/SquawkVM.jpg 6. Squawk homepage, Retrieved 08:50, July 28, 2007, from http://research.sun.com/projects/squawk/ 7. projectsunspot, Retrieved 08:55, July 28, 2007, from http://www.flickr.com/photos/projectsunspot/ 8. Project Sun SPOT Product, Retrieved 09:00, July 28, 2007, from http://www.sunspotworld.com/products/ 9. WSN .Imote2 Builder, Retrived 09:10, July 28,2007, from http://www.xbow.com/Products/Product_images/Wireless_images/Imote2_Kit.jpg 10. IPR2400 Datasheet, Retrived 09:13, July 28, 2007, from http://www.xbow.com/Products/Product_pdf_files/Wireless_pdf/Imote2_Datasheet.pdf 11. Sun SPOT SDK Version Orange, Developers’ Guide 12. Sun SPOT SDK Version Orange, Owners Manual 13. Sun SPOT SDK Version Orange, CodeSamples 14. Synchronizing time between spot and host, Retrieved 12:00, July 28, 2007, from http://www.sunspotworld.com/forums/viewtopic.php?t=557&start=0&postdays=0&postorder=asc&highlight= 15. Balance.org, shotsbig_01.jpg, Retrieved 13:09, July 30, 2007 from http://www.ballance.org/ImagesX/shots/shotsbig_01.jpg 16. Robert Kooima, screen-5.jpg, Retrieved 13:11, July 30, 2007 from http://offload2.icculus.org/neverball/screen-5.jpg 17. ADXL330 Small, Low Power, 3-Axis ±3g iMEMS® Accelerometer, Analog Device Inc. Retrived 10:28, 8 Aguuest, 2007, from http://www.analog.com/en/prod/0,2877,ADXL330,00.html 18. LIS3L02AQ3 DataSheet, ST Microsystems Inc. Retrived 10:30, 8 Aguuest, 2007, from http://www.st.com/stonline/products/literature/ds/11020/lis3l02aq3.pdf 19. Using the AT91 Timer/Counter, Ron Goldman, Sun Labs, Retrived 21:52, 8 March, 2008 from https://www.sunspotworld.com/docs/AppNotes/TimerCounterAppNote.pdf 20. black.jpg, http://www.trekstor.de/, Retrieved 22:18, 8 March, 2008 from http://www.trekstor.de/dyn_files/products/usb- charger_em/detail/black.jpg 48
  • 49. Thank you Peng Deng MEDC Student SUM Research Lab CSSE University of Melbourne pdeng@students.csse.unimelb.edu.au 49
  • 50. Revision History 8 Aug 2007 Initial Version 8 March 2008 Added: Timer and Counter Modified: Battery 50