Saturday, August 18, 2007

Source Code ในการเปลี่ยน Power level

เราจะศึกษา RSSI ที่ power level ต่างๆ ได้แก่ 5,10,15,20,25,30
ดังนั้น จะต้องเปลี่ยน Source Code ของ Beacon และ Mobile

Source Code ของ Beacon : ไฟล์ใน Beacon ประกอบด้วย AckMsg.h, ScooterC.nc และ ScooterM.nc
จะเปลี่ยน Source Code ในไฟล์ AckMsg.h

#ifndef ACKMSG_H
#define ACKMSG_H

enum {
AM_ACK1MSG = 1,
AM_ACKNOWLEDGE1MSG = 2,
AM_RSSIMSG = 3,

DELAYTIME = 10,
RF_POWER = 29, //Set RF Power 1 to 31 => เปลี่ยนค่า Power Level ตามต้องการ ในที่นี้จะเปลี่ยนเป็น 5,10,15,20,25,30
RF_FREQUENCY = 11, //Set Channel Frequency 11 to 26 เปลี่ยนช่องสัญญาณ
};

typedef struct Ack1Msg
{
} Ack1Msg;

typedef struct Acknowledge1Msg
{
uint16_t RSSI;
uint16_t ID;
} Acknowledge1Msg;

typedef struct RSSIMsg
{
uint16_t RSSI;
uint16_t ID;
} RSSIMsg;

#endif


Source Code ของ Mobile : ไฟล์ใน Mobile ประกอบด้วย AckMsg.h, BoatC.nc และ BoatM.nc
จะเปลี่ยน Source Code ในไฟล์ AckMsg.h

#ifndef ACKMSG_H
#define ACKMSG_H

enum {
AM_ACK1MSG = 1,
AM_ACKNOWLEDGE1MSG = 2,
AM_RSSIMSG = 3,

DELAYTIME = 10,
RF_POWER = 29, //Set RF Power 1 to 31 => เปลี่ยนค่า Power Level ตามต้องการ ในที่นี้จะเปลี่ยนเป็น 5,10,15,20,25,30
RF_FREQUENCY = 11, //Set Channel Frequency 11 to 26
};

typedef struct Ack1Msg
{
} Ack1Msg;

typedef struct Acknowledge1Msg
{
uint16_t RSSI;
uint16_t ID;
} Acknowledge1Msg;

typedef struct RSSIMsg
{
uint16_t RSSI;
uint16_t ID;
} RSSIMsg;

#endif

Sunday, August 12, 2007

การใช้โปรแกรม Cygwin

โปรแกรมที่ใช้ คือ Cygwin

ขั้นตอนการศึกษา

1. เปิดโปรแกรม Cygwin เสียบ Tmote ตัวที่เป็น Beacon ติดตั้งตัวโปรแกรมลงไป เมื่อลงเสร็จแล้ว ให้ดึง Tmote ออกก่อน
$ cd /opt/moteiv/apps/RSSIBase/
$ cd Beacon/
$ make telosb install,1
ลงโปรแกรมใน TMote ด้วย Address1 ให้ตัวที่เป็น Beacon มี Node Address1


2. เสียบ Tmote ตัวที่เป็น Mobile เพื่อติดตั้งโปรแกรมลงไป เมื่อลงเสร็จแล้ว ให้ดึง Tmote ออกก่อน
$ cd /opt/moteiv/apps/RSSIBase/Mobile/
$ make telosb install ลง Mobile ให้กับตัว Mobile station


3. เสียบ Tmote ตัวที่เป็น TOSBase เพื่อติดตั้งโปรแกรมลงไป เมื่อลงเสร็จแล้ว ให้ดึง Tmote ออกก่อน
$ cd /opt/moteiv/apps/TOSBase/
$ cd /opt/tinyos-1.x/apps/TOSBase/
$ make telosb install,0
อินสตอลลง TOSBase ให้กับตัว Tmote โดยกำหนด Address เป็น 0 เพื่อเป็น Base station ด้วยคำสั่ง


4. เมื่อ Install ทั้ง 3 ตัวเสร็จแล้ว ให้นำ Mobile และ TOSBase เสียบต่อกับคอมพิวเตอร์ ทั้งสองตัวนี้ให้วางตำแหน่งใกล้ๆกัน โดยวางในแนวเดียวกัน


5. วาง Beacon ในตำแหน่งตามจุดที่ต้องการ


6. เปิด Cygwin ใหม่
$ java net.tinyos.sf.SerailForwarder -comm
serial@COM12:tmote
*** COM12 เป็น Port ของ TOSBase


7. เปิด Cygwin ใหม่
$ java net.tinyos.rssibase.MainClass


8. จะได้รับค่า RSSI จากตัว Beacon ตามตำแหน่งต่างๆ และจะเก็บข้อมูลไว้ โดยแต่ละตำแหน่งจะเก็บค่า RSSI เป็นเวลา 1 นาที9. เมื่อหาตำแหน่งจนครบตามที่ต้องการแล้ว เปลี่ยน power lever และ complied ตามข้อ 1-3 ใหม่ และทำตามข้อต่อไปเรื่อยๆ จนครบ power level (1-31) แต่ในโครงงานนี้ จะศึกษา power level ที่ 5,10,15,20,25,30