Testing the Imote2 Sensor Board

From Cyber-Physical Systems Laboratory
Revision as of 22:46, 11 December 2007 by Liangfok (talk | contribs) (New page: TestSensorBoard is an Imote2 application that comes with TinyOS 1.x. It is used to test the Imote2's ITS400 sensor board and is located in tinyos-1.x/contrib/imote2/test/TestSensorboard. ...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

TestSensorBoard is an Imote2 application that comes with TinyOS 1.x. It is used to test the Imote2's ITS400 sensor board and is located in tinyos-1.x/contrib/imote2/test/TestSensorboard. For more information, read the README its directory.

How to Run TestSensorBoard

Compilation

The first step is to compile the application:

cd $TOSROOT/contrib/imote2/test/TestSensorboard/
make imote2 SENSORBOARD=BasicSensorboard USE_USB=1

Here is the output of a successful compilation:

mkdir -p build/imote2
xscale-elf-as -mcpu=iwmmxt -mfpu=softfpa -defsym BOOTLOADER=1 /opt/tinyos-1.x/t
s/platform/pxa27x/../imote2/flash.s /opt/tinyos-1.x/tos/platform/pxa27x/../imot
2/binarymover.s /opt/tinyos-1.x/tos/platform/pxa27x/barecrt.s /opt/tinyos-1.x/t
s/platform/pxa27x/mmu_table.s /opt/tinyos-1.x/tos/platform/pxa27x/util.s  -o bu
ld/imote2/asms.o
cd /opt/tinyos-1.x/tos/platform/pxa27x/lib; make;
make[1]: Entering directory `/opt/tinyos-1.x/beta/platform/pxa27x/lib'
xscale-elf-gcc -g -O2 -Wall -I/opt/tinyos-1.x/tos/platform/pxa27x -I/opt/tinyos
1.x/tos/platform/pxa27x/lib/DSP -I/opt/tinyos-1.x/tos/platform/pxa27x/lib/   -c
-o bufferManagement.o bufferManagement.c
In file included from bufferManagement.c:2:
assert.h:8: warning: `C' attribute directive ignored
In file included from bufferManagement.c:4:
systemUtil.h:28: warning: `C' attribute directive ignored
systemUtil.h:28: warning: `spontaneous' attribute directive ignored
xscale-elf-gcc -g -O2 -Wall -I/opt/tinyos-1.x/tos/platform/pxa27x -I/opt/tinyos
1.x/tos/platform/pxa27x/lib/DSP -I/opt/tinyos-1.x/tos/platform/pxa27x/lib/   -c
-o downsample.o downsample.c
xscale-elf-gcc -g -O2 -Wall -I/opt/tinyos-1.x/tos/platform/pxa27x -I/opt/tinyos
1.x/tos/platform/pxa27x/lib/DSP -I/opt/tinyos-1.x/tos/platform/pxa27x/lib/   -c
-o frequency.o frequency.c
xscale-elf-gcc -g -O2 -Wall -I/opt/tinyos-1.x/tos/platform/pxa27x -I/opt/tinyos
1.x/tos/platform/pxa27x/lib/DSP -I/opt/tinyos-1.x/tos/platform/pxa27x/lib/   -c
-o paramtask.o paramtask.c
In file included from paramtask.c:4:
systemUtil.h:28: warning: `C' attribute directive ignored
systemUtil.h:28: warning: `spontaneous' attribute directive ignored
xscale-elf-gcc -g -O2 -Wall -I/opt/tinyos-1.x/tos/platform/pxa27x -I/opt/tinyos
1.x/tos/platform/pxa27x/lib/DSP -I/opt/tinyos-1.x/tos/platform/pxa27x/lib/   -c
-o profile.o profile.c
xscale-elf-gcc -g -O2 -Wall -I/opt/tinyos-1.x/tos/platform/pxa27x -I/opt/tinyos
1.x/tos/platform/pxa27x/lib/DSP -I/opt/tinyos-1.x/tos/platform/pxa27x/lib/   -c
-o queue.o queue.c
xscale-elf-gcc -g -O2 -Wall -I/opt/tinyos-1.x/tos/platform/pxa27x -I/opt/tinyos
1.x/tos/platform/pxa27x/lib/DSP -I/opt/tinyos-1.x/tos/platform/pxa27x/lib/   -c
-o systemUtil.o systemUtil.c
In file included from systemUtil.c:2:
systemUtil.h:28: warning: `C' attribute directive ignored
systemUtil.h:28: warning: `spontaneous' attribute directive ignored
xscale-elf-gcc -g -O2 -Wall -I/opt/tinyos-1.x/tos/platform/pxa27x -I/opt/tinyos
1.x/tos/platform/pxa27x/lib/DSP -I/opt/tinyos-1.x/tos/platform/pxa27x/lib/   -c
-o utils.o utils.c
xscale-elf-gcc -g -O2 -Wall -I/opt/tinyos-1.x/tos/platform/pxa27x -I/opt/tinyos
1.x/tos/platform/pxa27x/lib/DSP -I/opt/tinyos-1.x/tos/platform/pxa27x/lib/   -c
-o wmmx.o wmmx.c
xscale-elf-ar  -rvs libimote2.a bufferManagement.o downsample.o frequency.o par
mtask.o profile.o queue.o systemUtil.o utils.o wmmx.o
r - bufferManagement.o
r - downsample.o
r - frequency.o
r - paramtask.o
r - profile.o
r - queue.o
r - systemUtil.o
r - utils.o
r - wmmx.o
make[1]: Leaving directory `/opt/tinyos-1.x/beta/platform/pxa27x/lib'
    compiling TestSensorboard to a imote2 binary
ncc -o build/imote2/main.exe -O1 -g -DCC2420_DEF_CHANNEL=15 -I/opt/tinyos-1.x/t
s/lib/CC2420Radio -I/opt/tinyos-1.x/tos/lib/Flash -DAUTO_BATTERY_MONITORING=1 -
all -Wshadow -DDEF_TOS_AM_GROUP=0x07 -Wnesc-all -target=imote2 -fnesc-cfile=bui
d/imote2/app.c -board=BasicSensorboard -DBOOTLOADER -I../../tos/sensorboards/Fr
mework -I../../tos/interfaces -I../../tos/include -I../../tos/sensorboards/Basi
Sensorboard -I../../tos/lib/I2CBusSequence       -DUSE_USB=1 -DIDENT_PROGRAM_NA
E=\"TestSensorboard\" -DIDENT_USER_ID=\"FOKSUN\" -DIDENT_HOSTNAME=\"quadcore\"
DIDENT_USER_HASH=0x6f78dd3bL -DIDENT_UNIX_TIME=0x474db757L -DIDENT_UID_HASH=0x1
26d0b4L TestSensorboard.nc -lm  build/imote2/asms.o /opt/tinyos-1.x/tos/platfor
/pxa27x/lib/libimote2.a
In file included from TestSensorboard.nc:9:
In component `TestSensorboardM':
TestSensorboardM.nc: In function `GetData.callApp':
TestSensorboardM.nc:166: warning: passing argument 9 of `GenericSampling.prepar
' from incompatible pointer type
TestSensorboardM.nc: In function `WriteData.write':
TestSensorboardM.nc:393: warning: assignment from incompatible pointer type
In file included from ../../tos/sensorboards/BasicSensorboard/BasicSensorboardA
celDataC.nc:17,
                 from ../../tos/sensorboards/BasicSensorboard/SensorboardC.nc:2
,
                 from TestSensorboard.nc:12:
In component `BasicSensorboardAccelDataM':
../../tos/sensorboards/BasicSensorboard/BasicSensorboardAccelDataM.nc: In funct
on `SensorData.getSensorData':
../../tos/sensorboards/BasicSensorboard/BasicSensorboardAccelDataM.nc:130: warn
ng: assignment from incompatible pointer type
In C file:
/opt/tinyos-1.x/tos/platform/imote2/BluSHM.nc: At top level:
/opt/tinyos-1.x/tos/platform/imote2/BluSHM.nc:113: warning: `UartSend.send' cal
ed asynchronously from `generalSend'
/opt/tinyos-1.x/tos/platform/imote2/BluSHM.nc:120: warning: `USBSend.send' call
d asynchronously from `generalSend'
../../tos/sensorboards/BasicSensorboard/BasicSensorboardAccelDataM.nc:192: warn
ng: `RawData.BulkTxRx' called asynchronously from `AccelRead'
/opt/tinyos-1.x/tos/platform/pxa27x/PXA27XUSBClientM.nc:326: warning: `SendVarL
nPacket.sendDone' called asynchronously from `USBInterrupt.fired'
/opt/tinyos-1.x/tos/platform/pxa27x/PXA27XUSBClientM.nc:328: warning: `SendJTPa
ket.sendDone' called asynchronously from `USBInterrupt.fired'
/opt/tinyos-1.x/tos/platform/pxa27x/PXA27XUSBClientM.nc:331: warning: `BareSend
sg.sendDone' called asynchronously from `USBInterrupt.fired'
../../tos/sensorboards/BasicSensorboard/BasicSensorboardAccelDataM.nc:279: warn
ng: `SensorData.getSensorDataDone' called asynchronously from `RawData.BulkTxRx
one'
../../tos/sensorboards/BasicSensorboard/BasicSensorboardAccelDataM.nc:279: warn
ng: `SensorData.getSensorDataDone' called asynchronously from `RawData.BulkTxRx
one'
../../tos/sensorboards/BasicSensorboard/BasicSensorboardAccelDataM.nc:46: warni
g: non-atomic accesses to shared variable `gAccelRxBuffer':
../../tos/sensorboards/BasicSensorboard/BasicSensorboardAccelDataM.nc:98: warni
g:   non-atomic read
../../tos/sensorboards/BasicSensorboard/BasicSensorboardAccelDataM.nc:279: warn
ng:   non-atomic write
../../tos/sensorboards/BasicSensorboard/BasicSensorboardAccelDataM.nc:279: warn
ng:   non-atomic read
../../tos/sensorboards/BasicSensorboard/BasicSensorboardAccelDataM.nc:279: warn
ng:   non-atomic read
../../tos/sensorboards/BasicSensorboard/BasicSensorboardAccelDataM.nc:279: warn
ng:   non-atomic read
../../tos/sensorboards/BasicSensorboard/BasicSensorboardAccelDataM.nc:279: warn
ng:   non-atomic read
../../tos/sensorboards/BasicSensorboard/BasicSensorboardAccelDataM.nc:48: warni
g: non-atomic accesses to shared variable `gAccelRxBufferPos':
../../tos/sensorboards/BasicSensorboard/BasicSensorboardAccelDataM.nc:277: warn
ng:   non-atomic read
../../tos/sensorboards/BasicSensorboard/BasicSensorboardAccelDataM.nc:280: warn
ng:   non-atomic write
../../tos/sensorboards/BasicSensorboard/BasicSensorboardAccelDataM.nc: In funct
on `BasicSensorboardAccelDataM$SensorData$getSensorData':
../../tos/sensorboards/BasicSensorboard/BasicSensorboardAccelDataM.nc:130: warn
ng: assignment from incompatible pointer type
TestSensorboardM.nc: In function `TestSensorboardM$GetData$callApp':
TestSensorboardM.nc:166: warning: passing arg 9 of `TestSensorboardM$GenericSam
ling$prepare' from incompatible pointer type
TestSensorboardM.nc: In function `TestSensorboardM$WriteData$write':
TestSensorboardM.nc:393: warning: assignment from incompatible pointer type
    compiled TestSensorboard to build/imote2/main.exe
          178204 bytes in ROM
           13636 bytes in RAM
            9216 bytes in STACK
          239292 bytes available in HEAP
xscale-elf-objcopy --output-target=binary build/imote2/main.exe build/imote2/ma
n.bin.out
xscale-elf-objcopy --output-target=binary build/imote2/main.exe build/imote2/ma
n.bin.out

Possible Error 1: No Medium Found

cc1: /cygdrive/e/wasabi_drops/wasabi031117/install031117/include: No medium found
cc1: /cygdrive/e/wasabi_drops/wasabi031117/install031117/lib/gcc-lib/xscale-elf/Wasabi-3.3.1/include: 
No medium found
cc1: /cygdrive/e/wasabi_drops/wasabi031117/install031117/xscale-elf/sys-include: No medium found
cc1: /cygdrive/e/wasabi_drops/wasabi031117/install031117/xscale-elf/include: No medium found

Solution: In this case, the error is because there is no media in drive E. In your case, the drive may be a different letter or there may be more than one drive having the same problem. For each drive, either disconnect it or put some media into it.

Possible Error 2: Invalid Target

nesc1: NESC_MACHINE, unknown field name starting at gcc=xscale-elf-gcc
nesc1: invalid target described in env NESC_MACHINE

Solution: Edit $TOSROOT/beta/platform/imote2/.platform and remove "gcc=xscale-elf-gcc" from the end of $ENV{NESC_MACHINE} on line 12.

Installation

The next step is to install TestSensorboard onto an Imote2. This can either be done using a JTAG dongle and an Imote2 programmer board, or, if the mote has the USB BootLoader installed, the application can be directly over USB using USBLoaderHost.exe as shown below.

USBLoaderHost -p build/imote2/main.bin.out

Here is the output of a successful installation:

Program Mode, File name = build/imote2/main.bin.out
File Size 178204
Device detected
Device detected
GET_IMAGE_DETAILS Received.
ImgSize=178204, Num Packets= 2922
Total Packets Uploaded = 0, 0.00% completed
Sending CRC Check command 21967
Total Packets Uploaded = 546, 18.00% completed
Sending CRC Check command 9073
Total Packets Uploaded = 1092, 37.00% completed
Sending CRC Check command 10643
Total Packets Uploaded = 1638, 56.00% completed
Sending CRC Check command 9334
Total Packets Uploaded = 2184, 74.00% completed
Sending CRC Check command 17902
Total Packets Uploaded = 2730, 93.00% completed
Sending CRC Check command 45344
Image Download Completed
CRC of the Image = 46516, Total Size = 178204
Time taken for Upload 8967 Milli Seconds
Image Verification Completed.
Loading Image to boot location and marking it as golden.
Time Elapsed till IMG_VERIFY 11592 Milli Seconds
Time Elapsed 17264 Milli Seconds
Successfully copied image to boot location.

Mapped Boot Image to golden. Booting New Image.

Overall Time Elapsed 19675 Milli Seconds

Possible Error 1: Command Not Found

bash: USBLoaderHost: command not found

Solution: Add USBLoaderHost to your path.

export PATH=$PATH:$TOSROOT/contrib/imote2/tools/bin

To prevent having to enter the above command each time you open up a new command prompt, you can add it to ~/.bashrc.

Running the iMoteConsole

Connect an ITS400 sensor board to the Imote2 and attach the Imote2 to your PC via USB. Open iMoteConsole from tinyos-1.x/contrib/imote2/tools/bin. The following GUI should appear:

The main ImoteConsole screen.

Select the Imote2 device (it should start with USB) and click on the "View Buffer in Window" button. The following GUI should appear:

The ImoteConsole buffer viewer (not connected).

Click on the "Connect" button. In the main text area of the window, type Enter to get a BluSH> prompt. Execute ls to view a list of valid commands.

To collect accelerometer readings, execute the following in the ImoteConsole:

  • GetData 1 560 100000 100
  • StartCollection

The parameters to GetData are [channel] [numSamples] [sampleRate in Hz] [warmup in ms]. Currently, the sampling rate for the accelerometer is ignored (it is fixed at 280Hz +- 10%). After executing StartCollection, you should see the following:

The ImoteConsole buffer viewer (connected).


Assuming you see "Sampling SUCCESS for channel 1", two files with extensions .dat and .raw will appear in the directory from which you launched iMoteConsole. The .dat file contains the sensor readings in gravity units, whereas the .raw contains the raw sensor readings. You can re-run GetData and StartCollection numerous times. Each time the data will be stored in unique files.

Launch Matlab and edit tinyos-1.x/contrib/imote2/tools/src/Matlab/GenericSampling/SensorRecordImport/process.m. Modify MOTE to contain your mote's ID and Collection for loop to be the collection that you want to analyze. The script will import the sensor readings and plot them on a graph in both the time and frequency domains (see example graph below). You can then use Matlab to perform other operations on the data.

Matlab plot of accelerometer readings.