I am currently trying to build an inverted pendulum and am using SimpleFOCShield 2.0.1 to control my motor. The motor works fine, but the gy-521 that should provide the angle of the pendulum stops working when I add the SimpleFOC motor, encoder and driver code. When I comment out the SimpleFOC stuff, the angle sensor works just the way I want it to, but when the code runs alongside it, the angles get all weird. The gy-521 uses the Arduino-Uno analog pins A4 and A5 (or the SCL and SDA), so I was wondering if SimpleFOC interferes in any way with those pins. The angle I get isn’t noisy or anything, it looks like the original angle is multiplied by a factor (for example, if I moved the pendulum 10 degrees, the angle would output that it moved 180 degrees).
For the driver, I use the recommended pinout with PWM pins 9, 5, and 6. For the encoder (AMT103-V), I use interrupt pins 2 and 3.
BLDCDriver3PWM Driver = BLDCDriver3PWM(9, 5, 6, 8);
Encoder = Encoder(2, 3, 500);
For the gy-521 i use the TinyMPU6050.h lib. Unfortunatly i dont know much about that lib or the lines of code that make it work.
This is used for init:
MPU6050 mpu (Wire);
This will be called to get the information:
pendulumAngleZ = mpu.GetAngZ();
pendulumAngleVelocityZ = mpu.GetGyroZ();
I hope it’s enough information to work with and thank you all in advance.