Unable to read data from the MPU6050 with TI C2000 f28379d & Simulink

16 ビュー (過去 30 日間)
tommaso serni
tommaso serni 2018 年 5 月 8 日
コメント済み: george kotoulas 2022 年 11 月 1 日
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:
  1. write 0 to register 0x6B: wakes up the MPU-6050
  2. 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.

採用された回答

Aditya Padmanabha
Aditya Padmanabha 2018 年 5 月 24 日
編集済み: Aditya Padmanabha 2018 年 5 月 24 日
Hi Tommaso,
I have attached the 17a model for the MPU-9150 present on BOOSTXL_SENSHUB attached to F28379D LaunchPad based on the model provided by Antonin above. This model runs in External mode with suitable COM port. If you want to run this model on ControlCard instead of LaunchPad, you may need to modify the Clock, I2C and SCI settings accordingly.
In this model, I have used the function call approach for sequencing the I2C Transmit and Receive. You may need to do additional changes for configuration of MPY-6050 sensor.
I have not implemented the logic to reset the slave sensor in this model and you have to implement separate logic if you need to do so. Ensure the slave sensor is working in normal mode after reset. If there is no reset logic and if the communications break in between you may have to do power cycle the sensor and perform the C2000 board reset to pull the slave sensor from sleep mode.
One more thing you may have to do if you are running on F28379D LaunchPad is to create additional circuit for SDA and SCL pins between Master and Slave as shown in the attached image. This ensures a stronger pullup and stable I2C communication between F28379D LaunchPad and MPU-9150.
The pullup resistor (2.2K Ohm) may not be required if the pullup is already present in the sensor module. but the 33 Ohm series resistor is required between F28379D LaunchPad and Sensor module without which the I2C communication is not stable and may return zero always when you read the sensor data.
I hope it helps,
Thanks,
Aditya
  1 件のコメント
Aditya Padmanabha
Aditya Padmanabha 2018 年 5 月 25 日
Hi Tommaso,
More information on the I2C glitch issue which causes the problem in F28379D LaunchPads in TI E2E https://e2e.ti.com/support/microcontrollers/c2000/f/171/t/676372.
Thanks,
Aditya

サインインしてコメントする。

その他の回答 (5 件)

Antonin
Antonin 2018 年 5 月 11 日
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
tommaso serni 2018 年 5 月 14 日
Thanks for the answer Antonin.
I modified the example as you advised me (I attach the images) but I continue to read only zeros.
I tried to reduce the sample time of the "InitTrigger" and "Rate Transition" blocks to 15e-2 s and 1e-2 s respectively, but without results.
Best regards,
Tommaso.

Antonin
Antonin 2018 年 5 月 15 日
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
tommaso serni 2018 年 5 月 15 日
Thanks for the help Antonin,
I copied the blocks in my model but I get the following error:
unable to honor user-specified priorities. 'i2c_sensor_example_antonin/First time Init/High Addr/Constant' (pri=[10, Inf]) has to execute before 'i2c_sensor_example_antonin/First time Init/I2C Transmit1' (pri=[2]) to satisfy data dependencies
Error:Error occurred while executing External Mode MEX-file 'ext_comm':
Failed to connect to the target. A time-out occurred while waiting for the connection response from the target. Possible reasons for the time-out:
a) The target is not switched on.
b) The target is not connected to your host machine.
c) The application for the model is not running on the target. You might have clicked the Stop button. If the Run button is not dimmed, click it. Otherwise, click the Build button, which downloads and runs your application on the target.
Error:Unable to connect to the 'TI Delfino F2837xD' target for 'i2c_sensor_example_antonin'.
After various tests I realized that removing the "While Iterator Subsystem" block I don't receive errors from the model, but obviously I do not read the data.
Do you have any ideas to solve the problem?
Best regards,
Tommaso.

Ali Ozan
Ali Ozan 2018 年 8 月 12 日
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 件のコメント
george kotoulas
george kotoulas 2022 年 11 月 1 日
Hello,
Im running into the same problem. Did you find any solution?
Best regards, George.

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by