This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%% Analyze signal | |
% Plots magnitude spectrum of the signal | |
X_mags=abs(fft(y)); | |
figure(2) | |
plot(X_mags); | |
xlabel('DFT Bins'); | |
ylabel('Magnitude'); | |
% Plots first half of DFT (normalized frequency) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%% Filter Design | |
% Designs a second order filter using a butterworth design guidelines | |
[b a] = butter(2,0.2,'high'); | |
% Plot the frequency response (normalized frequency) | |
figure(3) | |
H = freqz(b,a,floor(num_bins/2)); | |
plot(0:1/(num_bins/2 -1):1, abs(H), 'r'); | |
hold on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Filters the signal using coefficients obtained by the butter filter | |
% design | |
x_filtered = filter(b,a,y); | |
% Plots the filtered signal | |
figure(4) | |
plot(t,x_filtered,'r') | |
hold on | |
plot(t,y0,'k','LineWidth',2) | |
hold on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%% Real Signal definition | |
% Sampling Frequency Fs | |
Fs = 350; | |
% Sinusoid frequency | |
freq = 30; | |
bias = 1 | |
maxTime = 2; | |
t = 0:1/Fs:maxTime; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
yEasy = y - mean(y); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% This scipt loads and plots data from a .mat file | |
clc | |
gxFdata = 0; | |
gyFdata = 0; | |
gzFdata = 0; | |
% Loads samples from file | |
dat = load('GyroSamples.mat'); | |
dat = load('samples.mat'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%% Quick HP Filter | |
% 02/08/15 -> More info @ userk.co.uk | |
clear all; | |
clc; | |
%% IDEAL Signal definition | |
% Sampling Frequency Fs | |
Fs = 350; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void printCSVomega() | |
{ | |
Serial.print("A,"); | |
Serial.print(x); | |
Serial.print(","); | |
Serial.print(y); | |
Serial.print(","); | |
Serial.print(z); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void setup() | |
{ | |
Wire.begin(); | |
Serial.begin(9600); | |
Serial.println("starting up L3G4200D"); | |
// Configure L3G4200 - 250, 500 or 2000 deg/sec | |
setupL3G4200D(250); | |
delay(1500); //wait for the sensor to be ready | |
k = millis(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void setup() | |
{ | |
Wire.begin(); | |
Serial.begin(57600); | |
Serial.println("starting up L3G4200D"); | |
// Configure L3G4200 - 250, 500 or 2000 deg/sec | |
setupL3G4200D(2000); | |
delay(1500); //wait for the sensor to be ready | |
k = millis(); | |
} |