Saturday, August 30, 2008

Wiimote and Auto Power Spectrum (en)

[english version]

Wiimote and Auto Power Spectrum


[Auto Power Spectrum |AZ(f)|² from a 2Hz-pulse]

Modal analysis is used to obtain Power Spectrum from accelerometer. Quickly (see the tech. note for more info.), the aim of this analysis is an identification of frequencies from a recorded signal. The wiimote's accelerometer is able to record signal with a range of frequency between [0Hz 25Hz]. This range is useful for mechanical constraints of human body. (Soldering skills can allow you to extend this range but this is not the purpose of this post). Then, some notions from signal processing need to be described.

1. Sampling

Theorically, the bluetooth connection allows an acquisition of 100 frames per second. But the bluetooth stack management, the Operating System, applications and other peripherals are very disturbing for the acquisition chain Wiimote-Matlab :

Theor., acquisition step is around 0.01s.

A Gaussian distribution with a short standard deviation centered around 0.01s is tolerated. However, this
statistical distribution is not temporally-granted. So, a re-sampling is necessary without too much information losses. Here, an acquisition step of 0.02s (25Hz) were chosen. Well, thoughtful by Nintendo engineers, capacitor limitations of accelerometer range (max. 25Hz) can be considered as an anti-aliasing filter. (Be aware of anti-aliasing if re-sampling period is up to 0.02s.)





[right picture : Distribution of acquisition steps /
Recording Wiimote data with fWIIne ]


2. Fast Fourier Transform (FFT)

One example of an application of FFT to wiimote measurements :


[FFT of signals ax(t), ay(t), az(t) - repetitive arm movements ]

Auto Power Spectrum (APS) comes from FFT computation and provides signal power for a given frequency.
It was necessary to compare Power Spectrum of Both signals before and after re-sampling in order to control efficiency of the re-sampling :



[Zoom of range 8.5-11.5Hz : Auto Power Spectrum from a 10Hz-pulse - Re-sampled signal indicates 10Hz, properly, whereas first signal was erroneous
with a peak frequency of 10.2Hz]












[The Power Spectrum (left side : 2Hz pulse) is in accordance with theorical spectrum of pulses - right side]

3. Experiment - Technical aspects :

Steps :

Pulses were produced at a defined frequency - 1Hz, 2Hz, 10Hz - from a subwoofer (from a computer). The wiimote is located on the top of the subwoofer, horizontally. Recording the values with fWIIne v0.2 for Matlab/Windows XP :

- 1st step : Data Acquisition. At the end, a filename is asked in order to save a txt file.
- 2nd step : Data analysis. In the same directory, loading the file.


N

Comment

Matlab file

Example Stimulus / Measure

1

Data acquisitionwith fWIIne

fwiine_recording_experiment.m

test_#Hz.wav

2

Spectrum analysis

accel_fft_wiimote.m

Acquis#Hz_1.txt

Then some stimuli and measures were performed :


Frq

Stimulus

Measurement files of Wii Remote accel. sensor

1 Hz

test_1Hz.wav

acquis1Hz_1.txt

2 Hz

test_2Hz.wav

acquis2Hz_1.txt

10 Hz

test_10Hz.wav

acquis10Hz_1.txt



NB: Using an older release fWIIne v0.1 for Matlab/WinXP, the user will have to adapt the acquisition file, slightly.

In spite of a restricted frequency range, the wiimote allows recording data and Power Spectrum analysis for given experiments and for educational purposes.

6 comments:

Anonymous said...

Looks like you have done some good work here. I am trying to do some similar computations with LabView and MatLab and I can not find info on the Auto Power Spectrum, could you elaborate on what you have done in your matlab code

wiilliam said...

Hi,

Quickly, you will find a description of required steps to provide the power spectrum from accelerometer data :
- resampling (around the average sampling values) and zero-cleaning
- filtering (lowpass filter, mainly)
- FFT (including a Hanning Window)
- averaging (...)
- Displaying |X(f)|²
- Finally displaying spectrogram

Hope it will help you.
Wiilliam

Anonymous said...

Can you give info on the sub-woofer used? Can it reliably produce the frequencies involved?

Many thanks,
L.

wiilliam said...

Hi,

Please note : Here the analysis is based on periodic [pulses]. You can listen to the audio files.
The analyse is not based on a "pure" sine signal to 1Hz which isn't possible with a .wav file, I suppose.

Wiilliam


(just FYI : Altec Lansing )

Anonymous said...

hi,
Actually I am doing some tests about Operational Modal analysis.
could you give me some refrence regarding matlab codes?
also, is there a specific code for auto power spectrum in matlab?
is it different from usual power spectrum?
Thx

wiilliam said...

Hi,

Well, you could find some examples inside the fwiine sourcefiles and also inside Mathworks forums/ressources available on the net.
No, there is no difference between power strum and auto power spectrum. (just to make the difference with cross power spectrum).

Hope my explanations will help you
- Wiilliam