akimach / LSM9DS1_RaspberryPi_Library

RaspberryPi library for the LSM9DS1 9DOF IMU
19 stars 19 forks source link

Initializing IMU breaks PWM on raspberry pi #7

Closed saspelund closed 5 years ago

saspelund commented 5 years ago

I am working with a Raspberry Pi 2B. I am trying to use this IMU and provided libraries/code in a robot that also utilizes PWM for motor control. I can show (LED+oscilloscope) that the PWM (using wiringPi) works immediately before but not after the following code:

LSM9DS1 imu(IMU_MODE_I2C, 0x6b, 0x1e);

let alone

imu.begin();

If the PWM is connected to PWM0 (either pin), then the measured PWM signals jump all over the place rather than smoothly increasing the duty ratio and then decreasing it multiple times. If the PWM is connected to PWM1, then the PWM signal remains flatlined.

The IMU works fine which is very nice. Thank you!

Similar issue: https://raspberrypi.stackexchange.com/questions/53455/pwm-conflicts-with-i2c

saspelund commented 5 years ago

It turns out that this code uses WiringPiSetupGpio() while I was just using WiringPiSetup() so there was a pin mapping mix-up.