Unable to read data from the MPU6050 with TI C2000 f28379d & Simulink
11 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
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
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
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.
0 个评论
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.
0 个评论
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
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!