Hello, Newbie here.
I’m working on a project to control two stepper motors using an MPU6050 3 axis accelerometer/gyroscope. One motor moves for the X rotation data, the other for the Z rotation data from the MPU6050. I’m using an Arduino Uno (actually a Smraza Uno) and one A4988 motor controller for each Nema 17 stepper motor. See wiring diagram attached.
Everything works as expected after the MPU initialization but then at a random time (sometimes immediately, sometimes after 10 minutes) the MPU6050 starts putting out erratic noise in one or all axes. At this point I have to cut power to the sensor and start over.
When I have the motor power disconnected, the MPU signal is fine, the problems only start when the motors are getting power.
I’ve checked over all the electrical connections and tried adding 100uF capacitors over the power sources in case of spikes but none of that has fixed the issue. The problem doesn’t seem to depend on any physical adjustment of the system - I can leave the MPU 6050 sitting still and after a certain amount of time with the motors active, the angle signal from the MPU becomes completely erratic.
I’ve also check the voltage across the VCC input to the MPU and it’s getting 5V as expected, even when the signal is erratic.
I think it may be an issue with either of the following:
- Inconsistency in power supply to the MPU 6050
- Possible I2C clock mismatch, causing a misreading of the MPU data such that it’s interpreted as noise (see Arduino script attached). My script is fairly long and might be pushing the limits of the Arduino?
Has anyone else experienced this problem?? Any help in figuring this out would be highly appreciated!
Project_code.ino (14.4 KB)