42
1 Angad Singh Sun Campus Ambassador blogs.sun.com/angad 1 Programming the world Programming the world with Sun SPOTS with Sun SPOTS

Sun Spot Talk

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Sun Spot Talk

1

Angad SinghSun Campus Ambassadorblogs.sun.com/angad

1

Programming the world Programming the world with Sun SPOTSwith Sun SPOTS

Page 2: Sun Spot Talk

2

The Squawk Java VM

What is Sun SPOT?

Agenda

Coding a SPOT

RoboControl

Sun SPOT Demo

Page 3: Sun Spot Talk

3

What is a Sun SPOT?

• A hardware and sofware research platform• A small, battery operated, wireless device running the Squawk Java Virtual Machine (VM) without an underlying OS.• On-board sensor board Accelerometer, Light Sensor, Temperature Sensor, I/O pins• The Sun SPOT development kit can be purchased at www.sunspotworld.com

Page 4: Sun Spot Talk

4

What is Sun SPOT?• A Java platform for developing

applications for wireless networks and small devices

• Applications such as:> Robotics> Art> Toys> Personal electronics> Commercial Applications> Telemetries

Page 5: Sun Spot Talk

5

Why SunSPOTs?• Too many low-level

concerns in current WSN systems• 4x more productive in

Java than in C• Allows the developer to

focus on application functionality and features

Page 6: Sun Spot Talk

6

Why Sun SPOT?• Abstraction of low level details through VM• Protection of hardware by VM> Memory protection from bad code> Security protection from malicious code

• 802.15.4 wireless communication> upto 250Kbps, ZigBee support> adhoc, mesh, cluster tee and star topologies.

• A simple device with sensors and wireless operates at low power

Page 7: Sun Spot Talk

7

What did Sun Labs come up with?• Powerful mid-level

device:> Space for exploratory

programming> Allow processing of data

on node to reduce network traffic

> Enable over-the-air-programming

Page 8: Sun Spot Talk

8

The anatomy of a SunSPOT• The device has three

layers:> Battery> ARM based processor

board with wireless radio> Add-on sensor board

• Processor board acts as basestation• User programs the

device in Java using NetBeans

Page 9: Sun Spot Talk

9

SunSPOT Hardware• Processor board> 180 MHz 32 bit ARM920T core - 512K RAM/4M Flash> 2.4 GHz 802.15.4 ZigBee radio with integrated antenna> USB interface> 3.7V rechargeable 720 mAh lithium-ion battery

• Sensor board> 2G/6G 3-axis accelerometer> Light and temperature sensor> 8 tri-color LEDs, 2 momentary switches> 6 analog inputs, 5 general purpose I/O pins and 4 high

current output pins

Page 10: Sun Spot Talk

10

You need 2 spoons of java...• SunSPOT Software

Development Kit> Orange ver. 2.0> Purple ver. 3.0 in beta> Green ver. 1.0 (old)

• Java• Ant• NetBeans (works both

with 5.5 and 6.0)

Page 11: Sun Spot Talk

11

Sun SPOT Software Development Kit• Squawk Java VM: Desktop and Sun SPOT• Libraries> Java ME CLDC 1.1 libraries> Hardware libraries

– SPI, AIC, TC, PIO drivers all written in the Java programming language

– Demo sensor board library> Wireless layer libraries> Network layer libraries

– 802.15.4 MAC layer written in Java> Desktop libraries

Page 12: Sun Spot Talk

12

The Squawk Java VM

What is Sun SPOT?

Agenda

Coding a SPOT

RoboControl

Sun SPOT Demo

Page 13: Sun Spot Talk

13

What is squawk?• Another Sun Labs project• A java JVM written in java• Now open source (January

23rd 2008)• Inspiration from Squeak, a

Smalltalk environment written in Smalltalk• New home on the net https://

squawk.dev.java.net/

Page 14: Sun Spot Talk

14

The Squawk virtual machine

Page 15: Sun Spot Talk

15

SunSPOT build and deploy process

SunSPOTbuild

Squawk suite

converter

javac

.class

.java

.suite

.bin deploy

Page 16: Sun Spot Talk

16

Split VM architechture

Page 17: Sun Spot Talk

17

But – why not embedded Linux?• By running on the bare

metal, Squawk avoids the need for an operating system (OS) in the Sun SPOT, thereby freeing up memory that would otherwise be consumed by an OS.

Page 18: Sun Spot Talk

18

But – why not embedded Linux? (2)

“A lightweight configuration of embedded Linux requires 250 KB of ROM and 512 KB of RAM”

Arcticle onJava on the Bare Metal of Wireless Sensor Devices

Page 19: Sun Spot Talk

19

The right tool...for the right job• A series of features made Squawk JVM ideal for a

wireless sensor platform:> 1. was designed for memory constrained devices,> 2. runs on the bare metal on the ARM,> 3. represents applications as objects (via the isolate

mechanism),> 4. runs multiple applications in the one VM,> 5. migrates applications from one device to another, and> 6. authenticates deployed applications on the device.

Page 20: Sun Spot Talk

20

Design Overview

Page 21: Sun Spot Talk

21

The Squawk Java VM

What is Sun SPOT?

Agenda

Coding a SPOT

RoboControl

Sun SPOT Demo

Page 22: Sun Spot Talk

22

Sun SPOT Radio CommunicationExample: A Java Snippet for Sending

try {// Broadcast a message on port 52DatagramConnection conn = (DatagramConnection)

Connector.open(“radiogram://broadcast:52”);

Datagram packet = conn.newDatagram(conn.getMaximumLength());

packet.writeInt(someValue);

conn.send(packet);} catch (IOException ioe) { /* Handler */ }

Page 23: Sun Spot Talk

23

Sun SPOT Radio CommunicationExample: A Java Snippet for Receiving

try {// Listen on port 52DatagramConnection conn = (DatagramConnection)

Connector.open(“radiogram://:52”);

Datagram packet = (Radiogram) listenerConn.newDatagram(0);

conn.receive(packet);

//get the address of the sending SPOTString address= packet.getAddress();int rssi = packet.getRssi(); //get signal strength

} catch (IOException ioe) { /* Handler */ }

Page 24: Sun Spot Talk

24

Sun SPOT Sensor Code SnippetRangeInput light = SensorBoard.getLightSensor();RangeInput temp = SensorBoard.getTemperatureSensor();ISwitch switch1 = SensorBoard.getSwitch1();Accelerometer3D accel = SensorBoard.getAccelerometer();// Set accelerometer to 6G scalling( (LIS3L02AQAccelerometer) accel).set6GSScale();

SensorBoardColouredLED led1 =SensorBoardColouredLED.getLed1();

led1.setOn();// Change LED colour as SPOT is tiltedint xAccel = accel.getX().getValue();

if(xAccel > 0)led1.setRGB(xAccel, 0, 0);

elseled1.setRGB(0, 0, xAccel);

Page 25: Sun Spot Talk

25

demo

Page 26: Sun Spot Talk

26

Where to go from here...• http://www.sunspotworld.com/> Documentation, SDK> Discussion Forums> FAQs and application notes

• http://blogs.sun.com/davidgs/> News and informal info on SPOTs around the world

• https://squawk.dev.java.net/ or http://research.sun.com/projects/squawk/squawk-rjvm.html> The “old” research page and the new home as a open source

project on java.net• http://www.sun.com/emrkt/educonnection/newsletter/0108insidetech.html?cid=e4731

Page 27: Sun Spot Talk

RoboControl

Page 28: Sun Spot Talk

28

Page 29: Sun Spot Talk

29

A network controlled ROBOT

Page 30: Sun Spot Talk

30

A network controlled ^ ROBOTSun SPOT powered

Page 31: Sun Spot Talk

31

What is RoboControl?

• A wireless Sun SPOT powered robot with 2 DC motors, a 12V battery, an IC, a bluetooth camera phone and The Sun SPOT controller application written completely in Java.• A client and server application suite which allows remotely controlling the robot's motion, live video capture of the robot's camera and monitoring and visualization of the sensor data received from the robot's Sun SPOT.

Page 32: Sun Spot Talk

Components of RoboControl

Page 33: Sun Spot Talk

33

Components of RoboControlfile:///C:/Documents%20and%20Settings/Angad%20Singh/Desktop/Sun%20SPOT%20Talk/Sun%20Tech%20Days%20Talk/components.JPG

Page 34: Sun Spot Talk

34

Architecture

Page 35: Sun Spot Talk

Java Technology Used

in RoboControl

Page 36: Sun Spot Talk

36

Java Technology used in RoboControl

• Sun SPOT SDK• Netbeans 6.0 IDE• Java Communications API (uptil v1.0)• Java Media Framework• Java Socket Communications• Java Threading• Swing Application Framework

Page 37: Sun Spot Talk

Future Scope

Page 38: Sun Spot Talk

38

Future Scope● Dynamic spotlight illumination● Out-of-range Alarm● Automatic “return home action” ability of the robot to

backtrack it’s path when it runs out of range.● Using the live accelerometer data received from the SPOT

in a variety of useful ways on the RoboControl Client:● Showing the path traced by Robot● 3D Visualization of the robot’s orientation● Collision detection and warning

Page 39: Sun Spot Talk

39

More Future Scope..● Automatic motor speed adjustment● Remote controlled task based automation – automated task

designer. scripted tasks deployed to robot● Control of multiple wireless robots.● Image Processing● Sensor Plugin Architecture: Ability to add more sensors to

the robot and visualizing the sensor data using a plugin architecture.

Page 40: Sun Spot Talk

RoboControl on the Web

Page 41: Sun Spot Talk

41

RoboControl on the Web• RoboControl Java.net Project:The RoboControl project on Java.net:

http://robocontrol.dev.java.net• Downloadable release, documentation, and complete sources checked in under SVN

Mailing Lists:You may also subscribe to the following mailing lists for queries, suggestions, feedback, announcements and discussion on development work:

[email protected]@[email protected]

Page 42: Sun Spot Talk

42

Angad SinghSun Campus Ambassadorblogs.sun.com/angad

QUESTIONS?

42