Two arduino Uno with 4 MPU6050 MATLAB

조회 수: 1 (최근 30일)
hamad alzaabi
hamad alzaabi 2021년 4월 10일
Greetings,
I have connected two arduino uno with 4 mpu6050 IMUs and attached all of them to a body, i want to take accleration of the body if it moves, not when it is at rest. I donwnloaded Arduino support package for MATLAB, and tried different logic of code to take measurements from MPU6050 only when it moves, unfortunatley I get all the measurements while moving and at rest, please propose any modification to the code>>
%%
Generating IMUs readings through Arduino UNO:
% Identifying Two Arduino Uno
Right = arduino('COM9', 'Uno', 'Libraries', 'I2C');
LEFT = arduino('COM10', 'Uno', 'Libraries', 'I2C');
% Declaring 4 MPU6050 IMUs
imu1= mpu6050(Right,'SampleRate',160,'SamplesPerRead',10,'I2CAddress','0x68','ReadMode','Latest');
imu2 = mpu6050(Right,'SampleRate',160,'SamplesPerRead',10,'I2CAddress','0x69','ReadMode','Latest');
imu3 = mpu6050(LEFT,'SampleRate',160,'SamplesPerRead',10,'I2CAddress','0x68','ReadMode','Latest');
imu4 = mpu6050(LEFT,'SampleRate',160,'SamplesPerRead',10,'I2CAddress','0x69','ReadMode','Latest');
% logging measurements
IMU1_mueasurements=zeros(100,3);
IMU2_mueasurements=zeros(100,3);
IMU3_mueasurements=zeros(100,3);
IMU4_mueasurements=zeros(100,3);
accelReadings1=zeros(100,3);
accelReadings2=zeros(100,3);
accelReadings3=zeros(100,3);
accelReadings4=zeros(100,3);
[accelReadings1(1,:)] = readAcceleration(imu1);
[accelReadings2(1,:)] = readAcceleration(imu2);
[accelReadings3(1,:)] = readAcceleration(imu3);
[accelReadings4(1,:)] = readAcceleration(imu4);
for R= 2:100
[accelReadings1(R,:)] = readAcceleration(imu1)
if (accelReadings1(R)-accelReadings1(R-1))>0.5
IMU1_mueasurements(R)=accelReadings1(R);
end
[accelReadings2(R,:)] = readAcceleration(imu2)
if (accelReadings2(R)-accelReadings2(R-1))>0.5
IMU2_mueasurements(R)=accelReadings2(R);
end
[accelReadings3(R,:)] = readAcceleration(imu3)
if (accelReadings3(R)-accelReadings3(R-1))>0.5
IMU3_mueasurements(R)=accelReadings3(R);
end
[accelReadings4(R,:)] = readAcceleration(imu4)
if (accelReadings4(R)-accelReadings4(R-1))>0.5
IMU4_mueasurements(R)=accelReadings4(R);
end
end
%%

답변 (0개)

카테고리

Help CenterFile Exchange에서 Simulink Supported Hardware에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by