MPU6050_DMP6 with Stepper Motor (Code all works, but had a question)

Hello. Just an FYI, I’ve got all of the code and instruments functioning. I’ve got an MPU6050 and a stepper motor that I’m integrating together. If the MPU6050 gives me any negative Roll value, I make the stepper motor run one direction and if it gives me a positive Roll value, the motor runs the other direction. I have a tolerance deadband of 0.03.

The stepper motor is being used as a linear actuator. I downloaded the standard “stepper_oneStepAtATime” code and added a couple of switches so I could run the motor one direction to get my min and max values. When I set this up to a 38400 baud, it ran SO smoothly up and down. It hummed and you could barely hear it.

I then added some stepper motor code to the standard “MPU6050_DMP” code and downloaded it. This code has the clock set really high and the baud rate set super high as well. When I try and change the baud rate to 38400, the motor is “chatters” like it’s skipping steps or something. Uncommenting the Wire.setClock(400000) didn’t seem to help either. I had to add delays (using the millis() method) to slow it significantly in order to put the stepper code in the same code as the MPU6050. It still “chatters”…

Has anybody run into this when trying to control a motor with the “MPU6050_DMP” code? Is the MPU6050_DMP code just supposed to take up one processor and my instruments/motors should go into another?

MPU6050_DMP6.ino (16.4 KB)

222_Linear_Actuator.ino (20.5 KB)

Capture_Total_Steps.ino (1.69 KB)

When I set this up to a 38400 baud, it ran SO smoothly up and down. It hummed and you could barely hear it.

A stepper motor doesn't have a baud rate, so this statement is nonsense.

I meant when I changed the baud rate in the "stepperOneStepAtATime" code from 9600 to 38200, it turned faster and more smoothly than at 9600. Are you saying that changing the baud rate doesn't affect how fast the code is executed, thus, how fast the motor would step one step at a time?

Are you saying that changing the baud rate doesn't affect how fast the code is executed

If affects how incoming, and outgoing, serial data is handled. It does not affect how fast the code is executed or how fast the stepper steps.