2009년 5월 23일 토요일

OTA(Over The Air)

Deluge는 대규모 센서 네트워크에서 센서 노드들의 무선 프로그래밍을 가능하게 한다. 컴파일 된 프로그램의 binary와 같은 data object를 네트워크내에 있는 센서 노드들에게 퍼뜨리는 방법으로 이를 보통 OTA(Over the Air) Programming or Reprogramming 이라고 한다. 센서 네트워크에서 네트워크를 이루고 있는 센서 노드의 갯수가 증가할 경우에, 센서 노드에 일일이 프로그램을 다운로드하는 것은 비효율적이다. 이 경우 Deluge 매카니즘을 사용하게 되면 매우 효과적이다.


Deluge 2.0

- Goals :
• robustness & useability가 강화된 network programming

- Features :
• Multihop 지원 : multihop 네트워크 안의 모든 노드에 무선으로 프로그램 적재
• Epidemic propagation : 모든 노드에 의한 연속적인 전파 전달로, 통신율이 낮은 노드에도 전파 전달이 되도록 기여함.
• Redundant data integrity checks : CRC계산으로, 모든 노드의 프로그램 이미지 무결성을 보장하도록 기여함.
• Store multiple program images : 프로그램 이미지를 여러 개 저장함으로써, 계속되는 다운로드 없이도, 프로그램을 빠르게 교환.
• Golden image : 최소한의 network programming을 지원하는 프로그램 이미지로 외부 flash의 안전한 위치에 저장된다. 복구에 필요한 코드 부분이 있다.
• Isolated bootloader : TinyOS 어플리케이션의 리셋 후에 실행을 보장하는 코드. bootloader는 마이크로컨트롤러 프로그래밍과 관련되어 있으며, 프로그래밍 에러시 Golden Image를 읽어서 복구한다.
• Rollback gesture : 노드 고장시, 리셋 스위치를 여러 번 누르면, Golden image로 전환되어 새로운 프로그램을 받아들일 수 있도록 준비됨.
• Small RAM foot print : 150byte 미만의 메모리 차지.

- Improvement :
• 프로그래밍 전에 이미지가 유효한가에 대한 이미지 검증
• 프로그래밍 실패시 자동으로 Golden Image로 rollbak
• 어플리케이션의 의한 Golden image의 수정을 방지
• 프로그램에 대한 다양한 정보(program name, compile time, host name ...)
• CRC를 포함한 metadata 데이터구조를 사용
• Deluge나 TOSBase node 연결시 자동으로 감지
• 불완전한 이미지 자동 재시작
• 동일한 이미지 자동 감지

- Compatible platform :
• Mica2, Mica2-doc, MicaZ, Telos Rev.A, Telos Rev.B, TmoteSky

- Deluge Testing :

• Formatting the Flash ; Flash 메모리의 FAT를 위한 formatting
1) tinyos-1.x/apps/TestDeluge의 FlashFormat 어플리케이션 install
2) reset후 자동으로 포맷 시작(Yellow On), Success종료(Green On), Fail종료(Red On)

• Installing Deluge ; 기본 Deluge 어플리케이션과 TOSBoot 인스톨
1) tinyos-1.x/apps/TestDeluge의 DelugeBasic 어플리케이션 install(must set node ID)

• Pinging the Node ; Deluge java tool chain으로 현재 노드의 Deluge확인
1) Deluge가 적용된 노드를 UART로 연결한다.(SerialForwarder 혹은 MOTECOM 환경변수 설정)
2) java net.tinyos.tools.Deluge --ping
3) result screen

• Installing the Golden Image ; Deluge를 지원하는 최소 기능을 포함한 TinyOS application
1) application compile
2) build/telosb/tos_image.xml 생성 확인
3) java net.tinyos.tools.Deluge -i -in=0 -ti=./build/telosb/tos_image.xml 명령으로 Golden Image 생성 및 업로드(Golden image는 특별한 어플리케이션으로 직접연결로만 다운로드 가능)
4) 다른 노드에도 1~3의 과정으로 Golden image 다운로드 할 것.

• preparing your code : deluge 사용을 위해 사용자 어플리케이션에 deluge적용
1) top level configuration에서 DelugeC Component 추가, Main과 DelugeC wiring

• injecting a New Program image
1) java net.tinyos.tools.Deluge -i -in=1 -ti=./build/telosb/tos_image.xml

• reprogramming with a New program image
1) java net.tinyos.tools.Deluge -r -in=1(1번 image가 프로그래밍되어 동작됨. (GroupID, NodeID 유지됨))

- Deluge command :
• Ping
# java net.tinyos.tools.Deluge --ping
• Inject
# java net.tinyos.tools.Deluge --inject --tos_image= --imgnum=
• Reboot
# java net.tinyos.tools.Deluge --reboot --imgnum=
• Erase
# java net.tinyos.tools.Deluge --erase --imgnum=
• Reset
# java net.tinyos.tools.Deluge --reset --imgnum=
• Dump(extract)
# java net.tinyos.tools.Deluge --dump --imgnum= --outfile=

2009년 5월 20일 수요일

T1에서 컴파일 에러 문제

xubuntu 플랫폼에서 t1의 경우 nesc 컴파일러 1.3.0 버전을 사용하면 컴파일시 에러가 발생하는 경우가 생긴다. (대표적으로 DemoSensorC 컴포넌트 및 하위 인터페이스)

** version 확인은 다음과 같이...
#nescc --version

이를 해결하기 위해서는 nesc 컴파일러를 1.2.8a를 새로 설치하면 된다.
설치방법은 http://www.tinyos.net/dist-2.0.0/tinyos/linux 에서 해당 컴파일러를 찾아 다운로드 한 후, rpm 파일을 deb 파일로 변환하여 설치하도록 한다.

windows에 t1 설치 및 삭제

* windows에 tinyos-1.x 설치하기.

1. http://www.tinyos.net/dist-1.1.0/tinyos/windows/ 에서 tinyos-1.1.0-1is.exe를 다운로드 받아 실행한다.

2. t1의 최신버전인 1.1.15로 업그레이드 하기 위해 마찬가지로 위 사이트에서 tinyos-1.1.15Dec2005cvs-1.cygwin.noarch.rpm을 cygwin이 설치된 하부 디렉토리내에 다운로드 한다.

3. cygwin을 실행하여 1.1.15 rpm 파일이 위치한 곳으로 이동하여 다음 명령을 통해 업그레이드 하면 끝.

$ rpm --force --ignoreos -Uvh tinyos-1.1.15Dec2005cvs-1.cygwin.noarch.rpm

4. 설치가 완료되면 rpm -qa 명령을 통해 설치된 내용을 확인한다.


** windows에서 tinyos-1.x 삭제하기.

설치된 tinyos를 삭제하기 위해서는 다음의 순서를 꼭 따라야한다. 아니면 이 후 재설치 시 설치가 되지 않는 문제가 생길 수 있다.

1. 바탕화면의 Cygwin 바로가기 삭제
2. 시작-프로그램-Cygwin 폴더 삭제
3. 제어판-프로그램 추가/삭제-TinyOS 삭제
4. C:\Program Files\UCB 삭제
5. 시작-실행-regedit 를 실행한 후 Software\Cygnus Solutions 를 찾아 모두 삭제

2009년 5월 17일 일요일

duty cycle

듀티 사이클 (duty cycle)

송신 신호가 개폐되면서 한 주기를 이룰 때, 한 주기(= 전류가 흐른 시간 + 전류가 흐르지 않은 시간)에 대한 전류가 흐른 시간의 비를 듀티 사이클이라 하며, 또 전류가 흐르지 않은 시간에 대한 전류가 흐른 시간의 비를 듀티 비라고 한다.

2009년 5월 15일 금요일

TinyOS-2.x Overview

1. Introduction
TinyOS 2.0 is a clean slate redesign and re-implementation of TinyOS. Its development was motivated by our belief that many aspects of 1.x strain to meet requirements and uses that were not foreseen when it was designed and implemented. The structure and interfaces 1.x defines have several fundamental limitations. While these limitations can be worked around, this practice has led to tightly coupled components, hard to find interactions, and a very steep learning curve for a newcomer to sensor network programming.
TinyOS 2.0 is not backwards compatible with 1.x: code written for the latter will not compile for the former. However, one important aspect of 2.0's design is to minimize the difficulty of upgrading code. Therefore, while porting a 1.x application to 2.0 will require some work, it should not be very much.
This document provides a high-level overview of 2.0 and describes some of the ways in which it departs from 1.x. It covers the basic TinyOS abstractions, such as hardware abstractions, communication, timers, the scheduler, booting and initialization. Further detail on each of these can be found in TEPs (TinyOS Enhancement Proposals), which document and describe these abstractions.

2. Platforms/Hardware Abstraction
Platforms exist in the tos/platforms subdirectory. In TinyOS 2.0, a platform is a collection of chips and some glue code that connects them together. For example, the mica2 platform is the CC1000 radio chip and the ATmega128 microcontroller, while the micaZ platform is the CC2420 radio and the ATmega128 microcontroller, and the Teloi platforms are the CC2420 radio and the MSP430 microcontroller. Chip code exists in tos/chips. A platform directory generally has a .platform file, which has options to pass to the nesC compiler. For example, the mica2 .platform file tells ncc to look in chips/cc1000 and chips/atm128 directories, as well as to use avr-gcc to compile a mote binary (Teloi platforms tell it to use msp430-gcc).
Hardware abstractions in TinyOS 2.0 generally follow a three-level abstaction heirarchy, called the HAA (Hardware Abstraction Architecture).
At the bottom of the HAA is the HPL (Hardware Presentation Layer). The HPL is a thin software layer on top of the raw hardware, presenting hardare such as IO pins or registers as nesC interfaces. The HPL generally has no state besides the hardware itself (it has no variables). HPL components usually have the prefix Hpl, followed by the name of the chip. For example, the HPL components of the CC1000 begin with HplCC1000.
The middle of the HAA is the HAL (Hardware Abstraction Layer). The HAL builds on top of the HPL and provides higher-level abstractions that are easier to use than the HPL but still provide the full functionality of the underlying hardware. The HAL components usually have a prefix of the chip name. For example, the HAL components of the CC1000 begin with CC1000.
The top of the HAA is the HIL (Hardware Independent Layer). The HIL builds on top of the HAL and provides abstractions that are hardware independent. This generalization means that the HIL usually does not provide all of the functionality that the HAL can. HIL components have no naming prefix, as they represent abstractions that applications can use and safely compile on multiple platforms. For example, the HIL component of the CC1000 on the mica2 is ActiveMessageC, representing a full active message communication layer.
The HAA is described in TEP 2: Hardware Abstraction Architecture[TEP2].
Currently (as of the 2.0 release in November 2006), TinyOS 2.0 supports the following platforms:

•eyesIFXv2
•intelmote2
•mica2
•mica2dot
•micaZ
•telosb
•tinynode
•btnode3

The btnode3 platform is not included in the RPM.

3. Scheduler
As with TinyOS 1.x, TinyOS 2.0 scheduler has a non-preemptive FIFO policy. However, tasks in 2.0 operate slightly differently than in 1.x.
In TinyOS 1.x, there is a shared task queue for all tasks, and a component can post a task multiple times. If the task queue is full, the post operation fails. Experience with networking stacks showed this to be problematic, as the task might signal completion of a split-phase operation: if the post fails, the component above might block forever, waiting for the completion event.
In TinyOS 2.x, every task has its own reserved slot in the task queue, and a task can only be posted once. A post fails if and only if the task has already been posted. If a component needs to post a task multiple times, it can set an internal state variable so that when the task executes, it reposts itself.
This slight change in semantics greatly simplifies a lot of component code. Rather than test to see if a task is posted already before posting it, a component can just post the task. Components do not have to try to recover from failed posts and retry. The cost is one byte of state per task. Even in large systems such as TinyDB, this cost is under one hundred bytes (in TinyDB is is approximately 50).
Applications can also replace the scheduler, if they wish. This allows programmers to try new scheduling policies, such as priority- or deadline-based. It is important to maintain non-preemptiveness, however, or the scheduler will break all nesC's static concurrency analysis. Details on the new scheduler and how to extend it can be found in TEP 106: Schedulers and Tasks[TEP106].

4. Booting/Initialization
TinyOS 2.0 has a different boot sequence than 1.x. The 1.x interface StdControl has been split into two interfaces: Init and StdControl. The latter only has two commands: start and stop. In TinyOS 1.x, wiring components to the boot sequence would cause them to be powered up and started at boot. That is no longer the case: the boot sequence only initializes components. When it has completed initializing the scheduler, hardware, and software, the boot sequence signals the Boot.booted event. The top-level application component handles this event and start services accordingly. Details on the new boot sequence can be found in TEP 107: TinyOS 2.x Boot Sequence[TEP107].

5. Virtualization
TinyOS 2.0 is written with nesC 1.2, which introduces the concept of a 'generic' or instantiable component. Generic modules allow TinyOS to have reusable data structures, such as bit vectors and queues, which simplify development. More importantly, generic configurations allow services to encapsulate complex wiring relationships for clients that need them.
In practice, this means that many basic TinyOS services are now virtualized. Rather than wire to a component with a parameterized interface (e.g., GenericComm or TimerC in 1.x), a program instantiates a service component that provides the needed interface. This service component does all of the wiring underneath (e.g., in the case of timers, to a unique) automatically, reducing wiring mistakes and simplifying use of the abstraction.

6. Timers
TinyOS 2.0 provides a much richer set of timer interfaces than 1.x. Experience has shown that timers are one of the most critical abstractions a mote OS can provide, and so 2.0 expands the fidelity and form that timers take. Depending on the hardware resources of a platform, a component can use 32KHz as well as millisecond granularity timers, and the timer system may provide one or two high-precision timers that fire asynchronously (they have the async keyword). Components can query their timers for how much time remainins before they fire, and can start timers in the future (e.g., 'start firing a timer at 1Hz starting 31ms from now'). TEP 102: Timers[TEP102] defines what HIL components a platform must provide in order to support standard TinyOS timers. Platforms are required to provide millisecond granularity timers, and can provide finer granularity timers (e.g., 32kHz) if needed.
Timers present a good example of virtualization in 2.0. In 1.x, a program instantiates a timer by wiring to TimerC:

components App, TimerC;
App.Timer -> TimerC.Timer[unique("Timer")];

In 2.0, a program instantiates a timer:
components App, new TimerMilliC();
App.Timer -> TimerMilliC;

7. Communication
In TinyOS 2.0, the message buffer type is message_t, and it is a buffer that is large enough to hold a packet from any of a node's communication interfaces. The structure itself is completely opaque: components cannot reference its fields. Instead, all buffer accesses go through interfaces. For example, to get the destination address of an AM packet named msg, a component calls AMPacket.destination(msg).
Send interfaces distinguish the addressing mode of communication abstractions. For example, active message communication has the AMSend interface, as sending a packet require an AM destination address. In contrast, broadcasting and collection tree abstractions have the address-free Send interface.
Active messages are the network HIL. A platform's ActiveMessageC component defines which network interface is the standard communication medium. For example, a mica2 defines the CC1000 active message layer as ActiveMessageC, while the TMote defines the CC2420 active message layer as ActiveMessageC.
There is no longer a TOS_UART_ADDRESS for active message communication. Instead, a component should wire to SerialActiveMessageC, which provides active message communication over the serial port.
Active message communication is virtualized through four generic components, which take the AM type as a parameter: AMSenderC, AMReceiverC, AMSnooperC, and AMSnoopingReceiverC. AMSenderC is virtualized in that the call to send() does not fail if some other component is sending (as it does with GenericComm in 1.x). Instead, it fails only if that particular AMSenderC already has a packet outstanding or if the radio is not in a sending state. Underneath, the active message system queues and sends these outstanding packets. This is different than the QueuedSendC approach of 1.x, in which there is an N-deep queue that is shared among all senders. With N AMSenderC components, there is an N-deep queue where each sender has a single reserved entry. This means that each AMSenderC receives 1/n of the available post-MAC transmission opportunities, where n is the number of AMSenderC components with outstanding packets. In the worst case, n is the number of components; even when every protocol and component that sends packets is trying to send a packet, each one will receive its fair share of transmission opportunities.
Further information on message_t can be found in TEP 111: message_t[TEP111], while further information on AM can be found in TEP 116: Packet Protocols[TEP116].
The current TinyOS release has a low-power stack for the CC1000 radio (mica2 platform) and an experimental low-power stack for the CC2420 radio (micaz, telosb, and intelmote2 platforms).

8. Sensors
In TinyOS 2.0, named sensor components comprise the HIL of a platform's sensors. TEP 114 describes a set of HIL data acquisition interfaces, such as Read, ReadStream, and Get, which sensors provide according to their acquisition capabilities.
If a component needs high-frequency or very accurate sampling, it must use the HAL, which gives it the full power of the underlying platform (highly accurate platform-independent sampling is not really feasible, due to the particulars of individual platforms). Read assumes that the request can tolerate some latencies (for example, it might schedule competing requests using a FIFO policy).
Details on the ADC subsystem can be found in TEP 101: Analog-to-Digital Converters[TEP101]; details on the organization of sensor boards can be found in TEP 109: Sensorboards[TEP109], and the details of the HIL sensor interfaces can be found in TEP 114: Source and Sink Independent Drivers[TEP114].

9. Error Codes
The standard TinyOS 1.x return code is result_t, whose value is either SUCCESS (a non-zero value) or FAIL (a zero value). While this makes conditionals on calls very easy to write (e.g., if (call A.b())), it does not allow the callee to distinguish causes of error to the caller. In TinyOS 2.0, result_t is replaced by error_t, whose values include SUCCESS, FAIL, EBUSY, and ECANCEL. Interface commands and events define which error codes they may return and why.
From the perspective of porting code, this is the most significant different in 2.0. Calls that were once:

if (call X.y()) {
busy = TRUE;
}

now have their meanings reversed. In 1.x, the busy statement will execute if the call succeeds, while in 2.0 it will execute if the call fails. This encourages a more portable, upgradable, and readable approach:

if (call X.y() == SUCCESS) {
busy = TRUE;
}

10. Arbitration
While basic abstractions, such as packet communication and timers, can be virtualized, experiences with 1.x showed that some cannot without either adding significant complexity or limiting the system. The most pressing example of this is a shared bus on a microcontroller. Many different systems -- sensors, storage, the radio -- might need to use the bus at the same time, so some way of arbitrating access is needed.
To support these kinds of abstractions, TinyOS 2.0 introduces the Resource interface, which components use to request and acquire shared resources, and arbiters, which provide a policy for arbitrating access between multiple clients. For some abstractions, the arbiter also provides a power management policy, as it can tell when the system is no longer needed and can be safely turned off.
TEP 108: Resource Arbitration[TEP108] describes the Resource interface and how arbiters work.

11. Power Management
Power management in 2.0 is divided into two parts: the power state of the microcontroller and the power state of devices. The former, discussed in TEP 112: Microcontroller Power Management[TEP112], is computed in a chip-specific manner by examining which devices and interrupt souces are active. The latter, discussed in TEP 115: Power Management of Non-Virtualised Devices{TEP115], is handled through resource abiters. Fully virtualized services have their own, individual power management policies.
TinyOS 2.0 provides low-power stacks for the CC1000 (mica2) and CC2420 (micaz, telosb, imote2) radios. Both use a low-power listening apporach, where transmitters send long preambles or repeatedly send packets and receivers wake up periodically to sense the channel to hear if there is a packet being transmitted. The low-power stack CC1000 is standard, while the CC2420 stack is experimental. That is, the default CC1000 stack (chips/cc1000) has low-power-listening, while the default CC2420 stack (chips/cc2420) does not. To use the low-power CC2420 stack, you must include chips/cc2420_lpl in your application Makefile.

12. Network Protocols
TinyOS 2.0 provides simple reference implementations of two of the most basic protocols used in mote networks: dissemination and collection. Dissemination reliably delivers small (fewer than 20 byte) data items to every node in a network, while collection builds a routing tree rooted at a sink node. Together, these two protocols enable a wide range of data collection applications. Collection has advanced significantly since the most recent beta release; experimental tests in multiple network conditions have seen very high (>98%) deliver rates as long as the network is not saturated.

13. Conclusion
TinyOS 2.0 represents the next step of TinyOS development. Building on user experiences over the past few years, it has taken the basic TinyOS architecture and pushed it forward in several directions, hopefully leading to simpler and easier application development. It is still under active development: future prereleases will include non-volatile storage, basic multihop protocols (collection routing, dissemination), and further power management abstractions.

xubuntu network 설정

처음 xubuntu를 설치하게 되면 dhcp로 IP가 할당된다.
수동으로 고정 IP를 설정하기 위해서는

# vim /etc/networking/interfaces 파일의 내용을 다음과 같이 변경한다.

# iface eth0 inet dhcp 부분을 주석처리하고,
iface eth0 inet static
address 192.168.100.xxx
netmask 255.255.255.0
network 192.168.xxx.xxx
broadcast 192.168.xxx.xxx
gateway 192.168.xxx.xxx

위와 같이 설정이 끝나면 네트워킹을 재시작한다.
# sudo /etc/init.d/networking restart

변경된 IP 주소를 확인한다.
# ifconfig

xubuntu에 ssh 설치

1. ssh 설치
# sudo apt-get install ssh

2. 재시작
# sudo /etc/init.d/ssh restart

3. 확인
# netstat -ntl

xubuntu에 samba 설치

우분투에서 samba를 이용하여 파일공유가 가능하다.

1. 파일 공유를 위한 서버에서 다음과 같이 samba package를 설치한다.
# sudo apt-get install samba smbfs

2. 접근할 ID와 비밀번호를 설정.
# sudo smbpasswd -a ID

3. samba 설정
# sudo vim /etc/samba/smb.conf

# 기본적인 설정
[global]
# 워크 그룹
workgroup = WORKGROUP
encrypt passwords = yes
# 접근 아이피 범위
hosts allow = 192.168.
# 문자 인코딩 설정, 우분투는 utf-8을 기본적으로
unix charset=utf-8
dos charset=utf-8
#공유 디렉토리 이름
[MyDoc]
comment = My Documents
path = /공유할/디렉토리/위치
#접근 설정 여부
read only = no
browsable = yes
등등... 필요한 내용을 입력한다.

ex)
# access IP address
[global]
host allow = 192.168
# authentication
[authentication]
security = user
# shared forder
[tinyos]
comment = xubuntu
path = /share
public = yes
available = yes
writeable = yes
create make = 0777
directory mask = 0777
guest ok = no
browseable = yes

4. 설정이 완료되면 재시작한다.
# sudo /etc/init.d/samba restart

the END.

xubuntu에 APM 설치

xubuntu에서 APM의 설치는 의외로 간단하다.

1. apache2 설치
# sudo apt-get install apache2

2. php5 설치
# sudo apt-get install php5

3. mysql 설치
# sudo apt-get install mysql-server mysql-client

mysql과 php의 연동을 위해 다음과 같이 설치한다.
# sudo apt-get install php5-mysql

이상으로 기본적인 설치과정은 완료된다.

이제 apache 웹서버를 재시작한다.
# sudo /etc/init.d/apache2 restart

마찬가지로 mysql 서버도 재시작한다.
# sudo /etc/init.d/mysql restart

이로써 APM 환경이 구축된다.

2009년 5월 14일 목요일

Delta Application...

modified boomerang Delta application...
(voltage, humidity & temperature)
----------------------------------------
CommunicationsMoteiv’s communication system includes three main components: a Multihop mesh networkingprotocol, a network duty cycling protocol, and the recently proposed “Sensornet Protocol” (SP)abstraction for sending and receiving messages. All of these protocols are used in Moteiv’smesh networking application, Delta.

Multihop Networking
Moteiv’s on-demand ad-hoc networking utilizes spatial and temporal redundancy to reliabilitydeliver messages across a network to their destination. To use the Multihop library in anapplication, first include Multihop in your configuration:
  • component Multihop;
Then wire your application to the appropriate message handlers for your message type. Forexample, in your configuration:
  • AppM.Send -> MultiHop.Send[APP_ID];
  • APPM.Receive -> MultiHop.Receive[APP_ID];
Where APP_ID is a unique 8-bit identifier for your service or application defined in a header file.Please see the documentation for details of using the Send interface in Moteiv’s APIdocumentation available at /opt/moteiv/docs/nesdoc

Messages are submitted to the Multihop service and queued until there is an opportunity toroute the message towards the destination. After a message is successfully sent, an event(Send.sendDone()) is fired to your service notifying you that it is now safe to use themessage buffer for other purposes.

Low Power Operation
Moteiv’s software includes a synchronization protocol for low power wireless network. Thenetwork duty cycling approaches uses SP (described below) for establishing and maintaining aschedule whereby the entire network wakes up together and then returns to sleep.

Including Moteiv’s network duty cycling is as simple as adding a single parameter to thecompilation command. Simply add the lowpower keyword after the compilation platform. Forexample:
  • make tmote lowpower
Try the low power networking by using Delta, the mesh networking data collection application,with the lowpower option:
  • cd /opt/tinyos-1.x/contrib/boomerang/apps/Delta
  • make tmote lowpower
Be aware that bandwidth is very limited in low power mode (each node is only awake for a fewmilliseconds every two seconds). The initial synchronization of the network may require up to15 minutes to stabilize, but will reliably report data after the initial setup phase. Please bepatient!

Information about Moteiv’s network duty cycling is included in the API documentation for theNetSyncC and NetWakeC components. The source is at /opt/moteiv/tos/lib/netsync;however we strongly recommend that only the most advanced users consider modifying thiscode. Please note that Moteiv does not support any modifications to our source.

Sensornet Protocol (SP)
SP is a unifying link abstraction for running network protocols over a variety of link layer andphysical layer technologies without changing network protocol implementation. SP isimplemented by the SPC component.

SPC and its interfaces are described in detail in the following publication:A Unifying Link Abstraction for Wireless Sensor NetworksIn Proceedings of the Third ACM Conference on Embedded Networked Sensor Systems(SenSys), November 2-4, 2005.
http://www.polastre.com/papers/sensys05-sp.pdf

Messages are transmitted using the SPSend interface and message futures are handledthrough the SPSendNext interface. To send a message on a particular AM type, such as AMtype 5, wire your network protocol to SPSend[5]. The SP message pool will hold on to amessage and its corresponding packets until it may be sent over the channel.

Fields of each SP message (sp_message_t) should never be directly accessed. Instead, theycan be set using the parameters of the SPSend interface. Reading parameters should be donethrough the SPMessage interface.

Reception is on a per packet basis (not a per message basis like SPSend). Packets areimmediately dispatched to higher layer services based on AM type. SPReceive providesinformation about each packet, including a token that identifies which interface a messageoriginated.

The SP Neighbor Table is accessed through the SPNeighbor interface. Users must wire to theSP Neighbor Table with the parameter unique("SPNeighbor"). Each service has its ownidentity for controlling the insertions, removals, and changes of entries in the SP NeighborTable. See the SPNeighbor interface in the API documentation for more information.

Various utilities as part of SP's processing are available in the SPUtil interface. These utilitiesinclude link estimation functions and link post-arbitration time stamps.
- moteiv corp -

Power Characteristic

Basic Sensor Node

* AA Size battery 2ea
* USB 전원 인가하여 사용 가능
* CC2420은 DC 2.1v ~ 3.6v 범위에서 동작
* MSP430F1611 MCU는 1.8v ~ 3.6v 범위에서 동작
* USB 연결로 programming시 최소 2.7v 전원이 필요
* PC의 USB 인터페이스로부터 받은 5v 전원을 Regulator를 이용하여 3v 로 전환

2009년 5월 7일 목요일

TinyOS-1.x and Boomerang

TinyOS-1.x and Boomerang

These installation instructions will only work on Windows XP and XubuntOS. In particular, they will not work on Windows Vista, nor Mac OS. It is possible to install the tmote tools on any distribution of linux, but it is a bit more involved. XubuntOS makes your life a lot easier. The following is loosely based on http://www.5secondfuse.com/tinyos/oldInstall.html. I just added a few lines to the .bash_tinyos script to implement the boomerang function.

Installation

Windows XP

To install on XP, you need the Boomerang tmote tools CD, which you can get from me, or download from http://www.ccs.neu.edu/home/acassola/tmote-tools-2_0_4.zip.
To start, run the setup.msi file from within windows. The installer will set up Cygwin, Java5, TinyOS, and the boomerang/tmote-tools for you. To work, you will need to open a cygwin shell window. The installer made sure all the software and variables have been set.

XubuntOS

If you are using anything other than windows XP, you will need access to a trial version of VMWare workstation from http://www.vmware.com/, and download the XubuntOS virtual machine image at http://www.5secondfuse.com/tinyos/xubuntos-2.0-vm.tar.gz.
XubuntOS is a modified ubuntu installation that runs the XFCE window manager and has installed (almost) all the required java and TinyOS components for us.

Now follow these steps:

1. After unpacking the image, open it with vmware. Go to the VM->Settings Menu Option and under USB Controller check the box ``Automatically Connect USB Devices to this virtual machine. Click on Save.

2. Start the xubunTOS virtual machine. Once the machine is up, you can login with username xubuntos and password tinyos.

3. Go to Applications->System->Synaptic Package Manager. Click on the Reload Button. Click on the Search button and enter msp430 in the box and click search. Select the msp430-tinyos package, version 2.1-20080806 for installation, and accept the next dialog. Click on the apply button, and apply the next dialog, too.

4. Click on the terminal icon (next to the firefox icon). Inside the terminal run the following command:
wget -O .bash_tinyos http://www.ccs.neu.edu/home/acassola/bash_tinyos

5. Download the tinyos-tools zip file by running
wget http://www.ccs.neu.edu/home/acassola/tmote-tools-2_0_4.zip
in the same terminal as above

6. Download the moteiv tools package and install it. Change the owner of the installation directory:
wget http://www.ccs.neu.edu/home/acassola/tinyos-moteiv_2.0.4-2_all.deb
sudo dpkg --install *.deb
**Type the tinyos password**
sudo chown -R xubuntos /opt/moteiv

7. You are all set. Exit the terminal you were using, open the Qickstart guide inside the tools CD, read it, and start playing. Check out the tinyos tutorials available in the internet.


To interact with the motes, you need to use a terminal. Opening a new terminal after completing these instructions will give you one that has all its environment variables set to the right values and is ready to work.

- http://www.ccs.neu.deu/home/acassola/installtos/ -

Oscilloscope 어플리케이션 되짚어 보기.

Oscilloscope 어플리케이션 예제에서는 센싱 데이터가 2바이트씩 10개의 값을 보내도록 구현되어 있다. OscopeMsg 패킷의 형식을 보면 버퍼 사이즈 즉, 샘플링 데이터를 10개 수집하도록 되어 있기 때문이다. 하나씩 뜯어보도록 하자.

Tinyos에서 기본적으로 사용되는 TOS_Msg를 살펴보면
(/opt/tinyos-1.x/tos/platform/telos/AM.h)


#define TOSH_DATA_LENGTH 28
typedef struct TOS_Msg{
uint8_t length;
uint8_t fcfhi;
uint8_t fcflo;
uint8_t dsn;
uint16_t destpan;
uint16_t addr;
uint8_t type;
uint8_t group;
uint8_t data[TOSH_DATA_LENGTH];
uint16_t strength;
uint8_t lqi;
bool crc;
bool ack;
uint16_t time;
} TOS_Msg;

여기서 데이터가 저장되는 페이로드 부분은 int8_t data[TOSH_DATA_LENGTH]; 부분으로 총 28바이트의 크기를 가진다.
그리고 Oscilloscope에서 사용되는 OscopeMsg의 경우 TOS_Msg의 이 페이로드 부분, 즉 28바이트 크기를 가지는 data부분에 실려서 전송되며 별도의 헤더를 가진다.

enum {
BUFFER_SIZE = 10
};
struct OscopeMsg {
uint16_t sourceMoteID;
uint16_t lastSampleNumber;
uint16_t channel;
uint16_t data[BUFFER_SIZE];
} OscopeMsg;

총 28byte의 페이로드 중 6바이트를 OscopeMsg의 헤더로 사용하고 BUFFER_SIZE 크기 만큼인 20byte를 2바이트씩 10개의 데이터로 채운다. 즉, OscopeMsg 형태의 패킷을 사용하면 2바이트짜리 데이터가 패킷당 10개씩 들어오는 것이다.
왜 2바이트짜리를 사용하는가. 그것은 센서 노드에서 10~12bits의 ADC를 사용하기 때문이다. 즉, ADC를 거쳐 아날로그에서 디지털로 변환된 데이터의 크기는 10~12bits이고 이를 저장하기 위해서는 2바이트가 필요한 것이다. ADC에서 데이터를 변환하여 결과값이 나왔을때 호출되는 함수를 보면 async event result_t ADC.dataReady(uint16_t data); 와 같은 형식을 취하는데 인수로 넘어오는 uint16_t data가 ADC의 결과가 된다. 이 값을 보내기 위해서 당연히 2바이트 짜리 변수를 사용해서 보내는 것이다.

[TIP]
OscopeC 컴포넌트는 /opt/tinyos-1.x/tos/lib/Oscope에 위치해 있으며, 이 컴포넌트를 이용하여 (OscopeM.nc, Oscope.h와 함께) Oscilloscope에서 발생한 센서 데이터들을 센서 타입별로 OscopeMsg 형태로 만들어 RF로 전송하는 기능을 가진 컴포넌트이다.
/opt/tinyos-1.x/apps에 있는 Oscilloscope 어플리케이션은 오직 하나의 센서에 대해서만 처리하기 때문에 앞에서와 같은 기능 분리가 필요 없으나, /contrib/moteiv/apps에 있는 Oscilloscope 어플리케이션은 여러 개의 센서들에 대해서 샘플링하고, 이를 각각 OscopeMsg로 만들어서 전달하여야 하므로 위와 같은 기능을 분리한 것이다. 물론 사용자 어플리케이션에서 모든 것을 처리할 수도 있겠지만, 같은 것의 반복을 parameterized 인터페이스를 통해 좀 더 간결하고 쉽게 해결하기 위해 OscopeC 컴포넌트를 사용한다.

2009년 5월 3일 일요일

Makelocal

/opt/tinyos-1.x/tools/make/Makelocal 파일을 다음과 같이 설정하거나 또는, 해당 어플리케이션의 Makefile 내에 추가하면 컴파일 시 해당 내용이 적용된다.

#DEFAULT_LOCAL_GROUP = 0x7d
#PFLAGS += -DCC2420_DEF_CHANNEL = 26
#PFLAGS += -DDEFAULT_BAUDRATE = 57600
#PFLAGS += -DCC2420_DEF_RFPOWER = 31

또한, PFLAGS를 이용하여 경로 include 할 컴포넌트 및 라이브러리를 추가할 시, 다음과 같이 사용하면 된다.
#PFLAGS += -I$(TOSDIR)/../contrib/ucb/tos/lib/Oscope

참고로 크로스컴파일러 옵션의 -I는 include 폴더를 지정하는 것이며, -D는 define, 즉 컴파일전 정의를 해주는 것이다.

#PFLAGS += -v 옵션으로 해당 어플리케이션에서 사용하는 모든 파일을 컴파일 시간에 확인할 수 있다. 또한 컴파일 시 어플리케이션에의 참조 파일 목록을 텍스트 파일로 저장할 수도 있다.
# make telosb 2&>test.txt

2009년 5월 1일 금요일

Issue

* Low Power Listening *


Arch Rock에서 CC2420 기반의 Low Power Listening을 성공적으로 구현, 2007년 초부터 TinyOS-2.x에 LPL 코드가 공개되었다.
저 전력 통신을 위해서는 주기적으로 CC2420을 sleep/wake 동작이 가능하도록 해야 한다.
MAC 계층 에서 Telosb의 저 전력은 현재 많이 사용하는 SurgeTelos등과 같은 공개된 코드에서는 active 상태로 동작한다. CC2420은 active 상태에서는 20mA 이상의 전류가 항상 소모되고 있다. CC2420은 보통 17mA ~ 20mA 정도의 전력을 소비하므로 항상 wake 되어 있는 일반적인 SurgeTelos 등과 같은 어플리케이션의 경우 저 전력으로 동작시킬 수 없다.
저 전력을 구현하기 위해서는 TinyOS-2.x 의 LPL을 이용해야 한다. (tutorial 참조)
결론은 TinyOS-1.x 에서는 CC2420의 저 전력이 불가능하고, TinyOS-2.x 에서는 LPL이 지원되므로 저 전력으로 구현이 가능하다. 이 LPL은 Deluge를 구현한 Jonathan Hui가 만들었다. 현재 6LowPAN에서 왕성한 활동을 하고 있다.
CC1000 계열에서는 소프트웨어에서 Preamble을 제어 할 수 있다. CC2420은 보내고자하는 데이터를 버퍼로 입력해주면, 하드웨어가 알아서 전송한다. 즉, CC1000과 같이 세밀한 제어가 불가능 하다. CC2420은 대부분의 기능을 하드웨어가 하기 때문에, 새로운 알고리즘을 적용한 프로토콜을 만들어내기가 거의 불가능하다. 따라서 대부분의 학계 연구결과들은 CC1000을 기반으로 발표된 내용이며, S-MAC, PRIME, Funelling MAC 등 CC2420은 제약이 많다. 저 전력으로 구현하기에는 CC1000이 성능이 좋다. 그 이유는 Preamble을 가변적으로 조절해서 LPL을 구현할 수 있기 때문이다. CC2420은 데이터 전송률이 높으며, MCU와 연결하여 통신을 하기에 매우 편리하다. CC1000과 다르게 대부분의 기능을 하드웨어가 담당한다. 또한, CC2420은 IEEE 표준 기반이지만 CC1000은 아니다. 현재 비즈니스를 하는 대부분의 회사들은 표준을 따라 가고 있다. Vertical market은 한계를 가지고 있기 때문이다.
B-MAC은 ZigBee용 MAC이 아니다. 기본적으로 B-MAC은 CC1000 칩을 위한 MAC 프로토콜로 Preamble 을 동적으로 줄이고 늘이고 해야하기 때문에, CC2420에서는 불가능 하다. 보통 Telos 에 사용된 MAC을 LPL(Low Power Listening)이 없는 MAC이라고 부른다. 그동안의 Sensys 컨퍼런스 논문들을 보면, 센서 네트워크에서의 MAC이 어떻게 발전 되어 왔는지를 볼 수 있다. 그중 저전력을 목표로 구현한 것들이 많다. CC2420 칩이 20mA 정도를 항상 소비한다고 보면, 얼마나 잘 Sleep 시켰다가, wake up 시키느냐가 중요하다고 볼 수 있다.

- tinyos korea -