Matlab Mobile - Extracting my sensor data isnt working properly.

15 views (last 30 days)
Hello all,
i am working with matlab mobile and i am facing a rather annoying problem. I dont even know if it is caused by Matlab Mobile/Matlab/Android or my Smartphone. I work with Matlab R2016a.
After i have created a successful connection between the smartphone and matlab and logged some data, i want to extract it via [Accel, t_Accel] = accellog(m). But the results i get seem to be corrupt/broken. The timevector isnt contiguous and i receive too few data. If i shake my phone for like 15 seconds and the contiguous party of timevec imply a frequency of ~12 Hz my Datamatrix is only 70x3 and not ~180x3 as i would expect.
Does anyone of you know where my problem occurs from? I tested 2 different smartphones and controlling matlab mobile on the smartphone and in matlab with console commands (m.Logging =1 ; m.Logging =0;) and i still get similar problems.
I hope someone has a smart idea.
Greetings

Answers (1)

Daniel Hauch
Daniel Hauch on 30 Oct 2017
I fixed the problem!
If anyone is interested, i will write a quick report.
Making timevector contiguous: delete old mobiledev and create a new one. I dont know why this problem occurs, but this is a simple fix.
Receive logged data completly: Matlab Mobile needs quite some time to postprocess the logged data. Therefore you have to wait some time until the log-functions return vectors with the appropiate length. I automated this process with the code showing below:
t_Accel_old = 0;
while true
%get data from mobiledev and save in var
[Accel, t_Accel] = accellog(m);
if length(t_Accel_old)==length(t_Accel)
break;
end
t_Accel_old = t_Accel;
pause(2);
end
I hope my explanation is helpful and saves someone some time.
Greetings
  1 Comment
Bushra
Bushra on 16 Dec 2023
clc;
clear all;
clear a;
a = arduino('COM5', 'Uno');
fs = 100; % Sample Rate in Hz
imu = mpu6050(a,'SampleRate',fs,'OutputFormat','matrix');
ts = tic;
stopTimer = 50;
magReadings=[];
while(toc(ts) < stopTimer)
[accel,gyro] = read(imu);
end
GyroscopeNoiseMPU9250 = 3.0462e-06; % GyroscopeNoise (variance value) in units of rad/s
AccelerometerNoiseMPU9250 = 0.0061; % AccelerometerNoise (variance value) in units of m/s^2
viewer = HelperOrientationViewer('Title',{'AHRS Filter'});
FUSE = ahrsfilter('SampleRate',imu.SampleRate, 'GyroscopeNoise',GyroscopeNoiseMPU9250,'AccelerometerNoise',AccelerometerNoiseMPU9250);
stopTimer = 100;
ts = tic;
while(toc(ts) < stopTimer)
[accel,gyro] = read(imu);
% Align coordinates in accordance with NED convention
accel = [-accel(:,2), -accel(:,1), accel(:,3)];
gyro = [gyro(:,2), gyro(:,1), -gyro(:,3)];
rotators = FUSE(accel,gyro);
for j = numel(rotators)
viewer(rotators(j));
end
end
I am reading data from mpu6050 using arduino in MATLAB. I am receiving this error
Error using mpu6050_Arduino12
Command logs are not supported for sensors. Create the hardware Object with property 'TraceOn' disabled.
Can you help me with that?

Sign in to comment.

Communities

More Answers in the  Distance Learning Community

Categories

Find more on Manage Products in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!