Unable to read data from the MPU6050 with TI C2000 f28379d & Simulink
Show older comments
Hi, I'm trying to read the data (accelerometer, gyroscope and thermometer) from an IMU 6 dof (MPU6050) using a TI C2000 f28379d with simulink. The MPU6050 uses I2C with the following registers:
- 0x68: I2C address of the MPU-6050
- 0x6B: PWR_MGMT_1 register
- 0x3B (ACCEL_XOUT_H) & 0x3C (ACCEL_XOUT_L)
- 0x3D (ACCEL_YOUT_H) & 0x3E (ACCEL_YOUT_L)
- 0x3F (ACCEL_ZOUT_H) & 0x40 (ACCEL_ZOUT_L)
- 0x41 (TEMP_OUT_H) & 0x42 (TEMP_OUT_L)
- 0x43 (GYRO_XOUT_H) & 0x44 (GYRO_XOUT_L)
- 0x45 (GYRO_YOUT_H) & 0x46 (GYRO_YOUT_L)
- 0x47 (GYRO_ZOUT_H) & 0x48 (GYRO_ZOUT_L)
To do this I modified the example provided with "Embedded Coder Support Package for Texas Instruments C2000 Processors": "c28x_i2c_sensor" with the following logic:
- write 0 to register 0x6B: wakes up the MPU-6050
- read register 0x3B (ACCEL_XOUT_H)
but I only read zeros (with external mode).
Electrical connections:
- SDA:P104
- SCL:P105
I attach the screens of the modified file.
Have any ideas to help me?
Thanks.
Accepted Answer
More Answers (5)
Antonin
on 11 May 2018
0 votes
Hi Tommaso,
The I2C blocks expect a slave I2C address in decimal format. You have to use hex2dec('68') or 104 for the slave address register.
Also, make sure to wait between the set of the read address to '3B' and the I2C receive request to read your sensor data, otherwise the I2C receive request will want to execute prior to the end of the previous I2C transmit. That is the reason for the "do {...} while" subsystem that you can find in the example: c28x_i2c_eeprom/EEPROM Data Read.
A way to avoid the wait is to first issue the I2C receive request, than transmit the '3B' address for the next hit of I2C receive. You can take care of the first instance in the init function.
I hope it helps,
Good luck,
Antonin.
tommaso serni
on 14 May 2018
0 votes
Antonin
on 15 May 2018
0 votes
Attached is a model that has been created in MATLAB R2016b for the MPU-9150 present on the BOOSTXL-SENSHUB attached to an F28027 Launchpad. It's meant to run in External mode as well. I think you can directly copy the blocks to your model. The model configuration will probably be different from yours.
I realize that the MPU-9150 uses the same addresses as the MPY-6050, so it should be very close.
Your function-call approach is good to sequence the execution, better than the block priorities that we use in the attached model. That's one improvement you can do. Like said above, there is a way to remove the wait loop, that's another possible improvement.
I hope it helps,
Antonin.
tommaso serni
on 15 May 2018
Ali Ozan
on 12 Aug 2018
0 votes
Hello tommaso serni;
I am working on a similar project where I need to read gyroscope data from MPU6050 using TI C2000 F28379D Launchpad.
Did you manage to solve the problem. Because in another thread you say "On CPU1: IMU 6dof reading (I2CA), use of serials SCIA/SCIB and PWM output for servo/ESC (ePWM1/ePWM2)". Can you please help me if you find a solution.
Best regards.
1 Comment
george kotoulas
on 1 Nov 2022
Hello,
Im running into the same problem. Did you find any solution?
Best regards, George.
Categories
Find more on Deployment, Integration, and Supported Hardware 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!