File Exchange

image thumbnail

Raspberry Pi MPU6050-HMC5883L SFunction with I2C Communication using WiringPiI2C

version 1.2.0.0 (41.4 KB) by Glen
9DOF S-function with MPU6050 and HMC5883L

6 Downloads

Updated 07 Oct 2013

View License

Building on the work of Joshua Hurst MPU6050 S-function. His original s-function had been edited to provide 9DOF with the HMC5883L.

There are two modes - Pass through where the Magnetometer Data is read directly from the HMC5883L via the AUX I2C. Then, when the MPU6050 is configured as master the Magnetometer Data is read from the Slave Registers on the MPU6050.

The I2C library used is WirnigPiI2C which comes with the target-installer distribution of RPi.

Comments and Ratings (6)

Jorie

I also got the error as Jordan Luke, solution indeed was to add "-lwiringPi" to linker argument.

I found the solution to my own problem and Jordan Luke's. The problem is that wiringPi is not in the linker search path. This can be established by using the matlab command "xmakefilesetup" for details read the blog of John Whittington: http://wp.me/p2C0Bi-bK

I also get the error as Jordan Luke got. Has someone (or Jordan perhaps) a solution?

jorden Luke

I have tried running this today On my Pi. And For some reason I get some errors and I can't figure out why.

Error:

The call to realtime_make_rtw_hook, during the after_make hook generated the following error:
Error executing SSH command: make: Entering directory '/home/pi/MPU6050_HMC5883L_PASS_THRU_IMU_rtt'
"gcc" -I"./" -O3 -D"MODEL=MPU6050_HMC5883L_PASS_THRU_IMU" -D"NUMST=1" -D"NCSTATES=0" -D"HAVESTDIO=" -D"ON_TARGET_WAIT_FOR_START=1" -D"ONESTEPFCN=0" -D"EXT_MODE=1" -D"TERMFCN=1" -D"MAT_FILE=0" -D"MULTI_INSTANCE_CODE=0" -D"INTEGER_CODE=0" -D"MT=0" -D"CLASSIC_INTERFACE=0" -D"ALLOCATIONFCN=0" -D"TID01EQ=0" -D"_USE_TARGET_UDP_=" -D"_RUNONTARGETHARDWARE_BUILD_=" -D"EXIT_FAILURE=1" -D"EXTMODE_DISABLETESTING=" -c ./linuxUDP.c ./ext_svr.c ./ext_work.c ./rtiostream_interface.c ./updown.c ./rtiostream_tcpip.c ./rtiostream_utils.c ./MPU6050_HMC5883L_PASS_THRU_IMU.c ./ert_main.c ./sf_IMU_PASS_wrapper.c
"gcc" ./linuxUDP.o ./ext_svr.o ./ext_work.o ./rtiostream_interface.o ./updown.o ./rtiostream_tcpip.o ./rtiostream_utils.o ./MPU6050_HMC5883L_PASS_THRU_IMU.o ./ert_main.o ./sf_IMU_PASS_wrapper.o -lm -ldl -lpthread -lrt -o ./MW/MPU6050_HMC5883L_PASS_THRU_IMU
./sf_IMU_PASS_wrapper.o: In function `pinMode.constprop.11':
sf_IMU_PASS_wrapper.c:(.text+0xee4): undefined reference to `softPwmStop'
sf_IMU_PASS_wrapper.c:(.text+0xeec): undefined reference to `softToneStop'
./sf_IMU_PASS_wrapper.o: In function `pinMode':
sf_IMU_PASS_wrapper.c:(.text+0x14e4): undefined reference to `softPwmStop'
sf_IMU_PASS_wrapper.c:(.text+0x14ec): undefined reference to `softToneStop'
sf_IMU_PASS_wrapper.c:(.text+0x16b8): undefined reference to `softPwmCreate'
sf_IMU_PASS_wrapper.c:(.text+0x16c4): undefined reference to `softToneCreate'
collect2: ld returned 1 exit status
_MPU6050_HMC5883L_PASS_THRU_IMU.mk:122: recipe for target 'MW/MPU6050_HMC5883L_PASS_THRU_IMU' failed
make: *** [MW/MPU6050_HMC5883L_PASS_THRU_IMU] Error 1
make: Leaving directory '/home/pi/MPU6050_HMC5883L_PASS_THRU_IMU_rtt'

The build process will terminate as a result.

Error executing SSH command: make: Entering directory '/home/pi/MPU6050_HMC5883L_PASS_THRU_IMU_rtt'
"gcc" -I"./" -O3 -D"MODEL=MPU6050_HMC5883L_PASS_THRU_IMU" -D"NUMST=1" -D"NCSTATES=0" -D"HAVESTDIO=" -D"ON_TARGET_WAIT_FOR_START=1" -D"ONESTEPFCN=0" -D"EXT_MODE=1" -D"TERMFCN=1" -D"MAT_FILE=0" -D"MULTI_INSTANCE_CODE=0" -D"INTEGER_CODE=0" -D"MT=0" -D"CLASSIC_INTERFACE=0" -D"ALLOCATIONFCN=0" -D"TID01EQ=0" -D"_USE_TARGET_UDP_=" -D"_RUNONTARGETHARDWARE_BUILD_=" -D"EXIT_FAILURE=1" -D"EXTMODE_DISABLETESTING=" -c ./linuxUDP.c ./ext_svr.c ./ext_work.c ./rtiostream_interface.c ./updown.c ./rtiostream_tcpip.c ./rtiostream_utils.c ./MPU6050_HMC5883L_PASS_THRU_IMU.c ./ert_main.c ./sf_IMU_PASS_wrapper.c
"gcc" ./linuxUDP.o ./ext_svr.o ./ext_work.o ./rtiostream_interface.o ./updown.o ./rtiostream_tcpip.o ./rtiostream_utils.o ./MPU6050_HMC5883L_PASS_THRU_IMU.o ./ert_main.o ./sf_IMU_PASS_wrapper.o -lm -ldl -lpthread -lrt -o ./MW/MPU6050_HMC5883L_PASS_THRU_IMU
./sf_IMU_PASS_wrapper.o: In function `pinMode.constprop.11':
sf_IMU_PASS_wrapper.c:(.text+0xee4): undefined reference to `softPwmStop'
sf_IMU_PASS_wrapper.c:(.text+0xeec): undefined reference to `softToneStop'
./sf_IMU_PASS_wrapper.o: In function `pinMode':
sf_IMU_PASS_wrapper.c:(.text+0x14e4): undefined reference to `softPwmStop'
sf_IMU_PASS_wrapper.c:(.text+0x14ec): undefined reference to `softToneStop'
sf_IMU_PASS_wrapper.c:(.text+0x16b8): undefined reference to `softPwmCreate'
sf_IMU_PASS_wrapper.c:(.text+0x16c4): undefined reference to `softToneCreate'
collect2: ld returned 1 exit status
_MPU6050_HMC5883L_PASS_THRU_IMU.mk:122: recipe for target 'MW/MPU6050_HMC5883L_PASS_THRU_IMU' failed
make: *** [MW/MPU6050_HMC5883L_PASS_THRU_IMU] Error 1
make: Leaving directory '/home/pi/MPU6050_HMC5883L_PASS_THRU_IMU_rtt'

Hamza

Hi !

Thank you for sharing :) Is it possible to add the management of the MS5611 ?

bests

sakuyaki

Updates

1.2.0.0

Added new files

MATLAB Release Compatibility
Created with R2013a
Compatible with any release
Platform Compatibility
Windows macOS Linux