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: [email protected]
[mailto:[email protected]] On Behalf Of Niamh O'Mahony
Sent: 03 October 2012 16:33
To: 'Gabriele Spina'; [email protected]
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: [email protected]
[mailto:[email protected]] On Behalf Of Gabriele Spina
Sent: 03 October 2012 14:09
To: [email protected]
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

_______________________________________________
Shimmer-users mailing list
[email protected]
https://lists.eecs.harvard.edu/mailman/listinfo/shimmer-users

Reply via email to