If your motors are miswired, it can cause the problems you are having. Several possible sources of miswiring are:
- You have "PID speed control set" but the encoders are not connected. No changes will be detected on the encoders so the PID algorithm will adjust to maximum speed.
- You have the four wire motor encoder connected backwards. The orange lead should be on the "fat" side of the motor controller.
- the motor leads are connected "opposite". That is, they're connected so that when the motor is going forward (positive) the encoder is counting reverse (negative). Simply swap the motor leads.
- Motor encoder 1 is connected to motor encoder 2 input and vice versa.
I spent an hour with my initial robot wondering what had happened until I got this straightened out.
A good way to test that you have your wiring accurate is to use the "NXT Devices" command found in the debugger. Here's how to do this:
- Download the file included in this post. It's a small program that alternately drives each of the motors forward and then reverse for two seconds.
- Compile the program and download to NXT.
- Run the program with the ROBOTC debugger window "NXT Devices" open.
- Monitor the results in the debugger window and verify that they are the expected ones.
More detailed instructions are included in the comments of the test program. This program will also be included in the sample programs folder for the next ROBOTC release.