Defining measurement range for MPU 6050 Gyro connected through arduino

36 visualizaciones (últimos 30 días)
Bar Danino
Bar Danino el 10 de Nov. de 2022
Respondida: Prateek el 24 de Nov. de 2022
I've successfully connected my MPU 6050 to MATLAB (through an Arduino Uno) and have measured acceleration and angular velocity, however the default sensor range is insufficient for me and I can't find a way to increase it.
The default angular velocity range is 250 dps, but that is not enough for my purposes, as I have angular velocities of more than a thousand dps. I know that the sensor is capable of changing its measurement range to up to 2000 dps (by sacrificing resolution, which is not an issue in my case), and while I have successfully done that when programming the arduino itself (I've confirmed this by printing the data to the serial monitor), I haven't been able to change the range when using MATLAB. My results get "cropped" due to this issue.
Is it possible to change the range in this way? If so, how?
As a side note, is there a way to shift the gyroscope values (to calibrate it)? When at rest it shows a (near-)constant non-zero value (that isn't as important to me as the range issue though).
Thanks
a = arduino('COM4', 'Uno', 'Libraries', 'I2C');
imu = mpu6050(a,'SampleRate',200,'SamplesPerRead',500,'TimeFormat','duration');
disp("begin")
pause(1)
imu.release();
t = imu.read();

Respuestas (1)

Prateek
Prateek el 24 de Nov. de 2022
Hi Bar,
The Gyroscope range for the MPU6050 sensor in MATLAB is currently fixed at +/-250 dps. However, there exists a workaround to unlock the full range, using custom code. For this, please follow these instructions:
1. Execute the following command in the MATLAB Command Window. This will change the current directory of MATLAB to the directory where sensor files are stored:
>> sensorpth = fullfile(matlabshared.supportpkg.getSupportPackageRoot,'toolbox','matlab','hardware','shared','sensors')
>> cd(sensorpth)
2. Replace the mpu6050.m file in the above location with the custom mpu6050.m file (attached here).
3. Execute the following commands in the command window :
>> clear classes
>> rehash toolboxcache
4. Now, to change Accelerometer and Gyroscope range from the default value, use the 'Name Value' pairs 'AccelerometerRange' and 'GyroscopeRange'. For example, to set the accelerometer range as +/-4g and gyroscope range as +/-500 dps, the mpu6050 object needs to be created as follows:
>> imu = mpu6050(a, 'AccelerometerRange', 4, 'GyroscopeRange', 500)
The arguments to this object creation can be decided based on the following notes:
AccelerometerRange: Full-scale acceleration range in 'g'.
Possible values : 2,4,8,16
Default: 2
GyroscopeRange: Full-scale angular velocity range in “degrees per seconds (dps)”.
Possible values: 250,500,1000,2000
Default : 250
This should help to resolve your issue.
Regards,
Prateek

Etiquetas

Productos


Versión

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by