Switched power terminals of Motor B and Motor A to test if Motor B was defective as it was unstable for a lot of the PID values.
Then commented out Direction = true/false in setMotor(A/B)(Reverse/Forward). This removed the instability issue. This is because Direction is a state of the motor, not a command. Instructing the motor to reverse or rotate forward doesn't mean it will do so instantaneously, it needs to slow down first.
Function logic for wheel(A/B) direction of the motor didn't reflect the true direction of the motor and/or conditions for changing direction. Therefore Direction(A/B) didn't change accordingly, leading to errors in the number of pulses counted, as they weren't incrementing/decrementing correctly.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.