Discussion:
[Shimmer-users] ParamLogging
Gabriele Spina
2012-09-30 23:53:43 UTC
Permalink
Dear all,


I've seen that in the repository ~/tinyos-2.x-contrib/shimmer/apps a new
firmware is present (ParamLogging) that allows to store the data in the SD.
I tried to compile it without success and I get the following message:


***@ShimmerLive:~/tinyos-2.x-contrib/shimmer/apps/ParamLogging$ make
shimmer2r
mkdir -p build/shimmer2r
compiling ParamLoggingC to a shimmer2r binary
ncc -o build/shimmer2r/main.exe -Os -O -DSMCLK_4MHZ -mdisable-hwmul
-fnesc-separator=__ -Wall -Wshadow -Wnesc-all -target=shimmer2r
-fnesc-cfile=build/shimmer2r/app.c -board= -DDEFINED_TOS_AM_GROUP=0x22
-DIDENT_APPNAME=\"ParamLoggingC\" -DIDENT_USERNAME=\"tiny2\"
-DIDENT_HOSTNAME=\"ShimmerLive\" -DIDENT_USERHASH=0xe8d0c5b7L
-DIDENT_TIMESTAMP=0x5068b97fL -DIDENT_UIDHASH=0x1e5da879L ParamLoggingC.nc
-lm
In file included from ParamLoggingC.nc:35:
/home/tiny2/tinyos-main/tos/platforms/shimmer/chips/sd/fatfs/FatFs.h:69:2:
warning: #warning "Using enhanced/optimized version of FatFs............."
In file included from ParamLoggingC.nc:40:
In component `ParamLoggingP':
ParamLoggingP.nc: In function `setSamplingConfig':
ParamLoggingP.nc:347: implicit declaration of function `__delay_cycles'
ParamLoggingP.nc: In function `getSamplingConfig.runTask':
ParamLoggingP.nc:504: interface has no command or event named `disableDock'
ParamLoggingP.nc:520: interface has no command or event named `enableDock'
ParamLoggingP.nc: At top level:
ParamLoggingP.nc:614: `Magnetometer.readDone': async mismatch with
declaration
/home/tiny2/tinyos-main/tos/platforms/shimmer2/chips/hmc5843/Magnetometer.nc:69:
previous declaration of `Magnetometer.readDone'
ParamLoggingP.nc:681: `Magnetometer.writeDone': async mismatch with
declaration
/home/tiny2/tinyos-main/tos/platforms/shimmer2/chips/hmc5843/Magnetometer.nc:71:
previous declaration of `Magnetometer.writeDone'
/home/tiny2/tinyos-main/tos/platforms/shimmer2r/chips/mma7361/Mma7361P.nc:45:2:
warning: #warning "This accelerometer chipset supports only 1.5 and 6.0g;
other settings will default to 1.5g"
In file included from ParamLoggingC.nc:84:
In component `FatFsP':
/home/tiny2/tinyos-main/tos/platforms/shimmer/chips/sd/fatfs/FatFsP.nc: In
function `f_mkfs':
/home/tiny2/tinyos-main/tos/platforms/shimmer/chips/sd/fatfs/FatFsP.nc:3150:
warning: decimal constant is so large that it is unsigned
In file included from
/home/tiny2/tinyos-main/tos/platforms/shimmer/chips/sd/fatfs/diskIOC.nc:50,
from ParamLoggingC.nc:84:
In component `SDP':
/home/tiny2/tinyos-main/tos/platforms/shimmer/chips/sd/SDP.nc: In function
`powerCycle':
/home/tiny2/tinyos-main/tos/platforms/shimmer/chips/sd/SDP.nc:142: warning:
decimal constant is so large that it is unsigned
In file included from
/home/tiny2/tinyos-main/tos/platforms/shimmer/chips/sd/fatfs/diskIOC.nc:55,
from ParamLoggingC.nc:84:
In component `TimeP':
/home/tiny2/tinyos-main/tos/platforms/shimmer/TimeP.nc: In function
`Time.setZoneInfo':
/home/tiny2/tinyos-main/tos/platforms/shimmer/TimeP.nc:121: warning:
assignment of read-only variable `g_first_year'
make: *** [exe0] Error 1



Can anybody help me somehow?

Thanks a lot
Gabbo
mike healy
2012-10-01 07:45:22 UTC
Permalink
Hi Gabriele,

The problem you are seeing is due to a missing update to the FAT filesystem
drivers (two new commands were added to the FatFs interface). These updates
were not committed when ParamLogging was first released (an oversight), but
this was rectified two weeks ago. You just need to update your tinyos-main
tree to version r6004 or later and then ParamLogging should compile for you
(i.e. navigate to the tinyos-main folder and run "svn update").

Mike
Post by Gabriele Spina
Dear all,
I've seen that in the repository ~/tinyos-2.x-contrib/shimmer/apps a new
firmware is present (ParamLogging) that allows to store the data in the SD.
shimmer2r
mkdir -p build/shimmer2r
compiling ParamLoggingC to a shimmer2r binary
ncc -o build/shimmer2r/main.exe -Os -O -DSMCLK_4MHZ -mdisable-hwmul
-fnesc-separator=__ -Wall -Wshadow -Wnesc-all -target=shimmer2r
-fnesc-cfile=build/shimmer2r/app.c -board= -DDEFINED_TOS_AM_GROUP=0x22
-DIDENT_APPNAME=\"ParamLoggingC\" -DIDENT_USERNAME=\"tiny2\"
-DIDENT_HOSTNAME=\"ShimmerLive\" -DIDENT_USERHASH=0xe8d0c5b7L
-DIDENT_TIMESTAMP=0x5068b97fL -DIDENT_UIDHASH=0x1e5da879L ParamLoggingC.nc
-lm
warning: #warning "Using enhanced/optimized version of FatFs............."
ParamLoggingP.nc:347: implicit declaration of function `__delay_cycles'
ParamLoggingP.nc:504: interface has no command or event named `disableDock'
ParamLoggingP.nc:520: interface has no command or event named `enableDock'
ParamLoggingP.nc:614: `Magnetometer.readDone': async mismatch with
declaration
previous declaration of `Magnetometer.readDone'
ParamLoggingP.nc:681: `Magnetometer.writeDone': async mismatch with
declaration
previous declaration of `Magnetometer.writeDone'
warning: #warning "This accelerometer chipset supports only 1.5 and 6.0g;
other settings will default to 1.5g"
/home/tiny2/tinyos-main/tos/platforms/shimmer/chips/sd/fatfs/FatFsP.nc: In
warning: decimal constant is so large that it is unsigned
In file included from
/home/tiny2/tinyos-main/tos/platforms/shimmer/chips/sd/fatfs/diskIOC.nc:50,
/home/tiny2/tinyos-main/tos/platforms/shimmer/chips/sd/SDP.nc: In function
warning: decimal constant is so large that it is unsigned
In file included from
/home/tiny2/tinyos-main/tos/platforms/shimmer/chips/sd/fatfs/diskIOC.nc:55,
/home/tiny2/tinyos-main/tos/platforms/shimmer/TimeP.nc: In function
assignment of read-only variable `g_first_year'
make: *** [exe0] Error 1
Can anybody help me somehow?
Thanks a lot
Gabbo
_______________________________________________
Shimmer-users mailing list
https://lists.eecs.harvard.edu/mailman/listinfo/shimmer-users
Gabriele Spina
2012-10-03 13:09:23 UTC
Permalink
Dear all,

I'm trying to use the ParamLogging application
(.../tiny2/tinyos-2.x-contrib/shimmer/apps/ParamLogging) to log
accelerometer and gyro values.
Thanks to Mike I'm able to compile and run it, but when I try to read the
data from the SD card I get weird results.

I tried both the Matlab code in the manual and the python code read_em.py
suggested to read data recorded using JustFATLogging.

Hereby you can see the code that I used:

MATLAB:

fid = fopen('.../../acceltot.bin');

more off

accelx = fread(fid, 'uint16', 4);
L = length(accelx);
t = (0:L-1)/50;

frewind(fid);
fseek(fid,2,'bof');
accely = fread(fid, 'uint16', 4);

frewind(fid);
fseek(fid,4,'bof');
accelz = fread(fid, 'uint16', 4);

frewind(fid);
fseek(fid,6,'bof');
gyrox = fread(fid, 'uint16', 10);

frewind(fid);
fseek(fid,8,'bof');
gyroy = fread(fid, 'uint16', 10);

frewind(fid);
fseek(fid,10,'bof');
gyroz = fread(fid, 'uint16', 10);

figure
subplot(3,1,1); plot(accelx, 'r'); title 'Accel X';
subplot(3,1,2); plot(accely, 'g'); title 'Accel Y';
subplot(3,1,3); plot(accelz, 'b'); title 'Accel Z';

figure
subplot(3,1,1); plot(gyrox, 'r'); title 'Gyro X';
subplot(3,1,2); plot(gyroy, 'g'); title 'Gyro Y';
subplot(3,1,3); plot(gyroz, 'b'); title 'Gyro Z';




Python


#!/usr/bin/python

import os, sys
import array

USAGE_TEXT = """
Usage: read_em.py <datafile>
"""

def usage():
print USAGE_TEXT
sys.exit(-1)

def read_it(filename):
try:
f = open(filename, 'r')
except:
print "can't open %s for read" % filename
sys.exit(-2)

finfo = os.stat(filename)
sz = finfo.st_size



sz = sz / 2
data = array.array('H')
data.fromfile(f, sz)

f.close()

return data

def print_em(data):
t = 0.00

s = len(data)
for i in range(0,s,6):
try:
print "%04.02f\t%d\t%d\t%d\t%d\t%d\t%d" % (t, data[i],
data[i+1], data[i+2],data[3], data[i+4], data[i+5])
except:
print "file has truncated data at index %d" % i
return

t = t + 0.02

def main(argv):
if len(argv) < 1:
usage()

data = read_it(argv[0])

print_em(data)

if __name__ == "__main__":
main(sys.argv[1:])



When I try to plot the data I get almost the same plots for accelerometer
values and gyro values and they look like the charger of a condenser....
I'm wondering if I'm doing some mistake reading the data or the
ParamLogging application has some bugs....did anyone use it before?

Thanks a lot for your help.
Gabriele
Niamh O'Mahony
2012-10-03 15:33:23 UTC
Permalink
Hi Gabriele,



Your code looks fine - I've tested the MATLAB version with data output by
ParamLogging and it's giving me meaningful results. I suggest you check that
you have saved the sample.cfg file in the top level directory of the SD card
on the shimmer and make sure that you have both the accelerometer and
gyroscope selected. (The example sample.cfg file from the ParamLogging
directory selects accelerometer and magnetometer by default so this will
have to be changed accordingly.) If ParamLogging does not find the
sample.cfg file in the top level directory of the SD card it should briefly
flash the red LED in warning and, then, default to logging accelerometer
data only.



Also, a word of caution - if the magnetometer is selected in sample.cfg but
a magnetometer daughtercard is not present, datalogging will fail and the
shimmer will need to be reset.



I hope this helps.



Best regards,

Niamh



_____

From: shimmer-users-***@eecs.harvard.edu
[mailto:shimmer-users-***@eecs.harvard.edu] On Behalf Of Gabriele Spina
Sent: 03 October 2012 14:09
To: shimmer-***@eecs.harvard.edu
Subject: [Shimmer-users] ParamLogging



Dear all,



I'm trying to use the ParamLogging application
(.../tiny2/tinyos-2.x-contrib/shimmer/apps/ParamLogging) to log
accelerometer and gyro values.

Thanks to Mike I'm able to compile and run it, but when I try to read the
data from the SD card I get weird results.



I tried both the Matlab code in the manual and the python code read_em.py
suggested to read data recorded using JustFATLogging.



Hereby you can see the code that I used:



MATLAB:

fid = fopen('.../../acceltot.bin');

more off

accelx = fread(fid, 'uint16', 4);

L = length(accelx);
t = (0:L-1)/50;

frewind(fid);
fseek(fid,2,'bof');

accely = fread(fid, 'uint16', 4);

frewind(fid);
fseek(fid,4,'bof');

accelz = fread(fid, 'uint16', 4);

frewind(fid);
fseek(fid,6,'bof');

gyrox = fread(fid, 'uint16', 10);

frewind(fid);
fseek(fid,8,'bof');

gyroy = fread(fid, 'uint16', 10);

frewind(fid);
fseek(fid,10,'bof');

gyroz = fread(fid, 'uint16', 10);

figure
subplot(3,1,1); plot(accelx, 'r'); title 'Accel X';

subplot(3,1,2); plot(accely, 'g'); title 'Accel Y';
subplot(3,1,3); plot(accelz, 'b'); title 'Accel Z';

figure
subplot(3,1,1); plot(gyrox, 'r'); title 'Gyro X';
subplot(3,1,2); plot(gyroy, 'g'); title 'Gyro Y';
subplot(3,1,3); plot(gyroz, 'b'); title 'Gyro Z';








Python







#!/usr/bin/python

import os, sys
import array

USAGE_TEXT = """
Usage: read_em.py <datafile>
"""

def usage():
print USAGE_TEXT
sys.exit(-1)

def read_it(filename):
try:
f = open(filename, 'r')
except:
print "can't open %s for read" % filename
sys.exit(-2)

finfo = os.stat(filename)
sz = finfo.st_size



sz = sz / 2
data = array.array('H')
data.fromfile(f, sz)

f.close()

return data

def print_em(data):
t = 0.00

s = len(data)
for i in range(0,s,6):
try:
print "%04.02f\t%d\t%d\t%d\t%d\t%d\t%d" % (t, data[i],
data[i+1], data[i+2],data[3], data[i+4], data[i+5])
except:
print "file has truncated data at index %d" % i
return

t = t + 0.02

def main(argv):
if len(argv) < 1:
usage()

data = read_it(argv[0])

print_em(data)

if __name__ == "__main__":
main(sys.argv[1:])






When I try to plot the data I get almost the same plots for accelerometer
values and gyro values and they look like the charger of a condenser....

I'm wondering if I'm doing some mistake reading the data or the ParamLogging
application has some bugs....did anyone use it before?



Thanks a lot for your help.

Gabriele
Niamh O'Mahony
2012-10-03 15:45:14 UTC
Permalink
Hi again Gabriele,



A correction to your MATLAB code that I forgot to mention - you must skip 10
bytes when you read the accelx, accely and accelz values, not 4 bytes. This,
along with my previous email should solve your problem.



Best regards,

Niamh



_____

From: shimmer-users-***@eecs.harvard.edu
[mailto:shimmer-users-***@eecs.harvard.edu] On Behalf Of Niamh O'Mahony
Sent: 03 October 2012 16:33
To: 'Gabriele Spina'; shimmer-***@eecs.harvard.edu
Subject: Re: [Shimmer-users] ParamLogging



Hi Gabriele,



Your code looks fine - I've tested the MATLAB version with data output by
ParamLogging and it's giving me meaningful results. I suggest you check that
you have saved the sample.cfg file in the top level directory of the SD card
on the shimmer and make sure that you have both the accelerometer and
gyroscope selected. (The example sample.cfg file from the ParamLogging
directory selects accelerometer and magnetometer by default so this will
have to be changed accordingly.) If ParamLogging does not find the
sample.cfg file in the top level directory of the SD card it should briefly
flash the red LED in warning and, then, default to logging accelerometer
data only.



Also, a word of caution - if the magnetometer is selected in sample.cfg but
a magnetometer daughtercard is not present, datalogging will fail and the
shimmer will need to be reset.



I hope this helps.



Best regards,

Niamh



_____

From: shimmer-users-***@eecs.harvard.edu
[mailto:shimmer-users-***@eecs.harvard.edu] On Behalf Of Gabriele Spina
Sent: 03 October 2012 14:09
To: shimmer-***@eecs.harvard.edu
Subject: [Shimmer-users] ParamLogging



Dear all,



I'm trying to use the ParamLogging application
(.../tiny2/tinyos-2.x-contrib/shimmer/apps/ParamLogging) to log
accelerometer and gyro values.

Thanks to Mike I'm able to compile and run it, but when I try to read the
data from the SD card I get weird results.



I tried both the Matlab code in the manual and the python code read_em.py
suggested to read data recorded using JustFATLogging.



Hereby you can see the code that I used:



MATLAB:

fid = fopen('.../../acceltot.bin');

more off

accelx = fread(fid, 'uint16', 4);

L = length(accelx);
t = (0:L-1)/50;

frewind(fid);
fseek(fid,2,'bof');

accely = fread(fid, 'uint16', 4);

frewind(fid);
fseek(fid,4,'bof');

accelz = fread(fid, 'uint16', 4);

frewind(fid);
fseek(fid,6,'bof');

gyrox = fread(fid, 'uint16', 10);

frewind(fid);
fseek(fid,8,'bof');

gyroy = fread(fid, 'uint16', 10);

frewind(fid);
fseek(fid,10,'bof');

gyroz = fread(fid, 'uint16', 10);

figure
subplot(3,1,1); plot(accelx, 'r'); title 'Accel X';

subplot(3,1,2); plot(accely, 'g'); title 'Accel Y';
subplot(3,1,3); plot(accelz, 'b'); title 'Accel Z';

figure
subplot(3,1,1); plot(gyrox, 'r'); title 'Gyro X';
subplot(3,1,2); plot(gyroy, 'g'); title 'Gyro Y';
subplot(3,1,3); plot(gyroz, 'b'); title 'Gyro Z';








Python











#!/usr/bin/python

import os, sys
import array

USAGE_TEXT = """
Usage: read_em.py <datafile>
"""

def usage():
print USAGE_TEXT
sys.exit(-1)

def read_it(filename):
try:
f = open(filename, 'r')
except:
print "can't open %s for read" % filename
sys.exit(-2)

finfo = os.stat(filename)
sz = finfo.st_size



sz = sz / 2
data = array.array('H')
data.fromfile(f, sz)

f.close()

return data

def print_em(data):
t = 0.00

s = len(data)
for i in range(0,s,6):
try:
print "%04.02f\t%d\t%d\t%d\t%d\t%d\t%d" % (t, data[i],
data[i+1], data[i+2],data[3], data[i+4], data[i+5])
except:
print "file has truncated data at index %d" % i
return

t = t + 0.02

def main(argv):
if len(argv) < 1:
usage()

data = read_it(argv[0])

print_em(data)

if __name__ == "__main__":
main(sys.argv[1:])






When I try to plot the data I get almost the same plots for accelerometer
values and gyro values and they look like the charger of a condenser....

I'm wondering if I'm doing some mistake reading the data or the ParamLogging
application has some bugs....did anyone use it before?



Thanks a lot for your help.

Gabriele
Gabriele Spina
2012-10-03 16:38:12 UTC
Permalink
Dear Niamh,

thank you so much!
I'm really sorry...it was my fault.
I misinterpreted the instruction in the README file thinking that the
configuration file is called while compiling the firmware.
Before, indeed, I didn't save the sample.cfg file in the SD card. Now it
works correctly.
Last question....would be it possible to set different sampling frequencies
for the sensors? (in particular for the accelerometer and ECG)

Have a nice evening,
Gabriele
Hi again Gabriele,****
** **
A correction to your MATLAB code that I forgot to mention – you must skip
10 bytes when you read the accelx, accely and accelz values, not 4 bytes.
This, along with my previous email should solve your problem.****
** **
Best regards,****
Niamh****
** **
------------------------------
*Sent:* 03 October 2012 16:33
*Subject:* Re: [Shimmer-users] ParamLogging****
** **
Hi Gabriele,****
** **
Your code looks fine – I’ve tested the MATLAB version with data output by
ParamLogging and it’s giving me meaningful results. I suggest you check
that you have saved the sample.cfg file in the top level directory of the
SD card on the shimmer and make sure that you have both the accelerometer
and gyroscope selected. (The example sample.cfg file from the ParamLogging
directory selects accelerometer and magnetometer by default so this will
have to be changed accordingly.) If ParamLogging does not find the
sample.cfg file in the top level directory of the SD card it should briefly
flash the red LED in warning and, then, default to logging accelerometer
data only. ****
** **
Also, a word of caution - if the magnetometer is selected in sample.cfg
but a magnetometer daughtercard is not present, datalogging will fail and
the shimmer will need to be reset.****
** **
I hope this helps.****
** **
Best regards,****
Niamh****
** **
------------------------------
*Sent:* 03 October 2012 14:09
*Subject:* [Shimmer-users] ParamLogging****
** **
Dear all,****
** **
I'm trying to use the ParamLogging application
(.../tiny2/tinyos-2.x-contrib/shimmer/apps/ParamLogging) to log
accelerometer and gyro values.****
Thanks to Mike I'm able to compile and run it, but when I try to read the
data from the SD card I get weird results.****
** **
I tried both the Matlab code in the manual and the python code read_em.py
suggested to read data recorded using JustFATLogging.****
** **
Hereby you can see the code that I used:****
** **
MATLAB:****
fid = fopen('.../../acceltot.bin');****
** **
more off****
** **
accelx = fread(fid, 'uint16', 4);****
** **
L = length(accelx);****
t = (0:L-1)/50;****
** **
frewind(fid);****
fseek(fid,2,'bof');****
** **
accely = fread(fid, 'uint16', 4);****
** **
frewind(fid);****
fseek(fid,4,'bof');****
** **
accelz = fread(fid, 'uint16', 4);****
** **
frewind(fid);****
fseek(fid,6,'bof');****
** **
gyrox = fread(fid, 'uint16', 10);****
** **
frewind(fid);****
fseek(fid,8,'bof');****
** **
gyroy = fread(fid, 'uint16', 10);****
** **
frewind(fid);****
fseek(fid,10,'bof');****
** **
gyroz = fread(fid, 'uint16', 10);****
** **
figure****
subplot(3,1,1); plot(accelx, 'r'); title 'Accel X';****
** **
subplot(3,1,2); plot(accely, 'g'); title 'Accel Y';****
subplot(3,1,3); plot(accelz, 'b'); title 'Accel Z';****
** **
figure****
subplot(3,1,1); plot(gyrox, 'r'); title 'Gyro X';****
subplot(3,1,2); plot(gyroy, 'g'); title 'Gyro Y';****
subplot(3,1,3); plot(gyroz, 'b'); title 'Gyro Z';****
** **
** **
** **
** **
Python****
** **
** **
****
#!/usr/bin/python****
** **
import os, sys****
import array****
** **
USAGE_TEXT = """****
Usage: read_em.py <datafile>****
"""****
** **
def usage():****
print USAGE_TEXT****
sys.exit(-1)****
** **
def read_it(filename):****
try:****
f = open(filename, 'r')****
except:****
print "can't open %s for read" % filename****
sys.exit(-2)****
****
finfo = os.stat(filename)****
sz = finfo.st_size****
** **
** **
** **
sz = sz / 2****
data = array.array('H')****
data.fromfile(f, sz)****
** **
f.close()****
** **
return data****
** **
def print_em(data):****
t = 0.00****
** **
s = len(data)****
for i in range(0,s,6):****
try:****
print "%04.02f\t%d\t%d\t%d\t%d\t%d\t%d" % (t, data[i], data[i+1], data[i+2],data[3], data[i+4], data[i+5])****
except:****
print "file has truncated data at index %d" % i****
return****
****
t = t + 0.02****
****
def main(argv): ****
if len(argv) < 1:****
usage() ****
** **
data = read_it(argv[0])****
** **
print_em(data)****
****
if __name__ == "__main__":****
main(sys.argv[1:])****
** **
** **
** **
When I try to plot the data I get almost the same plots for accelerometer
values and gyro values and they look like the charger of a condenser....**
**
I'm wondering if I'm doing some mistake reading the data or the
ParamLogging application has some bugs....did anyone use it before?****
** **
Thanks a lot for your help.****
Gabriele****
Niamh O'Mahony
2012-10-04 07:14:31 UTC
Permalink
Hi Gabriele,



The sampling frequency will be the same for all sensors. You should set the
highest frequency you require (this can be done in the sample.cfg file) and
then you can downsample the signals as required in postprocessing.



Best regards,

Niamh



_____

From: Gabriele Spina [mailto:***@gmail.com]
Sent: 03 October 2012 17:38
To: shimmer-***@eecs.harvard.edu
Cc: Niamh O'Mahony
Subject: Re: [Shimmer-users] ParamLogging



Dear Niamh,



thank you so much!

I'm really sorry...it was my fault.

I misinterpreted the instruction in the README file thinking that the
configuration file is called while compiling the firmware.

Before, indeed, I didn't save the sample.cfg file in the SD card. Now it
works correctly.

Last question....would be it possible to set different sampling frequencies
for the sensors? (in particular for the accelerometer and ECG)



Have a nice evening,

Gabriele

On 3 October 2012 17:45, Niamh O'Mahony <***@shimmer-research.com>
wrote:

Hi again Gabriele,



A correction to your MATLAB code that I forgot to mention - you must skip 10
bytes when you read the accelx, accely and accelz values, not 4 bytes. This,
along with my previous email should solve your problem.



Best regards,

Niamh



_____

From: shimmer-users-***@eecs.harvard.edu
[mailto:shimmer-users-***@eecs.harvard.edu] On Behalf Of Niamh O'Mahony
Sent: 03 October 2012 16:33
To: 'Gabriele Spina'; shimmer-***@eecs.harvard.edu
Subject: Re: [Shimmer-users] ParamLogging



Hi Gabriele,



Your code looks fine - I've tested the MATLAB version with data output by
ParamLogging and it's giving me meaningful results. I suggest you check that
you have saved the sample.cfg file in the top level directory of the SD card
on the shimmer and make sure that you have both the accelerometer and
gyroscope selected. (The example sample.cfg file from the ParamLogging
directory selects accelerometer and magnetometer by default so this will
have to be changed accordingly.) If ParamLogging does not find the
sample.cfg file in the top level directory of the SD card it should briefly
flash the red LED in warning and, then, default to logging accelerometer
data only.



Also, a word of caution - if the magnetometer is selected in sample.cfg but
a magnetometer daughtercard is not present, datalogging will fail and the
shimmer will need to be reset.



I hope this helps.



Best regards,

Niamh



_____

From: shimmer-users-***@eecs.harvard.edu
[mailto:shimmer-users-***@eecs.harvard.edu] On Behalf Of Gabriele Spina
Sent: 03 October 2012 14:09
To: shimmer-***@eecs.harvard.edu
Subject: [Shimmer-users] ParamLogging



Dear all,



I'm trying to use the ParamLogging application
(.../tiny2/tinyos-2.x-contrib/shimmer/apps/ParamLogging) to log
accelerometer and gyro values.

Thanks to Mike I'm able to compile and run it, but when I try to read the
data from the SD card I get weird results.



I tried both the Matlab code in the manual and the python code read_em.py
suggested to read data recorded using JustFATLogging.



Hereby you can see the code that I used:



MATLAB:

fid = fopen('.../../acceltot.bin');

more off

accelx = fread(fid, 'uint16', 4);

L = length(accelx);
t = (0:L-1)/50;

frewind(fid);
fseek(fid,2,'bof');

accely = fread(fid, 'uint16', 4);

frewind(fid);
fseek(fid,4,'bof');

accelz = fread(fid, 'uint16', 4);

frewind(fid);
fseek(fid,6,'bof');

gyrox = fread(fid, 'uint16', 10);

frewind(fid);
fseek(fid,8,'bof');

gyroy = fread(fid, 'uint16', 10);

frewind(fid);
fseek(fid,10,'bof');

gyroz = fread(fid, 'uint16', 10);

figure
subplot(3,1,1); plot(accelx, 'r'); title 'Accel X';

subplot(3,1,2); plot(accely, 'g'); title 'Accel Y';
subplot(3,1,3); plot(accelz, 'b'); title 'Accel Z';

figure
subplot(3,1,1); plot(gyrox, 'r'); title 'Gyro X';
subplot(3,1,2); plot(gyroy, 'g'); title 'Gyro Y';
subplot(3,1,3); plot(gyroz, 'b'); title 'Gyro Z';








Python


















#!/usr/bin/python

import os, sys
import array

USAGE_TEXT = """
Usage: read_em.py <datafile>
"""

def usage():
print USAGE_TEXT
sys.exit(-1)

def read_it(filename):
try:
f = open(filename, 'r')
except:
print "can't open %s for read" % filename
sys.exit(-2)

finfo = os.stat(filename)
sz = finfo.st_size



sz = sz / 2
data = array.array('H')
data.fromfile(f, sz)

f.close()

return data

def print_em(data):
t = 0.00

s = len(data)
for i in range(0,s,6):
try:
print "%04.02f\t%d\t%d\t%d\t%d\t%d\t%d" % (t, data[i],
data[i+1], data[i+2],data[3], data[i+4], data[i+5])
except:
print "file has truncated data at index %d" % i
return

t = t + 0.02

def main(argv):
if len(argv) < 1:
usage()

data = read_it(argv[0])

print_em(data)

if __name__ == "__main__":
main(sys.argv[1:])






When I try to plot the data I get almost the same plots for accelerometer
values and gyro values and they look like the charger of a condenser....

I'm wondering if I'm doing some mistake reading the data or the ParamLogging
application has some bugs....did anyone use it before?



Thanks a lot for your help.

Gabriele

Loading...