That's great. I can go into more detail if you like but basically the weirdness was being caused by some code being optimised out by the compiler. I guess over the years since this library was written the IDE has been through several updates and something must have changed in the way it compiles the code. I've put a bit in the code to stop the optimiser messing with it so that shouldn't be an issue anymore.Definite progress! It is now attempting the calibration
The robot rotates clockwise slightly more than 180 deg and then anti-clockwise by slightly less (from straight ahead) but no third rotation. It then sets off along the line in a zig-zaggy manner (with a bias to the right). This is on a "T" pattern. It found the first left and turned 180 but missed the straight on and turned right coming back
Overall it's very slow and hesitant (on a good battery) and keeps loosing the line.
It sounds like for some reason the left motor is spinning faster than the right motor. I assume it wasn't doing this before you originally re-flashed it? I'm just trying to figure if it's hardware related or not.
With regards to the calibration process with it first rotating more than 180 degrees, which also sounds like a symptom of one motor rotating too fast, you can tweak how much it turns by changing a value in the HCMRunner.h file.
If you open that file up in a text editor (if using Windows don't use notepad, it's rubbish and get the formatting wrong, use something like notepad++) on line 55 you can set the amount of time it does each calibration turn for (LSCALROTATIONTIME). The default is 1200. Try lowering it a little to see if it improves the calibration process any.
Could you also give the sketch below a try. All it will do is stick both motors into full speed forward. Does it look like one motor is spinning faster than the other? I.e. does it veer off in one direction?
- #define RIGHT_MOTOR_A 3
- #define RIGHT_MOTOR_B 2
- #define LEFT_MOTOR_A 5
- #define LEFT_MOTOR_B 4
- void setup()
- {
- pinMode(LEFT_MOTOR_A, OUTPUT);
- pinMode(LEFT_MOTOR_B, OUTPUT);
- pinMode(RIGHT_MOTOR_A, OUTPUT);
- pinMode(RIGHT_MOTOR_B, OUTPUT);
- digitalWrite(LEFT_MOTOR_A, HIGH);
- digitalWrite(LEFT_MOTOR_B, LOW);
- digitalWrite(RIGHT_MOTOR_A, HIGH);
- digitalWrite(RIGHT_MOTOR_B, LOW);
- }
- void loop()
- {
- }