Need Help with MPU 6050

At the beginning of this year, I decided that I was going to make a bunch of electronics balance on 2 wheels. gahhh

Im using an Arduino Uno with a MPU6050 and an Odrive motor controller that is controlled using two PWM pins from the Arduino. I am also trying to use "pulseIn(5, HIGH, 25000);" to accept two more signals from my radio receiver.

the library that I'm using for the MPU6050 is using an interrupt pin and is enabled for DMP, it is called
#include "I2Cdev.h"
#include "MPU6050_6Axis_MotionApps20.h"
Im using the MPU6050_DMP6 example

Right now, the problem is as follows:

1.When I output values VIA "Left.writeMicroseconds(writespeed+Steer);" it messes up the values that I get back from the MPU6050. -- UPDATE-- This problem is just electrical noise screwing with... something. it goes away with the Odrive motor controller powered off.

  1. When I read my radio receiver VIA "pulseIn(5, HIGH, 25000);" that causes the Gyro reading sketch to completely stop reading the area of the code that was left for non-gyro purposes.

is this something to do with Arduino's available timers?

In case you're wondering why I'm using the DMP sketch, it's because the data that I get back from it, (assuming that I don't adulterate the program with my stuff) is soo beautiful and accurate, regardless of the boot orientation the machine finds out where it needs to be and goes there, but as soon as I try to write to the motor controller or read from the RC receiver it all goes to ... well

what do I do! i've been screwing with this thing for a month now... haha

thanks in advance :slight_smile:

BalanceCarMakeWork copy.zip (5.1 KB)

I’m wondering if you’ve outgrown the UNO

Well, maybe... Yes. And i actually have a plethura of other Arduino boards that could be used, i just get so fed up with compatibility stuff that i've stopped using them. (teensy, due, mega, lenardo, digispark, nano)

I feel your pain. My goto is usually a nano now a days

Wanted to update this, for whatever reason, achieving DMP with the MPU6050 is nearly impossible, but achievable if that is all your Arduino is doing.

what I ended up doing is setting up an Arduino Nano that would read the values from the MPU6050 with really really short wires between them ( less than 1") in DMP mode, and then just serial write back with the one value that I wanted. then I read that value with another Arduino. for whatever reason, doing this prevented the ODrive from interfering with the signal, and also fixed the issue with the RC receiver read instruction, because now that is being done in the main controller.

I think for my IMU projects it’s time for the Cortex chips