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
while (abs(Wz) < 2500) | |
fprintf(xbee,'M') ; | |
notArrived = false; | |
try | |
while (get(xbee, 'BytesAvailable')~=0 && ~notArrived) | |
% read until terminator | |
sentence = fscanf( xbee, '%s'); % this reads in as a string (until a terminater is reached) | |
if (strcmp(sentence(1,1),'A')) | |
notArrived = true; | |
%% store and plot |
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
% Save angular rates from the received CSV string | |
C = textscan(sentence,'%c %d %d %d %c','delimiter',','); | |
Wx = C{2}; | |
% update the buffer | |
gxdata = [ gxdata(2:end) ; Wx ]; | |
% Plot, anzi subPlot! | |
subplot(3,1,1); | |
title('X Axis Omega in deg/s'); |
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
%% Arduino Gyroscope real time plot | |
% userk.co.uk | |
% The sensor used in this project is the L3G4200D | |
% !!Caution!! operative voltage: 3.3 V | |
clear all; | |
clc; | |
clear('instrfindall'); | |
%% Check serial objects & Connect to Port |
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 serialRoutine() | |
{ | |
if(Serial.available()>0) | |
{ | |
char t = Serial.read(); | |
if (t =='T') | |
{ | |
Serial.println("Ok"); | |
} |
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
%% Ask desired Sample Rate in Hz | |
rate=input('Enter the sampleRate in Hz. Max 500Hz. Non sgravare... '); | |
delay = 1/rate; | |
str = sprintf('SampleRate fixed to: %f.', delay); | |
disp(str); | |
%% Initializinig rolling plot | |
buf_len = rate; | |
index = 1:buf_len; |
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
fprintf(xbee,'M') ; | |
notArrived = false; | |
try | |
while (get(xbee, 'BytesAvailable')~=0 && ~notArrived) | |
% read until terminator | |
sentence = fscanf( xbee, '%s'); % this reads in as a string (until a terminater is reached) | |
if (strcmp(sentence(1,1),'A')) | |
notArrived = true; | |
%decodes "sentence" seperated (delimted) by commaseck Unit') | |
C = textscan(sentence,'%c %d %d %d %c','delimiter',','); |
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
% wait one second then record | |
if numberOfSamples==rate*2 && recording | |
disp('saving samples to file'); | |
gDataToWrite = [gxdata gydata gzdata]; | |
csvwrite('samples.txt',gDataToWrite); | |
disp('saving file to structure'); | |
dat.x = gxdata; | |
dat.y = gydata; | |
dat.z = gzdata; | |
save('samples.mat','-struct','dat'); |
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
%% Arduino Gyroscope real time plot | |
% The sensor used in this project is the L3G4200D | |
clear all; | |
clc; | |
clear('instrfindall'); | |
finished = false; | |
recording = true; |
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
%% Signal definition | |
% Sampling Frequency Fs | |
Fs = 350; | |
% Sinusoid frequency | |
freq = 30; | |
bias = 15 | |
t = 0:1/Fs:1; | |
% Generate random values [min,max] = [xm,xM] |